Index: chrome/browser/resources/settings/settings_main/settings_main.js |
diff --git a/chrome/browser/resources/settings/settings_main/settings_main.js b/chrome/browser/resources/settings/settings_main/settings_main.js |
index b23930bcc55a02cca9df6a3e898753257a2916a0..7a4f12e0a7efd87455d7e45c8c3b748959197652 100644 |
--- a/chrome/browser/resources/settings/settings_main/settings_main.js |
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js |
@@ -10,12 +10,6 @@ Polymer({ |
is: 'settings-main', |
properties: { |
- /** @private */ |
- isAdvancedMenuOpen_: { |
- type: Boolean, |
- value: false, |
- }, |
- |
/** |
* Preferences state. |
*/ |
@@ -35,27 +29,24 @@ Polymer({ |
}, |
/** @private */ |
- showAdvancedPage_: { |
+ advancedToggleExpanded_: { |
type: Boolean, |
value: false, |
}, |
/** @private */ |
- showAdvancedToggle_: { |
- type: Boolean, |
- value: true, |
- }, |
- |
- /** @private */ |
- showBasicPage_: { |
- type: Boolean, |
- value: true, |
- }, |
+ inSubpage_: Boolean, |
- /** @private */ |
- showAboutPage_: { |
- type: Boolean, |
- value: false, |
+ /** |
+ * Controls which main pages are displayed via dom-ifs. |
+ * @type {!{about: boolean, basic: boolean, advanced: boolean}} |
+ * @private |
+ */ |
+ showPages_: { |
+ type: Object, |
+ value: function() { |
+ return {about: false, basic: false, advanced: false}; |
+ }, |
}, |
toolbarSpinnerActive: { |
@@ -82,10 +73,9 @@ Polymer({ |
/** @override */ |
attached: function() { |
document.addEventListener('toggle-advanced-page', function(e) { |
- this.showAdvancedPage_ = e.detail; |
- this.isAdvancedMenuOpen_ = e.detail; |
+ this.advancedToggleExpanded_ = e.detail; |
this.currentRoute = { |
- page: this.isAdvancedMenuOpen_ ? 'advanced' : 'basic', |
+ page: this.advancedToggleExpanded_ ? 'advanced' : 'basic', |
section: '', |
subpage: [], |
}; |
@@ -105,7 +95,7 @@ Polymer({ |
* @param {boolean} opened Whether the menu is expanded. |
* @return {string} Which icon to use. |
* @private |
- * */ |
+ */ |
arrowState_: function(opened) { |
return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
}, |
@@ -115,24 +105,27 @@ Polymer({ |
* @private |
*/ |
currentRouteChanged_: function(newRoute) { |
- var isSubpage = !!newRoute.subpage.length; |
- |
- this.showAboutPage_ = newRoute.page == 'about'; |
- |
- this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
- |
- this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
- |
- this.showAdvancedPage_ = |
- (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
- newRoute.page == 'advanced'; |
+ this.inSubpage_ = newRoute.subpage.length > 0; |
+ this.style.height = this.inSubpage_ ? '100%' : ''; |
+ |
+ if (newRoute.page == 'about') { |
+ this.showPages_ = {about: true, basic: false, advanced: false}; |
+ } else { |
+ this.showPages_ = { |
+ about: false, |
+ basic: newRoute.page == 'basic' || !this.inSubpage_, |
+ advanced: newRoute.page == 'advanced' || |
+ (!this.inSubpage_ && this.advancedToggleExpanded_), |
+ }; |
- this.style.height = isSubpage ? '100%' : ''; |
+ if (this.showPages_.advanced) |
+ this.advancedToggleExpanded_ = true; |
dschuyler
2016/07/21 19:02:05
When would this be needed (when would it not
be s
michaelpg
2016/07/21 19:55:28
When you navigate to chrome://md-settings/advanced
michaelpg
2016/07/22 15:12:17
So this definitely needs to change to fix Advanced
|
+ } |
}, |
/** @private */ |
toggleAdvancedPage_: function() { |
- this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
+ this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); |
}, |
/** |
@@ -156,13 +149,13 @@ Polymer({ |
// Trigger rendering of the basic and advanced pages and search once ready. |
// Even if those are already rendered, yield to the message loop before |
// initiating searching. |
- this.showBasicPage_ = true; |
+ this.set('showPages_.basic', true); |
dschuyler
2016/07/21 19:02:05
With the new struct to set the basic, advanced, ab
michaelpg
2016/07/21 19:55:28
You'd have to ask dpapad whether it matters. I don
dpapad
2016/07/21 22:31:27
I believe that setting both booleans at once here
michaelpg
2016/07/22 15:12:18
Nah, the struct of booleans is good step forward.
|
setTimeout(function() { |
settings.getSearchManager().search( |
query, assert(this.$$('settings-basic-page'))); |
}.bind(this), 0); |
- this.showAdvancedPage_ = true; |
+ this.set('showPages_.advanced', true); |
setTimeout(function() { |
settings.getSearchManager().search( |
query, assert(this.$$('settings-advanced-page'))); |