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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2054013002: [MD settings] advanced toggle; add scrollWhenReady (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nits Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-main' displays the selected settings page. 7 * 'settings-main' displays the selected settings page.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-main', 10 is: 'settings-main',
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 showAboutPage_: { 56 showAboutPage_: {
57 type: Boolean, 57 type: Boolean,
58 value: false, 58 value: false,
59 }, 59 },
60 }, 60 },
61 61
62 attached: function() { 62 attached: function() {
63 document.addEventListener('toggle-advanced-page', function(e) { 63 document.addEventListener('toggle-advanced-page', function(e) {
64 this.showAdvancedPage_ = e.detail; 64 this.showAdvancedPage_ = e.detail;
65 this.isAdvancedMenuOpen_ = e.detail; 65 this.isAdvancedMenuOpen_ = e.detail;
66 if (this.showAdvancedPage_) {
67 scrollWhenReady(
68 function() {
69 return this.$$('settings-advanced-page');
70 }.bind(this),
71 function() {
72 return this.$$('#toggleContainer');
73 }.bind(this));
74 }
66 }.bind(this)); 75 }.bind(this));
67 }, 76 },
68 77
69 /** 78 /**
79 * @param {boolean} opened Whether the menu is expanded.
80 * @return {string} Which icon to use.
81 * @private
82 * */
83 arrowState_: function(opened) {
84 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
85 },
86
87 /**
70 * @param {!SettingsRoute} newRoute 88 * @param {!SettingsRoute} newRoute
71 * @private 89 * @private
72 */ 90 */
73 currentRouteChanged_: function(newRoute) { 91 currentRouteChanged_: function(newRoute) {
74 var isSubpage = !!newRoute.subpage.length; 92 var isSubpage = !!newRoute.subpage.length;
75 93
76 this.showAboutPage_ = newRoute.page == 'about'; 94 this.showAboutPage_ = newRoute.page == 'about';
77 95
78 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; 96 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage;
79 97
80 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; 98 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic';
81 99
82 this.showAdvancedPage_ = 100 this.showAdvancedPage_ =
83 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || 101 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) ||
84 newRoute.page == 'advanced'; 102 newRoute.page == 'advanced';
85 103
86 this.$.pageContainer.style.height = isSubpage ? '100%' : ''; 104 this.style.height = isSubpage ? '100%' : '';
87 }, 105 },
88 106
89 /** @private */ 107 /** @private */
90 toggleAdvancedPage_: function() { 108 toggleAdvancedPage_: function() {
91 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); 109 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_);
92 }, 110 },
93 }); 111 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698