Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/resources/md_history/app.js

Issue 2627383002: MD History: Replace app-drawer with cr-drawer (Closed)
Patch Set: Use correct close function Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 }, 89 },
90 90
91 showMenuPromo_: { 91 showMenuPromo_: {
92 type: Boolean, 92 type: Boolean,
93 value: function() { 93 value: function() {
94 return loadTimeData.getBoolean('showMenuPromo'); 94 return loadTimeData.getBoolean('showMenuPromo');
95 }, 95 },
96 }, 96 },
97 97
98 // True if the window is narrow enough for the page to have a drawer. 98 // True if the window is narrow enough for the page to have a drawer.
99 hasDrawer_: Boolean, 99 hasDrawer_: {
100 type: Boolean,
101 observer: 'hasDrawerChanged_',
102 },
100 103
101 // Used to display notices for profile sign-in status. 104 // Used to display notices for profile sign-in status.
102 showSidebarFooter: Boolean, 105 showSidebarFooter: Boolean,
103 106
104 hasSyncedResults: Boolean, 107 hasSyncedResults: Boolean,
105 }, 108 },
106 109
107 listeners: { 110 listeners: {
108 'cr-toolbar-menu-promo-close': 'onCrToolbarMenuPromoClose_', 111 'cr-toolbar-menu-promo-close': 'onCrToolbarMenuPromoClose_',
109 'cr-toolbar-menu-promo-shown': 'onCrToolbarMenuPromoShown_', 112 'cr-toolbar-menu-promo-shown': 'onCrToolbarMenuPromoShown_',
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 this.showMenuPromo_ = false; 177 this.showMenuPromo_ = false;
175 }, 178 },
176 179
177 /** @private */ 180 /** @private */
178 onCrToolbarMenuPromoShown_: function() { 181 onCrToolbarMenuPromoShown_: function() {
179 md_history.BrowserService.getInstance().menuPromoShown(); 182 md_history.BrowserService.getInstance().menuPromoShown();
180 }, 183 },
181 184
182 /** @private */ 185 /** @private */
183 onCrToolbarMenuTap_: function() { 186 onCrToolbarMenuTap_: function() {
184 var drawer = this.$$('#drawer'); 187 var drawer = /** @type {!CrDrawerElement} */ (this.$.drawer.get());
185 if (drawer) 188 drawer.align = document.documentElement.dir == 'ltr' ? 'left' : 'right';
186 drawer.toggle(); 189 drawer.toggle();
187 }, 190 },
188 191
189 /** 192 /**
190 * @param {!CustomEvent} e 193 * @param {!CustomEvent} e
191 * @private 194 * @private
192 */ 195 */
193 onOpenedChanged_: function(e) { 196 onOpenedChanged_: function(e) {
194 if (e.detail.value) 197 if (e.detail.value)
195 this.showMenuPromo_ = false; 198 this.showMenuPromo_ = false;
196 }, 199 },
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (!this.$.content.selectedItem) 353 if (!this.$.content.selectedItem)
351 return; 354 return;
352 this.scrollTarget = 355 this.scrollTarget =
353 this.$.content.selectedItem.getContentScrollTarget(); 356 this.$.content.selectedItem.getContentScrollTarget();
354 this._scrollHandler(); 357 this._scrollHandler();
355 }.bind(this)); 358 }.bind(this));
356 }.bind(this)); 359 }.bind(this));
357 this.recordHistoryPageView_(); 360 this.recordHistoryPageView_();
358 }, 361 },
359 362
363 /** @private */
364 hasDrawerChanged_: function() {
365 var drawer = /** @type {?CrDrawerElement} */ (this.$.drawer.getIfExists());
366 if (!this.hasDrawer_ && drawer && drawer.open)
367 drawer.closeDrawer();
368 },
369
360 /** 370 /**
361 * This computed binding is needed to make the iron-pages selector update when 371 * This computed binding is needed to make the iron-pages selector update when
362 * the synced-device-manager is instantiated for the first time. Otherwise the 372 * the synced-device-manager is instantiated for the first time. Otherwise the
363 * fallback selection will continue to be used after the corresponding item is 373 * fallback selection will continue to be used after the corresponding item is
364 * added as a child of iron-pages. 374 * added as a child of iron-pages.
365 * @param {string} selectedPage 375 * @param {string} selectedPage
366 * @param {Array} items 376 * @param {Array} items
367 * @return {string} 377 * @return {string}
368 * @private 378 * @private
369 */ 379 */
370 getSelectedPage_: function(selectedPage, items) { 380 getSelectedPage_: function(selectedPage, items) {
371 return selectedPage; 381 return selectedPage;
372 }, 382 },
373 383
374 /** @private */ 384 /** @private */
375 closeDrawer_: function() { 385 closeDrawer_: function() {
376 var drawer = this.$$('#drawer'); 386 var drawer = this.$.drawer.get();
377 if (drawer) 387 if (drawer && drawer.open)
378 drawer.close(); 388 drawer.closeDrawer();
379 }, 389 },
380 390
381 /** @private */ 391 /** @private */
382 recordHistoryPageView_: function() { 392 recordHistoryPageView_: function() {
383 var histogramValue = HistoryPageViewHistogram.END; 393 var histogramValue = HistoryPageViewHistogram.END;
384 switch (this.selectedPage_) { 394 switch (this.selectedPage_) {
385 case 'syncedTabs': 395 case 'syncedTabs':
386 histogramValue = this.isUserSignedIn_ ? 396 histogramValue = this.isUserSignedIn_ ?
387 HistoryPageViewHistogram.SYNCED_TABS : 397 HistoryPageViewHistogram.SYNCED_TABS :
388 HistoryPageViewHistogram.SIGNIN_PROMO; 398 HistoryPageViewHistogram.SIGNIN_PROMO;
(...skipping 11 matching lines...) Expand all
400 break; 410 break;
401 } 411 }
402 break; 412 break;
403 } 413 }
404 414
405 md_history.BrowserService.getInstance().recordHistogram( 415 md_history.BrowserService.getInstance().recordHistogram(
406 'History.HistoryPageView', histogramValue, 416 'History.HistoryPageView', histogramValue,
407 HistoryPageViewHistogram.END); 417 HistoryPageViewHistogram.END);
408 }, 418 },
409 }); 419 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/app.html ('k') | chrome/browser/resources/md_history/app.crisper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698