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 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-main', | 10 is: 'settings-main', |
| 11 | 11 |
| 12 behaviors: [RoutableBehavior], | |
|
michaelpg
2016/06/13 21:11:22
This should not be a RoutableBehavior, which contr
dschuyler
2016/06/13 21:44:50
Done.
| |
| 13 | |
| 12 properties: { | 14 properties: { |
| 13 /** @private */ | 15 /** @private */ |
| 14 isAdvancedMenuOpen_: { | 16 isAdvancedMenuOpen_: { |
| 15 type: Boolean, | 17 type: Boolean, |
| 16 value: false, | 18 value: false, |
| 17 }, | 19 }, |
| 18 | 20 |
| 19 /** | 21 /** |
| 20 * Preferences state. | 22 * Preferences state. |
| 21 */ | 23 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 showAboutPage_: { | 58 showAboutPage_: { |
| 57 type: Boolean, | 59 type: Boolean, |
| 58 value: false, | 60 value: false, |
| 59 }, | 61 }, |
| 60 }, | 62 }, |
| 61 | 63 |
| 62 attached: function() { | 64 attached: function() { |
| 63 document.addEventListener('toggle-advanced-page', function(e) { | 65 document.addEventListener('toggle-advanced-page', function(e) { |
| 64 this.showAdvancedPage_ = e.detail; | 66 this.showAdvancedPage_ = e.detail; |
| 65 this.isAdvancedMenuOpen_ = e.detail; | 67 this.isAdvancedMenuOpen_ = e.detail; |
| 68 if (this.showAdvancedPage_) { | |
| 69 this.scrollWhenReady( | |
| 70 function() { | |
| 71 return this.shadowRoot.querySelector('settings-advanced-page'); | |
| 72 }.bind(this), | |
| 73 function() { | |
| 74 return this.shadowRoot.querySelector('#toggleContainer'); | |
| 75 }.bind(this)); | |
| 76 } | |
| 66 }.bind(this)); | 77 }.bind(this)); |
| 67 }, | 78 }, |
| 68 | 79 |
| 69 /** | 80 /** |
| 81 * @param {boolean} opened Whether the menu is expanded. | |
| 82 * @return {string} Which icon to use. | |
| 83 * @private | |
| 84 * */ | |
| 85 arrowState_: function(opened) { | |
| 86 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | |
| 87 }, | |
| 88 | |
| 89 /** | |
| 70 * @param {!SettingsRoute} newRoute | 90 * @param {!SettingsRoute} newRoute |
| 71 * @private | 91 * @private |
| 72 */ | 92 */ |
| 73 currentRouteChanged_: function(newRoute) { | 93 currentRouteChanged_: function(newRoute) { |
| 74 var isSubpage = !!newRoute.subpage.length; | 94 var isSubpage = !!newRoute.subpage.length; |
| 75 | 95 |
| 76 this.showAboutPage_ = newRoute.page == 'about'; | 96 this.showAboutPage_ = newRoute.page == 'about'; |
| 77 | 97 |
| 78 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 98 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 79 | 99 |
| 80 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 100 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 81 | 101 |
| 82 this.showAdvancedPage_ = | 102 this.showAdvancedPage_ = |
| 83 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 103 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 84 newRoute.page == 'advanced'; | 104 newRoute.page == 'advanced'; |
| 85 | 105 |
| 86 this.$.pageContainer.style.height = isSubpage ? '100%' : ''; | 106 this.style.height = isSubpage ? '100%' : ''; |
| 87 }, | 107 }, |
| 88 | 108 |
| 89 /** @private */ | 109 /** @private */ |
| 90 toggleAdvancedPage_: function() { | 110 toggleAdvancedPage_: function() { |
| 91 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 111 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 92 }, | 112 }, |
| 93 }); | 113 }); |
| OLD | NEW |