Chromium Code Reviews| 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 * | |
| 9 * Example: | |
| 10 * | |
| 11 * <settings-main pages="[[pages]]" selected-page-id="{{selectedId}}"> | |
| 12 * </settings-main> | |
| 13 * | |
| 14 * See settings-drawer for example of use in 'paper-drawer-panel'. | |
| 15 */ | 8 */ |
| 16 Polymer({ | 9 Polymer({ |
| 17 is: 'settings-main', | 10 is: 'settings-main', |
| 18 | 11 |
| 19 properties: { | 12 properties: { |
| 13 /** @private */ | |
| 14 isAdvancedMenuOpen_: { | |
| 15 type: Boolean, | |
| 16 value: false, | |
| 17 }, | |
| 18 | |
| 20 /** | 19 /** |
| 21 * Preferences state. | 20 * Preferences state. |
| 22 * | |
| 23 * @type {?CrSettingsPrefsElement} | |
| 24 */ | 21 */ |
| 25 prefs: { | 22 prefs: { |
| 26 type: Object, | 23 type: Object, |
| 27 notify: true, | 24 notify: true, |
| 28 }, | 25 }, |
| 29 | 26 |
| 30 /** | 27 /** |
| 31 * The current active route. | 28 * The current active route. |
| 29 * @type {!SettingsRoute} | |
| 32 */ | 30 */ |
| 33 currentRoute: { | 31 currentRoute: { |
| 34 type: Object, | 32 type: Object, |
| 35 notify: true, | 33 notify: true, |
| 36 observer: 'currentRouteChanged_', | 34 observer: 'currentRouteChanged_', |
| 37 }, | 35 }, |
| 38 | 36 |
| 39 /** @private */ | 37 /** @private */ |
| 40 showAdvancedPage_: Boolean, | 38 showAdvancedPage_: { |
| 39 type: Boolean, | |
| 40 value: false, | |
| 41 }, | |
| 41 | 42 |
| 42 /** @private */ | 43 /** @private */ |
| 43 showBasicPage_: Boolean, | 44 showAdvancedToggle_: { |
| 45 type: Boolean, | |
| 46 value: true, | |
| 47 }, | |
| 44 | 48 |
| 45 /** @private */ | 49 /** @private */ |
| 46 showAboutPage_: Boolean, | 50 showBasicPage_: { |
| 51 type: Boolean, | |
| 52 value: true, | |
| 53 }, | |
| 54 | |
| 55 /** @private */ | |
| 56 showAboutPage_: { | |
| 57 type: Boolean, | |
| 58 value: false, | |
| 59 }, | |
| 60 }, | |
| 61 | |
| 62 attached: function() { | |
| 63 document.addEventListener('toggle-advanced-page', function(e) { | |
| 64 this.showAdvancedPage_ = e.detail; | |
| 65 this.isAdvancedMenuOpen_ = e.detail; | |
| 66 }.bind(this)); | |
| 47 }, | 67 }, |
| 48 | 68 |
| 49 /** | 69 /** |
| 50 * @param {!SettingsRoute} newRoute | 70 * @param {!SettingsRoute} newRoute |
| 51 * @private | 71 * @private |
| 52 */ | 72 */ |
| 53 currentRouteChanged_: function(newRoute) { | 73 currentRouteChanged_: function(newRoute) { |
| 74 var isSubpage = !!newRoute.subpage.length; | |
| 75 | |
| 54 this.showAboutPage_ = newRoute.page == 'about'; | 76 this.showAboutPage_ = newRoute.page == 'about'; |
| 55 this.showAdvancedPage_ = newRoute.page == 'advanced'; | 77 |
| 56 this.showBasicPage_ = newRoute.page == 'basic'; | 78 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 79 | |
| 80 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | |
| 81 | |
| 82 this.showAdvancedPage_ = | |
| 83 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | |
| 84 newRoute.page == 'advanced'; | |
| 85 | |
| 86 this.$.pageContainer.style.height = isSubpage ? '100%' : ''; | |
|
michaelpg
2016/06/09 18:00:13
this resets the scrollTop of this.$.pageContainer
| |
| 87 }, | |
| 88 | |
| 89 /** @private */ | |
| 90 toggleAdvancedPage_: function() { | |
| 91 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | |
| 57 }, | 92 }, |
| 58 }); | 93 }); |
| OLD | NEW |