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

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

Issue 2130613002: [MD settings] scroll to sections from subpages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit change Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Fast out, slow in. 5 // Fast out, slow in.
6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; 6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)';
7 var EXPAND_DURATION = 350; 7 var EXPAND_DURATION = 350;
8 8
9 /** 9 /**
10 * Calls |readyTest| repeatedly until it returns true, then calls 10 * Calls |readyTest| repeatedly until it returns true, then calls
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Allow the page to load before expanding the section. TODO(michaelpg): 387 // Allow the page to load before expanding the section. TODO(michaelpg):
388 // Time this better when refactoring settings-animated-pages. 388 // Time this better when refactoring settings-animated-pages.
389 setTimeout(function() { 389 setTimeout(function() {
390 var section = this.getSection_(newRoute.section); 390 var section = this.getSection_(newRoute.section);
391 if (section) 391 if (section)
392 this.expandSection(section); 392 this.expandSection(section);
393 }.bind(this)); 393 }.bind(this));
394 return; 394 return;
395 } 395 }
396 396
397 if (!newRouteIsSubpage && oldRouteIsSubpage) { 397 if (newRouteIsSubpage) {
398 var section = this.getSection_(oldRoute.section); 398 if (!oldRouteIsSubpage || newRoute.section != oldRoute.section) {
399 if (section) 399 var section = this.getSection_(newRoute.section);
400 this.collapseSection(section); 400 if (section)
michaelpg 2016/07/20 19:45:05 when does this fail? seems like something the rout
dschuyler 2016/07/20 20:20:42 This code was simply moved in this CL, so I don't
401 } else if (newRouteIsSubpage && 401 this.expandSection(section);
402 (!oldRouteIsSubpage || newRoute.section != oldRoute.section)) { 402 }
403 var section = this.getSection_(newRoute.section); 403 } else {
404 if (section) 404 if (oldRouteIsSubpage) {
405 this.expandSection(section); 405 var section = this.getSection_(oldRoute.section);
406 } else if (newRoute && newRoute.section && 406 if (section)
407 this.$$('[data-page=' + newRoute.page + ']')) { 407 this.collapseSection(section);
408 this.scrollToSection_(); 408 }
409
410 if (newRoute && newRoute.section &&
411 this.$$('[data-page=' + newRoute.page + ']')) {
412 this.scrollToSection_();
413 }
409 } 414 }
410 }, 415 },
411 416
412 /** 417 /**
413 * Helper function to get a section from the local DOM. 418 * Helper function to get a section from the local DOM.
414 * @param {string} section Section name of the element to get. 419 * @param {string} section Section name of the element to get.
415 * @return {?SettingsSectionElement} 420 * @return {?SettingsSectionElement}
416 * @private 421 * @private
417 */ 422 */
418 getSection_: function(section) { 423 getSection_: function(section) {
419 return /** @type {?SettingsSectionElement} */( 424 return /** @type {?SettingsSectionElement} */(
420 this.$$('[section=' + section + ']')); 425 this.$$('[section=' + section + ']'));
421 }, 426 },
422 }; 427 };
423 428
424 429
425 /** @polymerBehavior */ 430 /** @polymerBehavior */
426 var RoutableBehavior = [ 431 var RoutableBehavior = [
427 MainPageBehavior, 432 MainPageBehavior,
428 RoutableBehaviorImpl 433 RoutableBehaviorImpl
429 ]; 434 ];
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698