| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 90 this.searchTerm = search; | 90 this.searchTerm = search; |
| 91 var searchField = /** @type {SearchField} */(this.$['search-input']); | 91 var searchField = /** @type {!CrToolbarElement} */(this.$['main-toolbar']) |
| 92 .getSearchField(); |
| 92 searchField.showAndFocus().then(function(showing) { | 93 searchField.showAndFocus().then(function(showing) { |
| 93 if (showing) searchField.setValue(search); | 94 if (showing) searchField.setValue(search); |
| 94 }); | 95 }); |
| 95 }, | 96 }, |
| 96 | 97 |
| 97 /** | 98 /** |
| 98 * If the search term has changed reload for the new search. | 99 * If the search term has changed reload for the new search. |
| 99 */ | 100 */ |
| 100 onSearch: function(searchTerm) { | 101 onSearch: function(searchTerm) { |
| 101 if (searchTerm != this.searchTerm) | 102 if (searchTerm != this.searchTerm) |
| 102 this.searchTerm = searchTerm; | 103 this.searchTerm = searchTerm; |
| 103 }, | 104 }, |
| 104 | 105 |
| 105 attached: function() { | 106 attached: function() { |
| 106 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); | 107 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
| 107 /** @type {SearchField} */(this.$['search-input']) | 108 /** @type {!CrToolbarElement} */(this.$['main-toolbar']).getSearchField() |
| 108 .setDelegate(this.searchFieldDelegate_); | 109 .setDelegate(this.searchFieldDelegate_); |
| 109 }, | 110 }, |
| 110 | 111 |
| 111 onClearSelectionTap_: function() { | 112 onClearSelectionTap_: function() { |
| 112 this.fire('unselect-all'); | 113 this.fire('unselect-all'); |
| 113 }, | 114 }, |
| 114 | 115 |
| 115 onDeleteTap_: function() { | 116 onDeleteTap_: function() { |
| 116 this.fire('delete-selected'); | 117 this.fire('delete-selected'); |
| 117 }, | 118 }, |
| 118 | 119 |
| 119 /** | 120 /** |
| 120 * If the user is a supervised user the delete button is not shown. | 121 * If the user is a supervised user the delete button is not shown. |
| 121 * @private | 122 * @private |
| 122 */ | 123 */ |
| 123 deletingAllowed_: function() { | 124 deletingAllowed_: function() { |
| 124 return loadTimeData.getBoolean('allowDeletingHistory'); | 125 return loadTimeData.getBoolean('allowDeletingHistory'); |
| 125 }, | 126 }, |
| 126 | 127 |
| 127 numberOfItemsSelected_: function(count) { | 128 numberOfItemsSelected_: function(count) { |
| 128 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; | 129 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; |
| 129 }, | 130 }, |
| 130 | 131 |
| 131 getHistoryInterval_: function(queryStartTime, queryEndTime) { | 132 getHistoryInterval_: function(queryStartTime, queryEndTime) { |
| 132 // TODO(calamity): Fix the format of these dates. | 133 // TODO(calamity): Fix the format of these dates. |
| 133 return loadTimeData.getStringF( | 134 return loadTimeData.getStringF( |
| 134 'historyInterval', queryStartTime, queryEndTime); | 135 'historyInterval', queryStartTime, queryEndTime); |
| 135 } | 136 } |
| 136 }); | 137 }); |
| OLD | NEW |