| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * When changing the search term externally, update the search field to | 63 * When changing the search term externally, update the search field to |
| 64 * reflect the new search term. | 64 * reflect the new search term. |
| 65 * @param {string} search | 65 * @param {string} search |
| 66 */ | 66 */ |
| 67 setSearchTerm: function(search) { | 67 setSearchTerm: function(search) { |
| 68 if (this.searchTerm == search) | 68 if (this.searchTerm == search) |
| 69 return; | 69 return; |
| 70 this.searchTerm = search; | 70 this.searchTerm = search; |
| 71 var searchField = /** @type {SearchField} */(this.$['search-input']); | 71 var toolbar = /** @type {CrToolbarElement} */(this.$['main-toolbar']); |
| 72 searchField.showAndFocus().then(function(showing) { | 72 toolbar.showAndFocus().then(function(showing) { |
| 73 if (showing) searchField.setValue(search); | 73 if (showing) toolbar.setValue(search); |
| 74 }); | 74 }); |
| 75 }, | 75 }, |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * If the search term has changed reload for the new search. | 78 * If the search term has changed reload for the new search. |
| 79 */ | 79 */ |
| 80 onSearch: function(searchTerm) { | 80 onSearch: function(searchTerm) { |
| 81 if (searchTerm != this.searchTerm) { | 81 if (searchTerm != this.searchTerm) { |
| 82 this.searchTerm = searchTerm; | 82 this.searchTerm = searchTerm; |
| 83 this.fire('search-changed', {search: searchTerm}); | 83 this.fire('search-changed', {search: searchTerm}); |
| 84 } | 84 } |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 attached: function() { | 87 attached: function() { |
| 88 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); | 88 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this); |
| 89 /** @type {SearchField} */(this.$['search-input']) | 89 /** @type {CrToolbarElement} */(this.$['main-toolbar']) |
| 90 .setDelegate(this.searchFieldDelegate_); | 90 .setDelegate(this.searchFieldDelegate_); |
| 91 }, | 91 }, |
| 92 | 92 |
| 93 onClearSelectionTap_: function() { | 93 onClearSelectionTap_: function() { |
| 94 this.fire('unselect-all'); | 94 this.fire('unselect-all'); |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 onDeleteTap_: function() { | 97 onDeleteTap_: function() { |
| 98 this.fire('delete-selected'); | 98 this.fire('delete-selected'); |
| 99 }, | 99 }, |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * If the user is a supervised user the delete button is not shown. | 102 * If the user is a supervised user the delete button is not shown. |
| 103 * @private | 103 * @private |
| 104 */ | 104 */ |
| 105 deletingAllowed_: function() { | 105 deletingAllowed_: function() { |
| 106 return loadTimeData.getBoolean('allowDeletingHistory'); | 106 return loadTimeData.getBoolean('allowDeletingHistory'); |
| 107 }, | 107 }, |
| 108 | 108 |
| 109 numberOfItemsSelected_: function(count) { | 109 numberOfItemsSelected_: function(count) { |
| 110 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; | 110 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; |
| 111 } | 111 } |
| 112 }); | 112 }); |
| OLD | NEW |