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