| 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: { | 10 selectedPage: { |
| 11 type: String, | 11 type: String, |
| 12 value: 'history-list' | 12 value: 'history-list' |
| 13 }, |
| 14 route: { |
| 15 type: Object |
| 16 }, |
| 17 routeData: { |
| 18 type: Object, |
| 19 observer: 'routeChanged_' |
| 13 } | 20 } |
| 14 }, | 21 }, |
| 15 | 22 |
| 16 // TODO(calamity): Replace these event listeners with data bound properties. | 23 // TODO(calamity): Replace these event listeners with data bound properties. |
| 17 listeners: { | 24 listeners: { |
| 18 'history-checkbox-select': 'checkboxSelected', | 25 'history-checkbox-select': 'checkboxSelected', |
| 19 'unselect-all': 'unselectAll', | 26 'unselect-all': 'unselectAll', |
| 20 'delete-selected': 'deleteSelected', | 27 'delete-selected': 'deleteSelected', |
| 21 'search-changed': 'searchChanged', | 28 'search-changed': 'searchChanged', |
| 22 }, | 29 }, |
| 23 | 30 |
| 31 routeChanged_: function() { |
| 32 console.log(this.routeData.page); |
| 33 var routeToElementId = { |
| 34 'openTabs': 'history-synced-device-manager', |
| 35 }; |
| 36 var path = this.routeData.page; |
| 37 var elementId = |
| 38 routeToElementId[path] ? routeToElementId[path] : 'history-list'; |
| 39 this.$['content'].selected = elementId; |
| 40 }, |
| 41 |
| 24 /** | 42 /** |
| 25 * Listens for history-item being selected or deselected (through checkbox) | 43 * Listens for history-item being selected or deselected (through checkbox) |
| 26 * and changes the view of the top toolbar. | 44 * and changes the view of the top toolbar. |
| 27 * @param {{detail: {countAddition: number}}} e | 45 * @param {{detail: {countAddition: number}}} e |
| 28 */ | 46 */ |
| 29 checkboxSelected: function(e) { | 47 checkboxSelected: function(e) { |
| 30 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 48 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
| 31 toolbar.count += e.detail.countAddition; | 49 toolbar.count += e.detail.countAddition; |
| 32 }, | 50 }, |
| 33 | 51 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 }, | 105 }, |
| 88 | 106 |
| 89 /** | 107 /** |
| 90 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 108 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
| 91 * the sessions from other devices. | 109 * the sessions from other devices. |
| 92 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | 110 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
| 93 */ | 111 */ |
| 94 setForeignSessions: function(sessionList, isTabSyncEnabled) { | 112 setForeignSessions: function(sessionList, isTabSyncEnabled) { |
| 95 // TODO(calamity): Add a 'no synced devices' message when sessions are | 113 // TODO(calamity): Add a 'no synced devices' message when sessions are |
| 96 // empty. | 114 // empty. |
| 97 this.$['history-side-bar'].hidden = !isTabSyncEnabled; | |
| 98 var syncedDeviceElem = this.$['history-synced-device-manager']; | 115 var syncedDeviceElem = this.$['history-synced-device-manager']; |
| 99 var syncedDeviceManager = | 116 var syncedDeviceManager = |
| 100 /** @type {HistorySyncedDeviceManagerElement} */(syncedDeviceElem); | 117 /** @type {HistorySyncedDeviceManagerElement} */(syncedDeviceElem); |
| 101 if (isTabSyncEnabled) { | 118 if (isTabSyncEnabled) { |
| 102 syncedDeviceManager.setSyncedHistory(sessionList); | 119 syncedDeviceManager.setSyncedHistory(sessionList); |
| 103 /** @type {HistoryToolbarElement} */(this.$.toolbar).hasSidebar = true; | 120 /** @type {HistoryToolbarElement} */(this.$.toolbar).hasSidebar = true; |
| 104 } | 121 } |
| 105 }, | 122 }, |
| 106 | 123 |
| 107 deleteComplete: function() { | 124 deleteComplete: function() { |
| 108 var historyList = /** @type {HistoryListElement} */(this.$['history-list']); | 125 var historyList = /** @type {HistoryListElement} */(this.$['history-list']); |
| 109 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 126 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
| 110 historyList.removeDeletedHistory(toolbar.count); | 127 historyList.removeDeletedHistory(toolbar.count); |
| 111 toolbar.count = 0; | 128 toolbar.count = 0; |
| 112 } | 129 } |
| 113 }); | 130 }); |
| OLD | NEW |