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

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

Issue 2210933004: Settings Router Refactor: Kill settings-router. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge yet again because this conflicts with everything Created 4 years, 4 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',
11 11
12 behaviors: [settings.RouteObserverBehavior],
13
12 properties: { 14 properties: {
13 /** 15 /**
14 * Preferences state. 16 * Preferences state.
15 */ 17 */
16 prefs: { 18 prefs: {
17 type: Object, 19 type: Object,
18 notify: true, 20 notify: true,
19 }, 21 },
20 22
21 /**
22 * The current active route.
23 * @type {!settings.Route}
24 */
25 currentRoute: {
26 type: Object,
27 notify: true,
28 observer: 'currentRouteChanged_',
29 },
30
31 /** @private */ 23 /** @private */
32 advancedToggleExpanded_: { 24 advancedToggleExpanded_: {
33 type: Boolean, 25 type: Boolean,
34 value: false, 26 value: false,
35 }, 27 },
36 28
37 /** @private */ 29 /** @private */
38 inSubpage_: Boolean, 30 inSubpage_: Boolean,
39 31
40 /** @private */ 32 /** @private */
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 /** 114 /**
123 * @param {boolean} showBasicPage 115 * @param {boolean} showBasicPage
124 * @param {boolean} inSubpage 116 * @param {boolean} inSubpage
125 * @return {boolean} 117 * @return {boolean}
126 * @private 118 * @private
127 */ 119 */
128 showAdvancedToggle_: function(showBasicPage, inSubpage) { 120 showAdvancedToggle_: function(showBasicPage, inSubpage) {
129 return showBasicPage && !inSubpage; 121 return showBasicPage && !inSubpage;
130 }, 122 },
131 123
132 /** 124 /** @protected */
133 * @private 125 currentRouteChanged: function(newRoute) {
134 */
135 currentRouteChanged_: function(newRoute) {
136 this.inSubpage_ = newRoute.subpage.length > 0; 126 this.inSubpage_ = newRoute.subpage.length > 0;
137 this.style.height = this.inSubpage_ ? '100%' : ''; 127 this.style.height = this.inSubpage_ ? '100%' : '';
138 128
139 if (settings.Route.ABOUT.contains(newRoute)) { 129 if (settings.Route.ABOUT.contains(newRoute)) {
140 this.showPages_ = {about: true, basic: false, advanced: false}; 130 this.showPages_ = {about: true, basic: false, advanced: false};
141 } else { 131 } else {
142 this.showPages_ = { 132 this.showPages_ = {
143 about: false, 133 about: false,
144 basic: settings.Route.BASIC.contains(newRoute) || !this.inSubpage_, 134 basic: settings.Route.BASIC.contains(newRoute) || !this.inSubpage_,
145 advanced: settings.Route.ADVANCED.contains(newRoute) || 135 advanced: settings.Route.ADVANCED.contains(newRoute) ||
(...skipping 18 matching lines...) Expand all
164 154
165 /** 155 /**
166 * Return the height that the overscroll padding should be set to. 156 * Return the height that the overscroll padding should be set to.
167 * This is used to determine how much padding to apply to the end of the 157 * This is used to determine how much padding to apply to the end of the
168 * content so that the last element may align with the top of the content 158 * content so that the last element may align with the top of the content
169 * area. 159 * area.
170 * @return {number} 160 * @return {number}
171 * @private 161 * @private
172 */ 162 */
173 overscrollHeight_: function() { 163 overscrollHeight_: function() {
174 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || 164 var route = settings.getCurrentRoute();
Dan Beam 2016/08/05 18:25:19 can |route| be falsy?
tommycli 2016/08/05 18:54:06 Done.
175 this.showPages_.about) { 165 if (!route || route.subpage.length != 0 || this.showPages_.about)
176 return 0; 166 return 0;
177 }
178 167
179 var query = 'settings-section[section="' + this.currentRoute.section + '"]'; 168 var query = 'settings-section[section="' + route.section + '"]';
180 var topSection = this.$$('settings-basic-page').$$(query); 169 var topSection = this.$$('settings-basic-page').$$(query);
181 if (!topSection && this.showPages_.advanced) 170 if (!topSection && this.showPages_.advanced)
182 topSection = this.$$('settings-advanced-page').$$(query); 171 topSection = this.$$('settings-advanced-page').$$(query);
183 172
184 if (!topSection || !topSection.offsetParent) 173 if (!topSection || !topSection.offsetParent)
185 return 0; 174 return 0;
186 175
187 // Offset to the selected section (relative to the scrolling window). 176 // Offset to the selected section (relative to the scrolling window).
188 let sectionTop = topSection.offsetParent.offsetTop + topSection.offsetTop; 177 let sectionTop = topSection.offsetParent.offsetTop + topSection.offsetTop;
189 // The height of the selected section and remaining content (sections). 178 // The height of the selected section and remaining content (sections).
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 232
244 /** 233 /**
245 * @param {(boolean|undefined)} visibility 234 * @param {(boolean|undefined)} visibility
246 * @return {boolean} True unless visibility is false. 235 * @return {boolean} True unless visibility is false.
247 * @private 236 * @private
248 */ 237 */
249 showAdvancedSettings_: function(visibility) { 238 showAdvancedSettings_: function(visibility) {
250 return visibility !== false; 239 return visibility !== false;
251 }, 240 },
252 }); 241 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698