| OLD | NEW |
| 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 * Example: | 9 * Example: |
| 10 * | 10 * |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 observer: 'currentRouteChanged_', | 36 observer: 'currentRouteChanged_', |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 // If false the 'basic' page should be shown. | 39 // If false the 'basic' page should be shown. |
| 40 showAdvancedPage_: { | 40 showAdvancedPage_: { |
| 41 type: Boolean, | 41 type: Boolean, |
| 42 value: false | 42 value: false |
| 43 } | 43 } |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 listeners: { | |
| 47 'expand-animation-complete': 'onExpandAnimationComplete_', | |
| 48 }, | |
| 49 | |
| 50 /** @private */ | 46 /** @private */ |
| 51 currentRouteChanged_: function(newRoute, oldRoute) { | 47 currentRouteChanged_: function(newRoute, oldRoute) { |
| 52 this.showAdvancedPage_ = newRoute.page == 'advanced'; | 48 this.showAdvancedPage_ = newRoute.page == 'advanced'; |
| 53 | |
| 54 var pageContainer = this.$.pageContainer; | |
| 55 if (!oldRoute) { | |
| 56 pageContainer.classList.toggle('expanded', newRoute.section); | |
| 57 return; | |
| 58 } | |
| 59 | |
| 60 // For contraction only, apply new styling immediately. | |
| 61 if (!newRoute.section && oldRoute.section) { | |
| 62 pageContainer.classList.remove('expanded'); | |
| 63 | |
| 64 // TODO(tommycli): Save and restore scroll position. crbug.com/537359. | |
| 65 pageContainer.scrollTop = 0; | |
| 66 } | |
| 67 }, | |
| 68 | |
| 69 /** @private */ | |
| 70 onExpandAnimationComplete_: function() { | |
| 71 if (this.currentRoute.section) { | |
| 72 var pageContainer = this.$.pageContainer; | |
| 73 pageContainer.classList.add('expanded'); | |
| 74 pageContainer.scrollTop = 0; | |
| 75 } | |
| 76 }, | 49 }, |
| 77 }); | 50 }); |
| OLD | NEW |