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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 }, | 86 }, |
87 | 87 |
88 /** | 88 /** |
89 * When changing the search term externally, update the search field to | 89 * When changing the search term externally, update the search field to |
90 * reflect the new search term. | 90 * reflect the new search term. |
91 * @param {string} search | 91 * @param {string} search |
92 */ | 92 */ |
93 setSearchTerm: function(search) { | 93 setSearchTerm: function(search) { |
94 if (this.searchTerm == search) | 94 if (this.searchTerm == search) |
95 return; | 95 return; |
| 96 |
96 this.searchTerm = search; | 97 this.searchTerm = search; |
97 var searchField = /** @type {SearchField} */(this.$['search-input']); | 98 var searchField = /** @type {SearchField} */(this.$['search-input']); |
98 searchField.showAndFocus().then(function(showing) { | 99 searchField.showAndFocus().then(function(showing) { |
99 if (showing) searchField.setValue(search); | 100 if (showing) searchField.setValue(search); |
100 }); | 101 }); |
101 }, | 102 }, |
102 | 103 |
103 /** | 104 /** |
104 * If the search term has changed reload for the new search. | 105 * If the search term has changed reload for the new search. |
105 */ | 106 */ |
106 onSearch: function(searchTerm) { | 107 onSearch: function(searchTerm) { |
107 if (searchTerm != this.searchTerm) { | 108 if (searchTerm != this.searchTerm) |
108 this.searchTerm = searchTerm; | 109 this.searchTerm = searchTerm; |
109 this.fire('search-changed', {search: searchTerm}); | |
110 } | |
111 }, | 110 }, |
112 | 111 |
113 attached: function() { | 112 attached: function() { |
114 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); | 113 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
115 /** @type {SearchField} */(this.$['search-input']) | 114 /** @type {SearchField} */(this.$['search-input']) |
116 .setDelegate(this.searchFieldDelegate_); | 115 .setDelegate(this.searchFieldDelegate_); |
117 }, | 116 }, |
118 | 117 |
119 onClearSelectionTap_: function() { | 118 onClearSelectionTap_: function() { |
120 this.fire('unselect-all'); | 119 this.fire('unselect-all'); |
(...skipping 18 matching lines...) Expand all Loading... |
139 groupedModeChanged_: function() { | 138 groupedModeChanged_: function() { |
140 this.isRtl_ = isRTL(); | 139 this.isRtl_ = isRTL(); |
141 }, | 140 }, |
142 | 141 |
143 getHistoryInterval_: function(queryStartTime, queryEndTime) { | 142 getHistoryInterval_: function(queryStartTime, queryEndTime) { |
144 // TODO(calamity): Fix the format of these dates. | 143 // TODO(calamity): Fix the format of these dates. |
145 return loadTimeData.getStringF( | 144 return loadTimeData.getStringF( |
146 'historyInterval', queryStartTime, queryEndTime); | 145 'historyInterval', queryStartTime, queryEndTime); |
147 } | 146 } |
148 }); | 147 }); |
OLD | NEW |