Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 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 value: '' |
| 44 }, | |
| 45 | |
| 46 // True if it's searching at the backend. | |
| 47 searching_: { | |
| 48 type: Boolean, | |
| 49 value: false | |
| 44 } | 50 } |
| 45 }, | 51 }, |
| 46 | 52 |
| 47 /** | 53 /** |
| 48 * Changes the toolbar background color depending on whether any history items | 54 * Changes the toolbar background color depending on whether any history items |
| 49 * are currently selected. | 55 * are currently selected. |
| 50 * @private | 56 * @private |
| 51 */ | 57 */ |
| 52 changeToolbarView_: function() { | 58 changeToolbarView_: function() { |
| 53 this.itemsSelected_ = this.count > 0; | 59 this.itemsSelected_ = this.count > 0; |
| 54 }, | 60 }, |
| 55 | 61 |
| 56 /** | 62 /** |
| 57 * When changing the search term externally, update the search field to | 63 * When changing the search term externally, update the search field to |
| 58 * reflect the new search term. | 64 * reflect the new search term. |
| 59 * @param {string} search | 65 * @param {string} search |
| 60 */ | 66 */ |
| 61 setSearchTerm: function(search) { | 67 setSearchTerm: function(search) { |
| 62 if (this.searchTerm == search) | 68 if (this.searchTerm == search) |
| 63 return; | 69 return; |
| 64 this.searchTerm = search; | 70 this.searchTerm = search; |
| 65 var searchField = /** @type {SearchField} */(this.$['search-input']); | 71 var searchField = /** @type {SearchField} */(this.$['search-input']); |
| 66 searchField.showAndFocus().then(function(showing) { | 72 searchField.showAndFocus().then(function(showing) { |
| 67 if (showing) searchField.setValue(search); | 73 if (showing) searchField.setValue(search); |
| 68 }); | 74 }); |
| 69 }, | 75 }, |
| 70 | 76 |
| 71 /** | 77 /** |
| 78 * Mark the toolbar as currently searching term from the back-end. | |
|
tsergeant
2016/04/15 05:14:50
You can either replace these two functions with a
lshang
2016/04/18 00:29:00
Done.
| |
| 79 */ | |
| 80 setSearching: function() { | |
| 81 this.searching_ = true; | |
| 82 }, | |
| 83 | |
| 84 /** | |
| 85 * Set searching as finished so that searching spinner is hidden. | |
| 86 */ | |
| 87 searchingFinished: function() { | |
| 88 this.searching_ = false; | |
| 89 }, | |
| 90 | |
| 91 | |
| 92 /** | |
| 72 * If the search term has changed reload for the new search. | 93 * If the search term has changed reload for the new search. |
| 73 */ | 94 */ |
| 74 onSearch: function(searchTerm) { | 95 onSearch: function(searchTerm) { |
| 75 if (searchTerm != this.searchTerm) { | 96 if (searchTerm != this.searchTerm) { |
| 76 this.searchTerm = searchTerm; | 97 this.searchTerm = searchTerm; |
| 77 this.fire('search-changed', {search: searchTerm}); | 98 this.fire('search-changed', {search: searchTerm}); |
| 78 } | 99 } |
| 79 }, | 100 }, |
| 80 | 101 |
| 81 attached: function() { | 102 attached: function() { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 105 * @private | 126 * @private |
| 106 */ | 127 */ |
| 107 deletingAllowed_: function() { | 128 deletingAllowed_: function() { |
| 108 return loadTimeData.getBoolean('allowDeletingHistory'); | 129 return loadTimeData.getBoolean('allowDeletingHistory'); |
| 109 }, | 130 }, |
| 110 | 131 |
| 111 numberOfItemsSelected_: function(count) { | 132 numberOfItemsSelected_: function(count) { |
| 112 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; | 133 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; |
| 113 } | 134 } |
| 114 }); | 135 }); |
| OLD | NEW |