OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @typedef {{querying: boolean, | 6 * @typedef {{querying: boolean, |
7 * searchTerm: string, | 7 * searchTerm: string, |
8 * results: ?Array<!HistoryEntry>, | 8 * results: ?Array<!HistoryEntry>, |
9 * info: ?HistoryQuery, | 9 * info: ?HistoryQuery, |
10 * incremental: boolean, | 10 * incremental: boolean, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 // Route data for the current page. | 58 // Route data for the current page. |
59 routeData: Object, | 59 routeData: Object, |
60 }, | 60 }, |
61 | 61 |
62 observers: [ | 62 observers: [ |
63 // routeData.page <=> selectedPage | 63 // routeData.page <=> selectedPage |
64 'routeDataChanged_(routeData.page)', | 64 'routeDataChanged_(routeData.page)', |
65 'selectedPageChanged_(selectedPage_)', | 65 'selectedPageChanged_(selectedPage_)', |
66 | 66 |
67 // route.__queryParams.q <=> queryState.searchTerm | |
67 'searchTermChanged_(queryState_.searchTerm)', | 68 'searchTermChanged_(queryState_.searchTerm)', |
69 'searchQueryParamChanged_(route.__queryParams.q)', | |
tsergeant
2016/06/16 02:00:15
app-route exposes a `queryParams` property. You sh
calamity
2016/06/16 06:49:14
Ugh! So _that's_ where that was. I was so confused
| |
70 | |
68 'groupedRangeChanged_(queryState_.range)', | 71 'groupedRangeChanged_(queryState_.range)', |
69 ], | 72 ], |
70 | 73 |
71 // TODO(calamity): Replace these event listeners with data bound properties. | 74 // TODO(calamity): Replace these event listeners with data bound properties. |
72 listeners: { | 75 listeners: { |
73 'history-checkbox-select': 'checkboxSelected', | 76 'history-checkbox-select': 'checkboxSelected', |
74 'unselect-all': 'unselectAll', | 77 'unselect-all': 'unselectAll', |
75 'delete-selected': 'deleteSelected', | 78 'delete-selected': 'deleteSelected', |
76 'search-domain': 'searchDomain_', | 79 'search-domain': 'searchDomain_', |
77 'load-more-history': 'loadMoreHistory_', | 80 'load-more-history': 'loadMoreHistory_', |
78 }, | 81 }, |
79 | 82 |
80 /** @override */ | 83 /** @override */ |
81 ready: function() { | 84 ready: function() { |
82 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 85 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
86 if (window.location.hash) { | |
87 window.location.href = window.location.href.split('#')[0] + '?' + | |
88 window.location.hash.substr(1); | |
89 } | |
83 }, | 90 }, |
84 | 91 |
85 /** | 92 /** |
86 * Listens for history-item being selected or deselected (through checkbox) | 93 * Listens for history-item being selected or deselected (through checkbox) |
87 * and changes the view of the top toolbar. | 94 * and changes the view of the top toolbar. |
88 * @param {{detail: {countAddition: number}}} e | 95 * @param {{detail: {countAddition: number}}} e |
89 */ | 96 */ |
90 checkboxSelected: function(e) { | 97 checkboxSelected: function(e) { |
91 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 98 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
92 toolbar.count += e.detail.countAddition; | 99 toolbar.count += e.detail.countAddition; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 routeDataChanged_: function(page) { | 177 routeDataChanged_: function(page) { |
171 this.selectedPage_ = page; | 178 this.selectedPage_ = page; |
172 }, | 179 }, |
173 | 180 |
174 selectedPageChanged_: function(selectedPage) { | 181 selectedPageChanged_: function(selectedPage) { |
175 this.set('routeData.page', selectedPage); | 182 this.set('routeData.page', selectedPage); |
176 }, | 183 }, |
177 | 184 |
178 searchTermChanged_: function(searchTerm) { | 185 searchTermChanged_: function(searchTerm) { |
179 this.queryHistory(false); | 186 this.queryHistory(false); |
187 this.set('route.__queryParams.q', searchTerm || null); | |
188 }, | |
189 | |
190 searchQueryParamChanged_: function(searchTerm) { | |
191 this.$.toolbar.setSearchTerm(searchTerm || ''); | |
180 }, | 192 }, |
181 | 193 |
182 groupedRangeChanged_: function(range) { | 194 groupedRangeChanged_: function(range) { |
183 this.set('routeData.page', range == HistoryRange.ALL_TIME ? '' : 'grouped'); | 195 this.set('routeData.page', range == HistoryRange.ALL_TIME ? '' : 'grouped'); |
184 this.queryHistory(false); | 196 this.queryHistory(false); |
185 }, | 197 }, |
186 | 198 |
187 loadMoreHistory_: function() { | 199 loadMoreHistory_: function() { |
188 this.queryHistory(true); | 200 this.queryHistory(true); |
189 }, | 201 }, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 * @param {boolean} incremental | 263 * @param {boolean} incremental |
252 * @param {string} searchTerm | 264 * @param {string} searchTerm |
253 * @return {boolean} Whether a loading spinner should be shown (implies the | 265 * @return {boolean} Whether a loading spinner should be shown (implies the |
254 * backend is querying a new search term). | 266 * backend is querying a new search term). |
255 * @private | 267 * @private |
256 */ | 268 */ |
257 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 269 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
258 return querying && !incremental && searchTerm != ''; | 270 return querying && !incremental && searchTerm != ''; |
259 } | 271 } |
260 }); | 272 }); |
OLD | NEW |