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 26 matching lines...) Expand all Loading... |
37 queryResult_: { | 37 queryResult_: { |
38 type: Object, | 38 type: Object, |
39 value: function() { | 39 value: function() { |
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 |
| 48 // Route data for the current page. |
| 49 routeData_: Object, |
47 }, | 50 }, |
48 | 51 |
| 52 observers: [ |
| 53 // routeData_.page <=> selectedPage |
| 54 'routeDataChanged_(routeData_.page)', |
| 55 'selectedPageChanged_(selectedPage_)', |
| 56 ], |
| 57 |
| 58 // TODO(calamity): Replace these event listeners with data bound properties. |
49 listeners: { | 59 listeners: { |
50 'cr-menu-tap': 'onMenuTap_', | 60 'cr-menu-tap': 'onMenuTap_', |
51 'history-checkbox-select': 'checkboxSelected', | 61 'history-checkbox-select': 'checkboxSelected', |
52 'unselect-all': 'unselectAll', | 62 'unselect-all': 'unselectAll', |
53 'delete-selected': 'deleteSelected', | 63 'delete-selected': 'deleteSelected', |
54 'search-domain': 'searchDomain_', | 64 'search-domain': 'searchDomain_', |
55 }, | 65 }, |
56 | 66 |
57 /** @override */ | 67 /** @override */ |
58 ready: function() { | 68 ready: function() { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 .$$('history-synced-device-manager'); | 169 .$$('history-synced-device-manager'); |
160 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | 170 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); |
161 }, | 171 }, |
162 | 172 |
163 /** | 173 /** |
164 * @param {string} selectedPage | 174 * @param {string} selectedPage |
165 * @return {boolean} | 175 * @return {boolean} |
166 * @private | 176 * @private |
167 */ | 177 */ |
168 syncedTabsSelected_: function(selectedPage) { | 178 syncedTabsSelected_: function(selectedPage) { |
169 return selectedPage == 'synced-devices'; | 179 return selectedPage == 'syncedTabs'; |
170 }, | 180 }, |
171 | 181 |
172 /** | 182 /** |
173 * @param {boolean} querying | 183 * @param {boolean} querying |
174 * @param {boolean} incremental | 184 * @param {boolean} incremental |
175 * @param {string} searchTerm | 185 * @param {string} searchTerm |
176 * @return {boolean} Whether a loading spinner should be shown (implies the | 186 * @return {boolean} Whether a loading spinner should be shown (implies the |
177 * backend is querying a new search term). | 187 * backend is querying a new search term). |
178 * @private | 188 * @private |
179 */ | 189 */ |
180 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 190 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
181 return querying && !incremental && searchTerm != ''; | 191 return querying && !incremental && searchTerm != ''; |
182 }, | 192 }, |
| 193 |
| 194 /** |
| 195 * @param {string} page |
| 196 * @private |
| 197 */ |
| 198 routeDataChanged_: function(page) { |
| 199 this.selectedPage_ = page; |
| 200 }, |
| 201 |
| 202 /** |
| 203 * @param {string} selectedPage |
| 204 * @private |
| 205 */ |
| 206 selectedPageChanged_: function(selectedPage) { |
| 207 this.set('routeData_.page', selectedPage); |
| 208 }, |
| 209 |
| 210 /** |
| 211 * This computed binding is needed to make the iron-pages selector update when |
| 212 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 213 * fallback selection will continue to be used after the corresponding item is |
| 214 * added as a child of iron-pages. |
| 215 * @param {string} selectedPage |
| 216 * @param {Array} items |
| 217 * @return {string} |
| 218 * @private |
| 219 */ |
| 220 getSelectedPage_(selectedPage, items) { |
| 221 return selectedPage; |
| 222 }, |
183 }); | 223 }); |
OLD | NEW |