Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * Responds to route changes by expanding, collapsing, or scrolling to sections | 6 * Responds to route changes by expanding, collapsing, or scrolling to sections |
| 7 * on the page. Expanded sections take up the full height of the container. At | 7 * on the page. Expanded sections take up the full height of the container. At |
| 8 * most one section should be expanded at any given time. | 8 * most one section should be expanded at any given time. |
| 9 * @polymerBehavior MainPageBehavior | 9 * @polymerBehavior MainPageBehavior |
| 10 */ | 10 */ |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 // Expand the section into a subpage or scroll to it on the main page. | 142 // Expand the section into a subpage or scroll to it on the main page. |
| 143 if (currentRoute.isSubpage()) | 143 if (currentRoute.isSubpage()) |
| 144 promise = this.expandSection_(currentSection); | 144 promise = this.expandSection_(currentSection); |
| 145 else if (scrollToSection) | 145 else if (scrollToSection) |
| 146 currentSection.scrollIntoView(); | 146 currentSection.scrollIntoView(); |
| 147 } else if (settings.Route.ADVANCED.contains(currentRoute) && | 147 } else if (settings.Route.ADVANCED.contains(currentRoute) && |
| 148 // Need to exclude routes that correspond to 'non-sectioned' children of | 148 // Need to exclude routes that correspond to 'non-sectioned' children of |
| 149 // ADVANCED, otherwise tryTransitionToSection_ will recurse endlessly. | 149 // ADVANCED, otherwise tryTransitionToSection_ will recurse endlessly. |
| 150 !currentRoute.isNavigableDialog) { | 150 !currentRoute.isNavigableDialog) { |
| 151 assert(currentRoute.section); | 151 assert(currentRoute.section); |
| 152 promise = this.$$('#advancedPageTemplate').get(); | 152 |
| 153 // The About page also uses this behavior, and doesn't expand Advanced. | |
|
dpapad
2017/03/23 23:09:58
Ah, I understand now the problem. The code assumes
tommycli
2017/03/24 19:11:39
Done.
| |
| 154 var advancedTemplate = this.$$('#advancedPageTemplate'); | |
| 155 if (advancedTemplate) | |
| 156 promise = advancedTemplate.get(); | |
| 153 } | 157 } |
| 154 | 158 |
| 155 // When this animation ends, another may be necessary. Call this function | 159 // When this animation ends, another may be necessary. Call this function |
| 156 // again after the promise resolves. | 160 // again after the promise resolves. |
| 157 if (promise) | 161 if (promise) |
| 158 promise.then(this.tryTransitionToSection_.bind(this, scrollToSection)); | 162 promise.then(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| 159 }, | 163 }, |
| 160 | 164 |
| 161 /** | 165 /** |
| 162 * If the current animation is inconsistent with the current route, stops the | 166 * If the current animation is inconsistent with the current route, stops the |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 return /** @type {?SettingsSectionElement} */( | 342 return /** @type {?SettingsSectionElement} */( |
| 339 this.$$('settings-section[section="' + section + '"]')); | 343 this.$$('settings-section[section="' + section + '"]')); |
| 340 }, | 344 }, |
| 341 }; | 345 }; |
| 342 | 346 |
| 343 /** @polymerBehavior */ | 347 /** @polymerBehavior */ |
| 344 var MainPageBehavior = [ | 348 var MainPageBehavior = [ |
| 345 settings.RouteObserverBehavior, | 349 settings.RouteObserverBehavior, |
| 346 MainPageBehaviorImpl, | 350 MainPageBehaviorImpl, |
| 347 ]; | 351 ]; |
| OLD | NEW |