Chromium Code Reviews| 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 if (window.location.hash) { | |
|
tsergeant
2016/07/19 03:32:20
Should have a comment here explaining this.
calamity
2016/07/19 04:35:33
Done.
| |
| 84 window.location.href = window.location.href.split('#')[0] + '?' + | |
| 85 window.location.hash.substr(1); | |
| 86 } | |
| 74 }, | 87 }, |
| 75 | 88 |
| 76 /** @private */ | 89 /** @private */ |
| 77 onMenuTap_: function() { this.$['side-bar'].toggle(); }, | 90 onMenuTap_: function() { this.$['side-bar'].toggle(); }, |
| 78 | 91 |
| 79 /** | 92 /** |
| 80 * Listens for history-item being selected or deselected (through checkbox) | 93 * Listens for history-item being selected or deselected (through checkbox) |
| 81 * and changes the view of the top toolbar. | 94 * and changes the view of the top toolbar. |
| 82 * @param {{detail: {countAddition: number}}} e | 95 * @param {{detail: {countAddition: number}}} e |
| 83 */ | 96 */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 * @param {{detail: {domain: string}}} e | 135 * @param {{detail: {domain: string}}} e |
| 123 */ | 136 */ |
| 124 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, | 137 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
| 125 | 138 |
| 126 /** | 139 /** |
| 127 * @param {Event} e | 140 * @param {Event} e |
| 128 * @private | 141 * @private |
| 129 */ | 142 */ |
| 130 onCanExecute_: function(e) { | 143 onCanExecute_: function(e) { |
| 131 e.canExecute = true; | 144 e.canExecute = true; |
| 145 | |
|
tsergeant
2016/07/19 03:32:20
Nit: Undo this
calamity
2016/07/19 04:35:33
Done.
| |
| 132 }, | 146 }, |
| 133 | 147 |
| 134 /** | 148 /** |
| 149 * @param {string} searchTerm | |
| 150 * @private | |
| 151 */ | |
| 152 searchTermChanged_: function(searchTerm) { | |
| 153 this.set('queryParams_.q', searchTerm || null); | |
| 154 this.$['history'].queryHistory(false); | |
| 155 }, | |
| 156 | |
| 157 /** | |
| 158 * @param {string} searchQuery | |
| 159 * @private | |
| 160 */ | |
| 161 searchQueryParamChanged_: function(searchQuery) { | |
| 162 this.$.toolbar.setSearchTerm(searchQuery || ''); | |
| 163 }, | |
| 164 | |
| 165 /** | |
| 135 * @param {Event} e | 166 * @param {Event} e |
| 136 * @private | 167 * @private |
| 137 */ | 168 */ |
| 138 onCommand_: function(e) { | 169 onCommand_: function(e) { |
| 139 if (e.command.id == 'find-command') | 170 if (e.command.id == 'find-command') |
| 140 this.$.toolbar.showSearchField(); | 171 this.$.toolbar.showSearchField(); |
| 141 }, | 172 }, |
| 142 | 173 |
| 143 /** | 174 /** |
| 144 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 175 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 * added as a child of iron-pages. | 238 * added as a child of iron-pages. |
| 208 * @param {string} selectedPage | 239 * @param {string} selectedPage |
| 209 * @param {Array} items | 240 * @param {Array} items |
| 210 * @return {string} | 241 * @return {string} |
| 211 * @private | 242 * @private |
| 212 */ | 243 */ |
| 213 getSelectedPage_(selectedPage, items) { | 244 getSelectedPage_(selectedPage, items) { |
| 214 return selectedPage; | 245 return selectedPage; |
| 215 }, | 246 }, |
| 216 }); | 247 }); |
| OLD | NEW |