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

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: 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
« no previous file with comments | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 75daea44da83eb7a5e91e6f11fb9a2c469abc85b..89feb7da7b425f5f23e71cd6f8cdebd490204500 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,34 @@ Polymer({
},
/** @private */
- showAdvancedPage_: {
+ advancedToggleExpanded_: {
type: Boolean,
value: false,
},
/** @private */
- showAdvancedToggle_: {
+ inSubpage_: {
+ type: Boolean,
+ computed: 'computeInSubpage_(currentRoute.subpage)',
+ },
+
+ /** @private */
+ showAboutPage_: {
type: Boolean,
- value: true,
+ computed: 'computeShowAboutPage_(currentRoute.page)',
},
/** @private */
showBasicPage_: {
type: Boolean,
- value: true,
+ computed: 'computeShowBasicPage_(currentRoute.page, inSubpage_)',
},
/** @private */
- showAboutPage_: {
+ showAdvancedPage_: {
type: Boolean,
- value: false,
+ computed: 'computeShowAdvancedPage_(' +
+ 'currentRoute.page, advancedToggleExpanded_, inSubpage_)',
},
},
@@ -68,14 +69,13 @@ Polymer({
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');
@@ -101,7 +101,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';
},
@@ -111,24 +111,16 @@ Polymer({
* @private
*/
currentRouteChanged_: function(newRoute) {
- var isSubpage = !!newRoute.subpage.length;
+ // If we navigated to an advanced section, ensure the toggle is opened.
+ if (newRoute.page == 'advanced')
+ this.advancedToggleExpanded_ = true;
- 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.style.height = isSubpage ? '100%' : '';
+ this.style.height = this.inSubpage_ ? '100%' : '';
},
/** @private */
toggleAdvancedPage_: function() {
- this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_);
+ this.fire('toggle-advanced-page', !this.advancedToggleExpanded_);
},
/**
@@ -162,4 +154,45 @@ Polymer({
settings.search(query, assert(this.$$('settings-advanced-page')));
}.bind(this), 0);
},
+
+ /**
+ * @return {boolean}
+ * @param {!Array<string>} subpage
+ * @private
+ */
+ computeInSubpage_: function(subpage) {
+ return !!subpage.length;
+ },
+
+ /**
+ * @param {string} page
+ * @return {boolean}
+ * @private
+ */
+ computeShowAboutPage_: function(page) {
+ return page == 'about';
+ },
+
+ /**
+ * @param {string} page
+ * @param {boolean} inSubpage
+ * @return {boolean}
+ * @private
+ */
+ computeShowBasicPage_: function(page, inSubpage) {
+ return page == 'basic' ||
+ (page == 'advanced' && !inSubpage);
+ },
+
+ /**
+ * @param {string} page
+ * @param {boolean} advancedToggleExpanded
+ * @param {boolean} inSubpage
+ * @return {boolean}
+ * @private
+ */
+ computeShowAdvancedPage_: function(page, advancedToggleExpanded, inSubpage) {
+ return page == 'advanced' ||
+ (page == 'basic' && advancedToggleExpanded && !inSubpage);
+ },
});
« no previous file with comments | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698