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 Polymer({ | 5 Polymer({ |
| 6 is: 'history-list', | 6 is: 'history-list', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 // An array of history entries in reverse chronological order. | 9 // An array of history entries in reverse chronological order. |
| 10 historyData: { | 10 historyData: { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 type: String, | 21 type: String, |
| 22 value: '' | 22 value: '' |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 // True if there is a pending request to the backend. | 25 // True if there is a pending request to the backend. |
| 26 loading_: { | 26 loading_: { |
| 27 type: Boolean, | 27 type: Boolean, |
| 28 value: true | 28 value: true |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 // True if it's searching at the backend. | |
| 32 searching_: { | |
| 33 type: Boolean, | |
| 34 value: false | |
| 35 }, | |
| 36 | |
| 31 resultLoadingDisabled_: { | 37 resultLoadingDisabled_: { |
| 32 type: Boolean, | 38 type: Boolean, |
| 33 value: false | 39 value: false |
| 34 }, | 40 }, |
| 35 }, | 41 }, |
| 36 | 42 |
| 37 listeners: { | 43 listeners: { |
| 38 'infinite-list.scroll': 'closeMenu_', | 44 'infinite-list.scroll': 'closeMenu_', |
| 39 'tap': 'closeMenu_', | 45 'tap': 'closeMenu_', |
| 40 'toggle-menu': 'toggleMenu_', | 46 'toggle-menu': 'toggleMenu_', |
| 41 }, | 47 }, |
| 42 | 48 |
| 43 /** | 49 /** |
| 44 * Closes the overflow menu. | 50 * Closes the overflow menu. |
| 45 * @private | 51 * @private |
| 46 */ | 52 */ |
| 47 closeMenu_: function() { | 53 closeMenu_: function() { |
| 48 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).closeMenu(); | 54 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).closeMenu(); |
| 49 }, | 55 }, |
| 50 | 56 |
| 51 /** | 57 /** |
| 52 * Mark the page as currently loading new data from the back-end. | 58 * Mark the page as currently loading new data from the back-end. |
| 53 */ | 59 */ |
| 54 setLoading: function() { | 60 setSearching: function() { |
|
tsergeant
2016/04/07 01:07:02
We need to be careful about changing when loading_
lshang
2016/04/15 03:31:54
Done.
Thanks for reminding!
| |
| 55 this.loading_ = true; | 61 this.searching_ = true; |
| 56 }, | 62 }, |
| 57 | 63 |
| 58 /** | 64 /** |
| 59 * Opens the overflow menu unless the menu is already open and the same button | 65 * Opens the overflow menu unless the menu is already open and the same button |
| 60 * is pressed. | 66 * is pressed. |
| 61 * @param {Event} e The event with details of the menu item that was clicked. | 67 * @param {Event} e The event with details of the menu item that was clicked. |
| 62 * @private | 68 * @private |
| 63 */ | 69 */ |
| 64 toggleMenu_: function(e) { | 70 toggleMenu_: function(e) { |
| 65 var target = e.detail.target; | 71 var target = e.detail.target; |
| 66 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).toggleMenu( | 72 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).toggleMenu( |
| 67 target, e.detail.timestamp); | 73 target, e.detail.timestamp); |
| 68 }, | 74 }, |
| 69 | 75 |
| 70 /** | 76 /** |
| 71 * Disables history result loading when there are no more history results. | 77 * Disables history result loading when there are no more history results. |
| 72 */ | 78 */ |
| 73 disableResultLoading: function() { | 79 disableResultLoading: function() { |
| 74 this.resultLoadingDisabled_ = true; | 80 this.resultLoadingDisabled_ = true; |
| 75 }, | 81 }, |
| 76 | 82 |
| 77 /** | 83 /** |
| 78 * Adds the newly updated history results into historyData. Adds new fields | 84 * Adds the newly updated history results into historyData. Adds new fields |
| 79 * for each result. | 85 * for each result. |
| 80 * @param {!Array<!HistoryEntry>} historyResults The new history results. | 86 * @param {!Array<!HistoryEntry>} historyResults The new history results. |
| 81 * @param {string} searchTerm Search query used to find these results. | 87 * @param {string} searchTerm Search query used to find these results. |
| 82 */ | 88 */ |
| 83 addNewResults: function(historyResults, searchTerm) { | 89 addNewResults: function(historyResults, searchTerm) { |
| 84 this.loading_ = false; | 90 this.loading_ = false; |
| 91 this.searching_ = false; | |
| 85 | 92 |
| 86 if (this.searchTerm != searchTerm) { | 93 if (this.searchTerm != searchTerm) { |
| 87 if (this.historyData) | 94 if (this.historyData) |
| 88 this.splice('historyData', 0, this.historyData.length); | 95 this.splice('historyData', 0, this.historyData.length); |
| 89 this.searchTerm = searchTerm; | 96 this.searchTerm = searchTerm; |
| 90 } | 97 } |
| 91 | 98 |
| 92 if (historyResults.length == 0) | 99 if (historyResults.length == 0) |
| 93 return; | 100 return; |
| 94 | 101 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 return historyDataLength > 0; | 286 return historyDataLength > 0; |
| 280 }, | 287 }, |
| 281 | 288 |
| 282 noResultsMessage_: function(searchTerm, isLoading) { | 289 noResultsMessage_: function(searchTerm, isLoading) { |
| 283 if (isLoading) | 290 if (isLoading) |
| 284 return ''; | 291 return ''; |
| 285 var messageId = searchTerm !== '' ? 'noSearchResults' : 'noResults'; | 292 var messageId = searchTerm !== '' ? 'noSearchResults' : 'noResults'; |
| 286 return loadTimeData.getString(messageId); | 293 return loadTimeData.getString(messageId); |
| 287 } | 294 } |
| 288 }); | 295 }); |
| OLD | NEW |