Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3286)

Unified Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2160713002: MD Settings: refactor some main page properties, fix Advanced toggle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: object Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a5a6d10c5c551c74e652076ad17224e1cae42f98..7bc19ce34cc63b5421fc759c2b5105ba8bde17a7 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, ADVANCED: boolean, BASIC: boolean}}
+ * @private
+ */
+ showPages_: {
+ type: Object,
+ value: function() {
+ return {ABOUT: false, ADVANCED: false, BASIC: false};
+ },
},
toolbarSpinnerActive: {
@@ -82,14 +73,13 @@ 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: [],
};
- if (this.showAdvancedPage_) {
+ if (this.advancedToggleExpanded_) {
doWhenReady(
function() {
var advancedPage = this.$$('settings-advanced-page');
@@ -115,7 +105,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';
},
@@ -125,24 +115,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, ADVANCED: false, BASIC: 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;
+ }
},
/** @private */
toggleAdvancedPage_: function() {
- this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_);
+ this.fire('toggle-advanced-page', !this.advancedToggleExpanded_);
},
/**
@@ -166,13 +159,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);
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')));

Powered by Google App Engine
This is Rietveld 408576698