| 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 cr.define('md_history', function() { | 5 cr.define('md_history', function() { |
| 6 var lazyLoadPromise = null; | 6 var lazyLoadPromise = null; |
| 7 function ensureLazyLoaded() { | 7 function ensureLazyLoaded() { |
| 8 if (!lazyLoadPromise) { | 8 if (!lazyLoadPromise) { |
| 9 lazyLoadPromise = new Promise(function(resolve, reject) { | 9 lazyLoadPromise = new Promise(function(resolve, reject) { |
| 10 Polymer.Base.importHref( | 10 Polymer.Base.importHref( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 type: Boolean, | 79 type: Boolean, |
| 80 // Updated on synced-device-manager attach by chrome.sending | 80 // Updated on synced-device-manager attach by chrome.sending |
| 81 // 'otherDevicesInitialized'. | 81 // 'otherDevicesInitialized'. |
| 82 value: loadTimeData.getBoolean('isUserSignedIn'), | 82 value: loadTimeData.getBoolean('isUserSignedIn'), |
| 83 }, | 83 }, |
| 84 | 84 |
| 85 toolbarShadow_: { | 85 toolbarShadow_: { |
| 86 type: Boolean, | 86 type: Boolean, |
| 87 reflectToAttribute: true, | 87 reflectToAttribute: true, |
| 88 notify: true, | 88 notify: true, |
| 89 } | 89 }, |
| 90 |
| 91 showMenuPromo_: { |
| 92 type: Boolean, |
| 93 value: function() { |
| 94 return loadTimeData.getBoolean('showMenuPromo'); |
| 95 }, |
| 96 }, |
| 90 }, | 97 }, |
| 91 | 98 |
| 92 // TODO(calamity): Replace these event listeners with data bound properties. | |
| 93 listeners: { | 99 listeners: { |
| 94 'cr-menu-tap': 'onMenuTap_', | 100 'cr-toolbar-menu-promo-close': 'onCrToolbarMenuPromoClose_', |
| 101 'cr-toolbar-menu-promo-shown': 'onCrToolbarMenuPromoShown_', |
| 102 'cr-toolbar-menu-tap': 'onCrToolbarMenuTap_', |
| 103 'delete-selected': 'deleteSelected', |
| 95 'history-checkbox-select': 'checkboxSelected', | 104 'history-checkbox-select': 'checkboxSelected', |
| 96 'unselect-all': 'unselectAll', | |
| 97 'delete-selected': 'deleteSelected', | |
| 98 'history-close-drawer': 'closeDrawer_', | 105 'history-close-drawer': 'closeDrawer_', |
| 99 'history-view-changed': 'historyViewChanged_', | 106 'history-view-changed': 'historyViewChanged_', |
| 107 'opened-changed': 'onOpenedChanged_', |
| 108 'unselect-all': 'unselectAll', |
| 100 }, | 109 }, |
| 101 | 110 |
| 102 /** @override */ | 111 /** @override */ |
| 103 ready: function() { | 112 ready: function() { |
| 104 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 113 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 105 | 114 |
| 106 cr.ui.decorate('command', cr.ui.Command); | 115 cr.ui.decorate('command', cr.ui.Command); |
| 107 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 116 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 108 document.addEventListener('command', this.onCommand_.bind(this)); | 117 document.addEventListener('command', this.onCommand_.bind(this)); |
| 109 }, | 118 }, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 md_history.ensureLazyLoaded(); | 142 md_history.ensureLazyLoaded(); |
| 134 }, | 143 }, |
| 135 | 144 |
| 136 /** Overridden from IronScrollTargetBehavior */ | 145 /** Overridden from IronScrollTargetBehavior */ |
| 137 _scrollHandler: function() { | 146 _scrollHandler: function() { |
| 138 if (this.scrollTarget) | 147 if (this.scrollTarget) |
| 139 this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; | 148 this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; |
| 140 }, | 149 }, |
| 141 | 150 |
| 142 /** @private */ | 151 /** @private */ |
| 143 onMenuTap_: function() { | 152 onCrToolbarMenuPromoClose_: function() { |
| 153 this.showMenuPromo_ = false; |
| 154 }, |
| 155 |
| 156 /** @private */ |
| 157 onCrToolbarMenuPromoShown_: function() { |
| 158 md_history.BrowserService.getInstance().menuPromoShown(); |
| 159 }, |
| 160 |
| 161 /** @private */ |
| 162 onCrToolbarMenuTap_: function() { |
| 144 var drawer = this.$$('#drawer'); | 163 var drawer = this.$$('#drawer'); |
| 145 if (drawer) | 164 if (drawer) |
| 146 drawer.toggle(); | 165 drawer.toggle(); |
| 147 }, | 166 }, |
| 148 | 167 |
| 149 /** | 168 /** |
| 169 * @param {!CustomEvent} e |
| 170 * @private |
| 171 */ |
| 172 onOpenedChanged_: function(e) { |
| 173 if (e.detail.value) |
| 174 this.showMenuPromo_ = false; |
| 175 }, |
| 176 |
| 177 /** |
| 150 * Listens for history-item being selected or deselected (through checkbox) | 178 * Listens for history-item being selected or deselected (through checkbox) |
| 151 * and changes the view of the top toolbar. | 179 * and changes the view of the top toolbar. |
| 152 * @param {{detail: {countAddition: number}}} e | 180 * @param {{detail: {countAddition: number}}} e |
| 153 */ | 181 */ |
| 154 checkboxSelected: function(e) { | 182 checkboxSelected: function(e) { |
| 155 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); | 183 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); |
| 156 toolbar.count = /** @type {HistoryListContainerElement} */ (this.$.history) | 184 toolbar.count = /** @type {HistoryListContainerElement} */ (this.$.history) |
| 157 .getSelectedItemCount(); | 185 .getSelectedItemCount(); |
| 158 }, | 186 }, |
| 159 | 187 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 break; | 378 break; |
| 351 } | 379 } |
| 352 break; | 380 break; |
| 353 } | 381 } |
| 354 | 382 |
| 355 md_history.BrowserService.getInstance().recordHistogram( | 383 md_history.BrowserService.getInstance().recordHistogram( |
| 356 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END | 384 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END |
| 357 ); | 385 ); |
| 358 }, | 386 }, |
| 359 }); | 387 }); |
| OLD | NEW |