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 * @typedef {{about: boolean, basic: boolean, advanced: boolean}} | 6 * @typedef {{about: boolean, basic: boolean, advanced: boolean}} |
| 7 */ | 7 */ |
| 8 var MainPageVisibility; | 8 var MainPageVisibility; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 pageVisibility: { | 85 pageVisibility: { |
| 86 type: Object, | 86 type: Object, |
| 87 value: function() { return {}; }, | 87 value: function() { return {}; }, |
| 88 }, | 88 }, |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 /** @override */ | 91 /** @override */ |
| 92 attached: function() { | 92 attached: function() { |
| 93 document.addEventListener('toggle-advanced-page', function(e) { | 93 document.addEventListener('toggle-advanced-page', function(e) { |
| 94 this.advancedToggleExpanded_ = e.detail; | 94 this.advancedToggleExpanded_ = e.detail; |
| 95 this.currentRouteChanged(settings.getCurrentRoute()); | 95 this.updatePagesShown_(); |
| 96 }.bind(this)); | 96 }.bind(this)); |
| 97 | 97 |
| 98 var currentRoute = settings.getCurrentRoute(); | 98 var currentRoute = settings.getCurrentRoute(); |
| 99 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage(); | 99 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage(); |
| 100 }, | 100 }, |
| 101 | 101 |
| 102 /** @private */ | 102 /** @private */ |
| 103 overscrollChanged_: function() { | 103 overscrollChanged_: function() { |
| 104 if (!this.overscroll_ && this.boundScroll_) { | 104 if (!this.overscroll_ && this.boundScroll_) { |
| 105 this.offsetParent.removeEventListener('scroll', this.boundScroll_); | 105 this.offsetParent.removeEventListener('scroll', this.boundScroll_); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 var inSearchMode = !!this.previousShowPages_; | 145 var inSearchMode = !!this.previousShowPages_; |
| 146 return !inSearchMode && this.showPages_.basic && !this.hasExpandedSection_; | 146 return !inSearchMode && this.showPages_.basic && !this.hasExpandedSection_; |
| 147 }, | 147 }, |
| 148 | 148 |
| 149 currentRouteChanged: function(newRoute) { | 149 currentRouteChanged: function(newRoute) { |
| 150 // When the route changes from a sub-page to the main page, immediately | 150 // When the route changes from a sub-page to the main page, immediately |
| 151 // update hasExpandedSection_ to unhide the other sections. | 151 // update hasExpandedSection_ to unhide the other sections. |
| 152 if (!newRoute.isSubpage()) | 152 if (!newRoute.isSubpage()) |
| 153 this.hasExpandedSection_ = false; | 153 this.hasExpandedSection_ = false; |
| 154 | 154 |
| 155 if (settings.Route.ADVANCED.contains(newRoute)) | |
| 156 this.advancedToggleExpanded_ = true; | |
| 157 | |
| 155 this.updatePagesShown_(); | 158 this.updatePagesShown_(); |
| 156 }, | 159 }, |
| 157 | 160 |
| 158 /** @private */ | 161 /** @private */ |
| 159 onSubpageExpand_: function() { | 162 onSubpageExpand_: function() { |
| 160 // The subpage finished expanding fully. Hide pages other than the current | 163 // The subpage finished expanding fully. Hide pages other than the current |
| 161 // section's parent page. | 164 // section's parent page. |
| 162 this.hasExpandedSection_ = true; | 165 this.hasExpandedSection_ = true; |
| 163 this.updatePagesShown_(); | 166 this.updatePagesShown_(); |
| 164 }, | 167 }, |
| 165 | 168 |
| 166 /** | 169 /** |
| 167 * Updates the hidden state of the about, basic and advanced pages, based on | 170 * Updates the hidden state of the about, basic and advanced pages, based on |
| 168 * the current route and the Advanced toggle state. | 171 * the current route and the Advanced toggle state. |
| 169 * @private | 172 * @private |
| 170 */ | 173 */ |
| 171 updatePagesShown_: function() { | 174 updatePagesShown_: function() { |
| 172 var currentRoute = settings.getCurrentRoute(); | 175 var currentRoute = settings.getCurrentRoute(); |
| 173 if (settings.Route.ABOUT.contains(currentRoute)) { | 176 if (settings.Route.ABOUT.contains(currentRoute)) { |
| 174 this.showPages_ = {about: true, basic: false, advanced: false}; | 177 this.showPages_ = {about: true, basic: false, advanced: false}; |
| 175 } else { | 178 } else { |
| 176 this.showPages_ = { | 179 this.showPages_ = { |
| 177 about: false, | 180 about: false, |
| 178 basic: settings.Route.BASIC.contains(currentRoute) || | 181 basic: settings.Route.BASIC.contains(currentRoute) || |
| 179 !this.hasExpandedSection_, | 182 !this.hasExpandedSection_, |
| 180 advanced: settings.Route.ADVANCED.contains(currentRoute) || | 183 advanced: this.hasExpandedSection_ ? |
| 181 (!this.hasExpandedSection_ && this.advancedToggleExpanded_), | 184 settings.Route.ADVANCED.contains(currentRoute) : |
| 185 this.advancedToggleExpanded_, | |
|
dschuyler
2016/09/14 00:11:02
nit: the indent looks incorrect. Is it indented fr
tommycli
2016/09/14 00:12:22
Done.
| |
| 182 }; | 186 }; |
| 183 | |
| 184 if (this.showPages_.advanced) { | |
| 185 assert(!this.pageVisibility || | |
| 186 this.pageVisibility.advancedSettings !== false); | |
| 187 this.advancedToggleExpanded_ = true; | |
| 188 } | |
| 189 } | 187 } |
| 190 | 188 |
| 191 // Wait for any other changes prior to calculating the overflow padding. | 189 // Wait for any other changes prior to calculating the overflow padding. |
| 192 setTimeout(function() { | 190 setTimeout(function() { |
| 193 // Ensure any dom-if reflects the current properties. | 191 // Ensure any dom-if reflects the current properties. |
| 194 Polymer.dom.flush(); | 192 Polymer.dom.flush(); |
| 195 | 193 |
| 196 this.setOverscroll_(this.overscrollHeight_()); | 194 this.setOverscroll_(this.overscrollHeight_()); |
| 197 }.bind(this)); | 195 }.bind(this)); |
| 198 }, | 196 }, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 | 308 |
| 311 /** | 309 /** |
| 312 * @param {(boolean|undefined)} visibility | 310 * @param {(boolean|undefined)} visibility |
| 313 * @return {boolean} True unless visibility is false. | 311 * @return {boolean} True unless visibility is false. |
| 314 * @private | 312 * @private |
| 315 */ | 313 */ |
| 316 showAdvancedSettings_: function(visibility) { | 314 showAdvancedSettings_: function(visibility) { |
| 317 return visibility !== false; | 315 return visibility !== false; |
| 318 }, | 316 }, |
| 319 }); | 317 }); |
| OLD | NEW |