OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {SearchFieldDelegate} | 7 * @implements {SearchFieldDelegate} |
8 * @param {!HistoryToolbarElement} toolbar This history-toolbar. | 8 * @param {!HistoryToolbarElement} toolbar This history-toolbar. |
9 */ | 9 */ |
10 function ToolbarSearchFieldDelegate(toolbar) { | 10 function ToolbarSearchFieldDelegate(toolbar) { |
(...skipping 22 matching lines...) Expand all Loading... |
33 itemsSelected_: { | 33 itemsSelected_: { |
34 type: Boolean, | 34 type: Boolean, |
35 value: false, | 35 value: false, |
36 reflectToAttribute: true | 36 reflectToAttribute: true |
37 }, | 37 }, |
38 | 38 |
39 // The most recent term entered in the search field. Updated incrementally | 39 // The most recent term entered in the search field. Updated incrementally |
40 // as the user types. | 40 // as the user types. |
41 searchTerm: { | 41 searchTerm: { |
42 type: String, | 42 type: String, |
43 value: '' | 43 notify: true, |
44 }, | 44 }, |
45 | 45 |
46 // True if waiting on the search backend. | 46 // True if waiting on the search backend. |
47 searching: { | 47 searching: { |
48 type: Boolean, | 48 type: Boolean, |
49 value: false | 49 value: false |
50 }, | 50 }, |
51 | 51 |
52 // Whether domain-grouped history is enabled. | 52 // Whether domain-grouped history is enabled. |
53 isGroupedMode: { | 53 isGroupedMode: { |
(...skipping 25 matching lines...) Expand all Loading... |
79 }, | 79 }, |
80 | 80 |
81 /** | 81 /** |
82 * When changing the search term externally, update the search field to | 82 * When changing the search term externally, update the search field to |
83 * reflect the new search term. | 83 * reflect the new search term. |
84 * @param {string} search | 84 * @param {string} search |
85 */ | 85 */ |
86 setSearchTerm: function(search) { | 86 setSearchTerm: function(search) { |
87 if (this.searchTerm == search) | 87 if (this.searchTerm == search) |
88 return; | 88 return; |
| 89 |
89 this.searchTerm = search; | 90 this.searchTerm = search; |
90 var searchField = /** @type {SearchField} */(this.$['search-input']); | 91 var searchField = /** @type {SearchField} */(this.$['search-input']); |
91 searchField.showAndFocus().then(function(showing) { | 92 searchField.showAndFocus().then(function(showing) { |
92 if (showing) searchField.setValue(search); | 93 if (showing) searchField.setValue(search); |
93 }); | 94 }); |
94 }, | 95 }, |
95 | 96 |
96 /** | 97 /** |
97 * If the search term has changed reload for the new search. | 98 * If the search term has changed reload for the new search. |
98 */ | 99 */ |
99 onSearch: function(searchTerm) { | 100 onSearch: function(searchTerm) { |
100 if (searchTerm != this.searchTerm) { | 101 if (searchTerm != this.searchTerm) |
101 this.searchTerm = searchTerm; | 102 this.searchTerm = searchTerm; |
102 this.fire('search-changed', {search: searchTerm}); | |
103 } | |
104 }, | 103 }, |
105 | 104 |
106 attached: function() { | 105 attached: function() { |
107 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); | 106 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
108 /** @type {SearchField} */(this.$['search-input']) | 107 /** @type {SearchField} */(this.$['search-input']) |
109 .setDelegate(this.searchFieldDelegate_); | 108 .setDelegate(this.searchFieldDelegate_); |
110 }, | 109 }, |
111 | 110 |
112 onClearSelectionTap_: function() { | 111 onClearSelectionTap_: function() { |
113 this.fire('unselect-all'); | 112 this.fire('unselect-all'); |
(...skipping 14 matching lines...) Expand all Loading... |
128 numberOfItemsSelected_: function(count) { | 127 numberOfItemsSelected_: function(count) { |
129 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; | 128 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; |
130 }, | 129 }, |
131 | 130 |
132 getHistoryInterval_: function(queryStartTime, queryEndTime) { | 131 getHistoryInterval_: function(queryStartTime, queryEndTime) { |
133 // TODO(calamity): Fix the format of these dates. | 132 // TODO(calamity): Fix the format of these dates. |
134 return loadTimeData.getStringF( | 133 return loadTimeData.getStringF( |
135 'historyInterval', queryStartTime, queryEndTime); | 134 'historyInterval', queryStartTime, queryEndTime); |
136 } | 135 } |
137 }); | 136 }); |
OLD | NEW |