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_: Boolean, | |
| 15 | |
| 20 /** | 16 /** |
| 21 * Preferences state. | 17 * Preferences state. |
| 22 * | 18 * |
| 23 * @type {?CrSettingsPrefsElement} | 19 * @type {?CrSettingsPrefsElement} |
| 24 */ | 20 */ |
| 25 prefs: { | 21 prefs: { |
| 26 type: Object, | 22 type: Object, |
| 27 notify: true, | 23 notify: true, |
| 28 }, | 24 }, |
| 29 | 25 |
| 30 /** | 26 /** |
| 31 * The current active route. | 27 * The current active route. |
| 28 * @type {!SettingsRoute} | |
| 32 */ | 29 */ |
| 33 currentRoute: { | 30 currentRoute: { |
| 34 type: Object, | 31 type: Object, |
| 35 notify: true, | 32 notify: true, |
| 36 observer: 'currentRouteChanged_', | 33 observer: 'currentRouteChanged_', |
| 37 }, | 34 }, |
| 38 | 35 |
| 39 /** @private */ | 36 /** @private */ |
| 40 showAdvancedPage_: Boolean, | 37 showAdvancedPage_: Boolean, |
| 41 | 38 |
| 42 /** @private */ | 39 /** @private */ |
| 40 showAdvancedToggle_: Boolean, | |
| 41 | |
| 42 /** @private */ | |
| 43 showBasicPage_: Boolean, | 43 showBasicPage_: Boolean, |
| 44 | 44 |
| 45 /** @private */ | 45 /** @private */ |
| 46 showAboutPage_: Boolean, | 46 showAboutPage_: Boolean, |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 attached: function() { | |
| 50 document.addEventListener('toggle-advanced-page', function(e) { | |
| 51 this.showAdvancedPage_ = e.detail; | |
| 52 this.isAdvancedMenuOpen_ = e.detail; | |
|
Dan Beam
2016/06/02 01:28:19
does this compile? do you need to cast |e| to a C
dschuyler
2016/06/02 23:23:55
I added a compiled_resources2.gyp to test this.
e.
| |
| 53 }.bind(this)); | |
| 54 }, | |
| 55 | |
| 49 /** | 56 /** |
| 50 * @param {!SettingsRoute} newRoute | 57 * @param {!SettingsRoute} newRoute |
| 51 * @private | 58 * @private |
| 52 */ | 59 */ |
| 53 currentRouteChanged_: function(newRoute) { | 60 currentRouteChanged_: function(newRoute, oldRoute) { |
| 61 var isSubpage = !!newRoute.subpage.length; | |
| 62 | |
| 54 this.showAboutPage_ = newRoute.page == 'about'; | 63 this.showAboutPage_ = newRoute.page == 'about'; |
| 55 this.showAdvancedPage_ = newRoute.page == 'advanced'; | 64 |
| 56 this.showBasicPage_ = newRoute.page == 'basic'; | 65 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 66 | |
| 67 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | |
| 68 | |
| 69 this.showAdvancedPage_ = this.isAdvancedMenuOpen_ && | |
| 70 this.showAdvancedToggle_ || newRoute.page == 'advanced'; | |
|
Dan Beam
2016/06/02 01:28:20
add extra parens cuz ambiguity
dschuyler
2016/06/02 23:23:55
Done.
| |
| 71 | |
| 72 this.$.pageContainer.style.height = (isSubpage ? '100%' : ''); | |
|
Dan Beam
2016/06/02 01:28:19
drop extra parens
dschuyler
2016/06/02 23:23:55
Done.
| |
| 73 }, | |
| 74 | |
| 75 /** @private */ | |
| 76 toggleAdvancedPage_: function() { | |
| 77 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | |
| 57 }, | 78 }, |
| 58 }); | 79 }); |
| OLD | NEW |