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

Side by Side Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2210933004: Settings Router Refactor: Kill settings-router. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge 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 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 /** 5 /**
6 * Calls |readyTest| repeatedly until it returns true, then calls 6 * Calls |readyTest| repeatedly until it returns true, then calls
7 * |readyCallback|. 7 * |readyCallback|.
8 * @param {function():boolean} readyTest 8 * @param {function():boolean} readyTest
9 * @param {!Function} readyCallback 9 * @param {!Function} readyCallback
10 */ 10 */
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 TransitionBehavior, 236 TransitionBehavior,
237 MainPageBehaviorImpl 237 MainPageBehaviorImpl
238 ]; 238 ];
239 239
240 240
241 /** 241 /**
242 * TODO(michaelpg): integrate slide animations. 242 * TODO(michaelpg): integrate slide animations.
243 * @polymerBehavior RoutableBehavior 243 * @polymerBehavior RoutableBehavior
244 */ 244 */
245 var RoutableBehaviorImpl = { 245 var RoutableBehaviorImpl = {
246 properties: {
247 /** Contains the current route. */
248 currentRoute: {
249 type: Object,
250 notify: true,
251 observer: 'currentRouteChanged_',
252 },
253 },
254
255 /** @private */ 246 /** @private */
256 scrollToSection_: function() { 247 scrollToSection_: function() {
257 doWhenReady( 248 doWhenReady(
258 function() { 249 function() {
259 return this.scrollHeight > 0; 250 return this.scrollHeight > 0;
260 }.bind(this), 251 }.bind(this),
261 function() { 252 function() {
262 // If the current section changes while we are waiting for the page to 253 // If the current section changes while we are waiting for the page to
263 // be ready, scroll to the newest requested section. 254 // be ready, scroll to the newest requested section.
264 this.getSection_(this.currentRoute.section).scrollIntoView(); 255 this.getSection_(settings.getCurrentRoute().section).scrollIntoView();
265 }.bind(this)); 256 }.bind(this));
266 }, 257 },
267 258
268 /** @private */ 259 /** @private */
269 currentRouteChanged_: function(newRoute, oldRoute) { 260 currentRouteChanged: function(newRoute, oldRoute) {
270 var newRouteIsSubpage = newRoute && newRoute.subpage.length; 261 var newRouteIsSubpage = newRoute && newRoute.subpage.length;
271 var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length; 262 var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length;
272 263
273 if (!oldRoute && newRouteIsSubpage) { 264 if (!oldRoute && newRouteIsSubpage) {
274 // Allow the page to load before expanding the section. TODO(michaelpg): 265 // Allow the page to load before expanding the section. TODO(michaelpg):
275 // Time this better when refactoring settings-animated-pages. 266 // Time this better when refactoring settings-animated-pages.
276 setTimeout(function() { 267 setTimeout(function() {
277 var section = this.getSection_(newRoute.section); 268 var section = this.getSection_(newRoute.section);
278 if (section) 269 if (section)
279 this.expandSection(section); 270 this.expandSection(section);
(...skipping 29 matching lines...) Expand all
309 getSection_: function(section) { 300 getSection_: function(section) {
310 return /** @type {?SettingsSectionElement} */( 301 return /** @type {?SettingsSectionElement} */(
311 this.$$('[section=' + section + ']')); 302 this.$$('[section=' + section + ']'));
312 }, 303 },
313 }; 304 };
314 305
315 306
316 /** @polymerBehavior */ 307 /** @polymerBehavior */
317 var RoutableBehavior = [ 308 var RoutableBehavior = [
318 MainPageBehavior, 309 MainPageBehavior,
310 settings.RouteObserverBehavior,
319 RoutableBehaviorImpl 311 RoutableBehaviorImpl
320 ]; 312 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698