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 Polymer({ | 5 Polymer({ |
6 is: 'history-app', | 6 is: 'history-app', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // The id of the currently selected page. | 9 // The id of the currently selected page. |
10 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, | 10 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, |
(...skipping 29 matching lines...) Expand all Loading... |
40 return { | 40 return { |
41 info: null, | 41 info: null, |
42 results: null, | 42 results: null, |
43 sessionList: null, | 43 sessionList: null, |
44 }; | 44 }; |
45 } | 45 } |
46 }, | 46 }, |
47 | 47 |
48 // Route data for the current page. | 48 // Route data for the current page. |
49 routeData_: Object, | 49 routeData_: Object, |
| 50 |
| 51 // The query params for the page. |
| 52 queryParams_: Object, |
50 }, | 53 }, |
51 | 54 |
52 observers: [ | 55 observers: [ |
53 // routeData_.page <=> selectedPage | 56 // routeData_.page <=> selectedPage |
54 'routeDataChanged_(routeData_.page)', | 57 'routeDataChanged_(routeData_.page)', |
55 'selectedPageChanged_(selectedPage_)', | 58 'selectedPageChanged_(selectedPage_)', |
| 59 |
| 60 // queryParams_.q <=> queryState.searchTerm |
| 61 'searchTermChanged_(queryState_.searchTerm)', |
| 62 'searchQueryParamChanged_(queryParams_.q)', |
| 63 |
56 ], | 64 ], |
57 | 65 |
58 // TODO(calamity): Replace these event listeners with data bound properties. | 66 // TODO(calamity): Replace these event listeners with data bound properties. |
59 listeners: { | 67 listeners: { |
60 'cr-menu-tap': 'onMenuTap_', | 68 'cr-menu-tap': 'onMenuTap_', |
61 'history-checkbox-select': 'checkboxSelected', | 69 'history-checkbox-select': 'checkboxSelected', |
62 'unselect-all': 'unselectAll', | 70 'unselect-all': 'unselectAll', |
63 'delete-selected': 'deleteSelected', | 71 'delete-selected': 'deleteSelected', |
64 'search-domain': 'searchDomain_', | 72 'search-domain': 'searchDomain_', |
65 }, | 73 }, |
66 | 74 |
67 /** @override */ | 75 /** @override */ |
68 ready: function() { | 76 ready: function() { |
69 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 77 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
70 | 78 |
71 cr.ui.decorate('command', cr.ui.Command); | 79 cr.ui.decorate('command', cr.ui.Command); |
72 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 80 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
73 document.addEventListener('command', this.onCommand_.bind(this)); | 81 document.addEventListener('command', this.onCommand_.bind(this)); |
| 82 |
| 83 // Redirect legacy search URLs to URLs compatible with material history. |
| 84 if (window.location.hash) { |
| 85 window.location.href = window.location.href.split('#')[0] + '?' + |
| 86 window.location.hash.substr(1); |
| 87 } |
74 }, | 88 }, |
75 | 89 |
76 /** @private */ | 90 /** @private */ |
77 onMenuTap_: function() { this.$['side-bar'].toggle(); }, | 91 onMenuTap_: function() { this.$['side-bar'].toggle(); }, |
78 | 92 |
79 /** | 93 /** |
80 * Listens for history-item being selected or deselected (through checkbox) | 94 * Listens for history-item being selected or deselected (through checkbox) |
81 * and changes the view of the top toolbar. | 95 * and changes the view of the top toolbar. |
82 * @param {{detail: {countAddition: number}}} e | 96 * @param {{detail: {countAddition: number}}} e |
83 */ | 97 */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 146 |
133 /** | 147 /** |
134 * @param {Event} e | 148 * @param {Event} e |
135 * @private | 149 * @private |
136 */ | 150 */ |
137 onCanExecute_: function(e) { | 151 onCanExecute_: function(e) { |
138 e.canExecute = true; | 152 e.canExecute = true; |
139 }, | 153 }, |
140 | 154 |
141 /** | 155 /** |
| 156 * @param {string} searchTerm |
| 157 * @private |
| 158 */ |
| 159 searchTermChanged_: function(searchTerm) { |
| 160 this.set('queryParams_.q', searchTerm || null); |
| 161 this.$['history'].queryHistory(false); |
| 162 }, |
| 163 |
| 164 /** |
| 165 * @param {string} searchQuery |
| 166 * @private |
| 167 */ |
| 168 searchQueryParamChanged_: function(searchQuery) { |
| 169 this.$.toolbar.setSearchTerm(searchQuery || ''); |
| 170 }, |
| 171 |
| 172 /** |
142 * @param {Event} e | 173 * @param {Event} e |
143 * @private | 174 * @private |
144 */ | 175 */ |
145 onCommand_: function(e) { | 176 onCommand_: function(e) { |
146 if (e.command.id == 'find-command') | 177 if (e.command.id == 'find-command') |
147 this.$.toolbar.showSearchField(); | 178 this.$.toolbar.showSearchField(); |
148 }, | 179 }, |
149 | 180 |
150 /** | 181 /** |
151 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 182 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 * added as a child of iron-pages. | 245 * added as a child of iron-pages. |
215 * @param {string} selectedPage | 246 * @param {string} selectedPage |
216 * @param {Array} items | 247 * @param {Array} items |
217 * @return {string} | 248 * @return {string} |
218 * @private | 249 * @private |
219 */ | 250 */ |
220 getSelectedPage_(selectedPage, items) { | 251 getSelectedPage_(selectedPage, items) { |
221 return selectedPage; | 252 return selectedPage; |
222 }, | 253 }, |
223 }); | 254 }); |
OLD | NEW |