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