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', |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 notify: true, | 27 notify: true, |
| 28 observer: 'currentRouteChanged_', | 28 observer: 'currentRouteChanged_', |
| 29 }, | 29 }, |
| 30 | 30 |
| 31 /** @private */ | 31 /** @private */ |
| 32 advancedToggleExpanded_: { | 32 advancedToggleExpanded_: { |
| 33 type: Boolean, | 33 type: Boolean, |
| 34 value: false, | 34 value: false, |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 /** @private */ | 37 /** |
| 38 * True if a section is expanded to show a subpage. Initialized using | |
| 39 * currentRoute. Toggles based on expand/collapse events so effects can | |
| 40 * be deferred until transitions complete. | |
| 41 * @private | |
| 42 */ | |
| 38 inSubpage_: Boolean, | 43 inSubpage_: Boolean, |
| 39 | 44 |
| 40 /** | 45 /** |
| 41 * Controls which main pages are displayed via dom-ifs. | 46 * Controls which main pages are displayed via dom-ifs. |
| 42 * @type {!{about: boolean, basic: boolean, advanced: boolean}} | 47 * @type {!{about: boolean, basic: boolean, advanced: boolean}} |
| 43 * @private | 48 * @private |
| 44 */ | 49 */ |
| 45 showPages_: { | 50 showPages_: { |
| 46 type: Object, | 51 type: Object, |
| 47 value: function() { | 52 value: function() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 }.bind(this)); | 87 }.bind(this)); |
| 83 | 88 |
| 84 doWhenReady( | 89 doWhenReady( |
| 85 function() { | 90 function() { |
| 86 var basicPage = this.$$('settings-basic-page'); | 91 var basicPage = this.$$('settings-basic-page'); |
| 87 return !!basicPage && basicPage.scrollHeight > 0; | 92 return !!basicPage && basicPage.scrollHeight > 0; |
| 88 }.bind(this), | 93 }.bind(this), |
| 89 function() { | 94 function() { |
| 90 this.resolver_.resolve(); | 95 this.resolver_.resolve(); |
| 91 }.bind(this)); | 96 }.bind(this)); |
| 97 | |
| 98 this.inSubpage_ = this.currentRoute.subpage.length > 0; | |
|
Dan Beam
2016/07/23 01:13:44
so we don't need to call updatePagesShown_() here?
| |
| 92 }, | 99 }, |
| 93 | 100 |
| 94 /** | 101 /** |
| 95 * @param {boolean} opened Whether the menu is expanded. | 102 * @param {boolean} opened Whether the menu is expanded. |
| 96 * @return {string} Which icon to use. | 103 * @return {string} Which icon to use. |
| 97 * @private | 104 * @private |
| 98 */ | 105 */ |
| 99 arrowState_: function(opened) { | 106 arrowState_: function(opened) { |
| 100 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | 107 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
| 101 }, | 108 }, |
| 102 | 109 |
| 103 /** | 110 /** |
| 104 * @param {boolean} showBasicPage | 111 * @param {boolean} showBasicPage |
| 105 * @param {boolean} inSubpage | 112 * @param {boolean} inSubpage |
| 106 * @return {boolean} | 113 * @return {boolean} |
| 107 */ | 114 */ |
| 108 showAdvancedToggle_: function(showBasicPage, inSubpage) { | 115 showAdvancedToggle_: function(showBasicPage, inSubpage) { |
| 109 return showBasicPage && !inSubpage; | 116 return showBasicPage && !inSubpage; |
| 110 }, | 117 }, |
| 111 | 118 |
| 112 /** | 119 /** |
| 113 * @param {!SettingsRoute} newRoute | 120 * @param {!SettingsRoute} newRoute |
| 114 * @private | 121 * @private |
| 115 */ | 122 */ |
| 116 currentRouteChanged_: function(newRoute) { | 123 currentRouteChanged_: function(newRoute) { |
| 117 this.inSubpage_ = newRoute.subpage.length > 0; | 124 this.updatePagesShown_(); |
| 118 this.style.height = this.inSubpage_ ? '100%' : ''; | 125 }, |
| 119 | 126 |
| 120 if (newRoute.page == 'about') { | 127 /** @private */ |
| 121 this.showPages_ = {about: true, basic: false, advanced: false}; | 128 subpageExpanded_: function() { |
| 129 this.inSubpage_ = true; | |
| 130 // Hide pages other than the current section's parent page. | |
| 131 this.updatePagesShown_(); | |
| 132 }, | |
| 133 | |
| 134 /** @private */ | |
| 135 subpageCollapsing_: function() { | |
| 136 this.inSubpage_ = false; | |
| 137 // Unhide pages before collapsing the full-height section. | |
| 138 this.updatePagesShown_(); | |
| 139 }, | |
| 140 | |
| 141 /** | |
| 142 * Updates the hidden state of the about, basic and advanced pages, based on | |
| 143 * the current route and the Advanced toggle state. | |
| 144 * @private | |
| 145 */ | |
| 146 updatePagesShown_: function() { | |
| 147 if (this.currentRoute.page == 'about') { | |
| 148 this.showPages_ = {about: true, advanced: false, basic: false}; | |
| 122 } else { | 149 } else { |
| 123 this.showPages_ = { | 150 this.showPages_ = { |
| 124 about: false, | 151 about: false, |
| 125 basic: newRoute.page == 'basic' || !this.inSubpage_, | 152 basic: this.currentRoute.page == 'basic' || !this.inSubpage_, |
| 126 advanced: newRoute.page == 'advanced' || | 153 advanced: this.currentRoute.page == 'advanced' || |
| 127 (!this.inSubpage_ && this.advancedToggleExpanded_), | 154 (!this.inSubpage_ && this.advancedToggleExpanded_), |
| 128 }; | 155 }; |
| 129 | 156 |
| 130 if (this.showPages_.advanced) | 157 if (this.showPages_.advanced) |
| 131 this.advancedToggleExpanded_ = true; | 158 this.advancedToggleExpanded_ = true; |
| 132 } | 159 } |
| 133 }, | 160 }, |
| 134 | 161 |
| 135 /** @private */ | 162 /** @private */ |
| 136 toggleAdvancedPage_: function() { | 163 toggleAdvancedPage_: function() { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 162 setTimeout(function() { | 189 setTimeout(function() { |
| 163 settings.getSearchManager().search( | 190 settings.getSearchManager().search( |
| 164 query, assert(this.$$('settings-basic-page'))); | 191 query, assert(this.$$('settings-basic-page'))); |
| 165 }.bind(this), 0); | 192 }.bind(this), 0); |
| 166 setTimeout(function() { | 193 setTimeout(function() { |
| 167 settings.getSearchManager().search( | 194 settings.getSearchManager().search( |
| 168 query, assert(this.$$('settings-advanced-page'))); | 195 query, assert(this.$$('settings-advanced-page'))); |
| 169 }.bind(this), 0); | 196 }.bind(this), 0); |
| 170 }, | 197 }, |
| 171 }); | 198 }); |
| OLD | NEW |