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

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

Issue 2518233004: MD Settings: Move settings-advanced-page into settings-basic-page (Closed)
Patch Set: rebase Created 4 years 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 b5f524a17866f5bc183e5fbb36566a49bae7dfde..51bb5f422fb7db5c411e7c39dc236072f6f8e1db 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -3,7 +3,7 @@
// found in the LICENSE file.
/**
- * @typedef {{about: boolean, basic: boolean, advanced: boolean}}
+ * @typedef {{about: boolean, settings: boolean}}
*/
var MainPageVisibility;
@@ -28,16 +28,8 @@ Polymer({
advancedToggleExpanded: {
type: Boolean,
notify: true,
- observer: 'updatePagesShown_',
},
- /**
- * True if a section is fully expanded to hide other sections beneath it.
- * Not true otherwise (even while animating a section open/closed).
- * @private
- */
- hasExpandedSection_: Boolean,
-
/** @private */
overscroll_: {
type: Number,
@@ -46,13 +38,13 @@ Polymer({
/**
* Controls which main pages are displayed via dom-ifs, based on the current
- * route and the Advanced toggle state.
+ * route.
* @private {!MainPageVisibility}
*/
showPages_: {
type: Object,
value: function() {
- return {about: false, basic: false, advanced: false};
+ return {about: false, settings: false};
},
},
@@ -93,8 +85,6 @@ Polymer({
/** @override */
attached: function() {
this.listen(this, 'freeze-scroll', 'onFreezeScroll_');
- var currentRoute = settings.getCurrentRoute();
- this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage();
},
/** @override */
@@ -162,84 +152,24 @@ 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';
- },
-
- /**
- * @return {boolean}
- * @private
- */
- showAdvancedToggle_: function() {
- return !this.inSearchMode_ && this.showPages_.basic &&
- !this.hasExpandedSection_;
- },
-
- /**
- * @return {boolean} Whether to show the basic page, taking into account both
- * routing and search state.
- * @private
- */
- showBasicPage_: function() {
- return this.showPages_.basic || (
- this.inSearchMode_ && !this.hasExpandedSection_);
- },
-
- /**
- * @return {boolean} Whether to show the advanced page, taking into account
- * both routing and search state.
- * @private
- */
- showAdvancedPage_: function() {
- return this.showPages_.advanced || (
- this.inSearchMode_ && !this.hasExpandedSection_);
- },
-
/** @param {!settings.Route} newRoute */
currentRouteChanged: function(newRoute) {
- // When the route changes from a sub-page to the main page, immediately
- // update hasExpandedSection_ to unhide the other sections.
- if (!newRoute.isSubpage())
- this.hasExpandedSection_ = false;
-
- if (settings.Route.ADVANCED.contains(newRoute))
- this.advancedToggleExpanded = true;
-
this.updatePagesShown_();
},
/** @private */
onSubpageExpand_: function() {
- // The subpage finished expanding fully. Hide pages other than the current
- // section's parent page.
- this.hasExpandedSection_ = true;
this.updatePagesShown_();
},
/**
- * Updates the hidden state of the about, basic and advanced pages, based on
- * the current route and the Advanced toggle state.
+ * Updates the hidden state of the about and settings pages based on the
+ * current route.
* @private
*/
updatePagesShown_: function() {
- var currentRoute = settings.getCurrentRoute();
- if (settings.Route.ABOUT.contains(currentRoute)) {
- this.showPages_ = {about: true, basic: false, advanced: false};
- } else {
- this.showPages_ = {
- about: false,
- basic: settings.Route.BASIC.contains(currentRoute) ||
- !this.hasExpandedSection_,
- advanced: this.hasExpandedSection_ ?
- settings.Route.ADVANCED.contains(currentRoute) :
- this.advancedToggleExpanded,
- };
- }
+ var inAbout = settings.Route.ABOUT.contains(settings.getCurrentRoute());
+ this.showPages_ = {about: inAbout, settings: !inAbout};
// Calculate and set the overflow padding.
this.updateOverscrollForPage_();
@@ -292,27 +222,18 @@ Polymer({
return Math.max(0, this.offsetParent.clientHeight - distance);
},
- /** @private */
- toggleAdvancedPage_: function() {
- this.advancedToggleExpanded = !this.advancedToggleExpanded;
- },
-
/**
* Returns the root page (if it exists) for a route.
* @param {!settings.Route} route
- * @return {(?SettingsAboutPageElement|?SettingsAdvancedPageElement|
- * ?SettingsBasicPageElement)}
+ * @return {(?SettingsAboutPageElement|?SettingsBasicPageElement)}
*/
getPage_: function(route) {
if (settings.Route.ABOUT.contains(route)) {
return /** @type {?SettingsAboutPageElement} */(
this.$$('settings-about-page'));
}
- if (settings.Route.ADVANCED.contains(route)) {
- return /** @type {?SettingsAdvancedPageElement} */(
- this.$$('settings-advanced-page'));
- }
- if (settings.Route.BASIC.contains(route)) {
+ if (settings.Route.BASIC.contains(route) ||
+ settings.Route.ADVANCED.contains(route)) {
return /** @type {?SettingsBasicPageElement} */(
this.$$('settings-basic-page'));
}
@@ -330,14 +251,8 @@ Polymer({
return new Promise(function(resolve, reject) {
setTimeout(function() {
- var whenSearchDone = settings.getSearchManager().search(
- query, assert(this.getPage_(settings.Route.BASIC)));
-
- if (this.pageVisibility.advancedSettings !== false) {
- assert(whenSearchDone === settings.getSearchManager().search(
- query, assert(this.getPage_(settings.Route.ADVANCED))));
- }
-
+ var whenSearchDone =
+ assert(this.getPage_(settings.Route.BASIC)).searchContents(query);
whenSearchDone.then(function(request) {
resolve();
if (!request.finished) {
@@ -355,13 +270,4 @@ Polymer({
}.bind(this), 0);
}.bind(this));
},
-
- /**
- * @param {(boolean|undefined)} visibility
- * @return {boolean} True unless visibility is false.
- * @private
- */
- showAdvancedSettings_: function(visibility) {
- return visibility !== false;
- },
});

Powered by Google App Engine
This is Rietveld 408576698