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

Unified Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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_page/main_page_behavior.js
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.js b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
index 6a02acd2c1b1bec4034f905809b4b105720fb183..a2c1a30bf848612c15c2b186659abe02178e1af6 100644
--- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js
+++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
@@ -30,7 +30,7 @@ var MainPageBehaviorImpl = {
if (this.domHost && this.domHost.parentNode.tagName == 'PAPER-HEADER-PANEL')
this.scroller = this.domHost.parentNode.scroller;
else
- this.scroller = document.body; // Used in unit tests.
+ this.scroller = document.body; // Used in unit tests.
},
/**
@@ -38,9 +38,8 @@ var MainPageBehaviorImpl = {
* @param {settings.Route} oldRoute
*/
currentRouteChanged: function(newRoute, oldRoute) {
- var oldRouteWasSection =
- !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
- oldRoute.parent.section != oldRoute.section;
+ var oldRouteWasSection = !!oldRoute && !!oldRoute.parent &&
+ !!oldRoute.section && oldRoute.parent.section != oldRoute.section;
// Always scroll to the top if navigating from a section to the root route.
if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
@@ -50,9 +49,8 @@ var MainPageBehaviorImpl = {
// Scroll to the section except for back/forward. Also scroll for any
// in-page back/forward navigations (from a section or the root page).
- var scrollToSection =
- !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
- oldRoute == settings.Route.BASIC;
+ var scrollToSection = !settings.lastRouteChangeWasPopstate() ||
+ oldRouteWasSection || oldRoute == settings.Route.BASIC;
// For previously uncreated pages (including on first load), allow the page
// to render before scrolling to or expanding the section.
@@ -97,7 +95,7 @@ var MainPageBehaviorImpl = {
}
var promise;
- var expandedSection = /** @type {?SettingsSectionElement} */(
+ var expandedSection = /** @type {?SettingsSectionElement} */ (
this.$$('settings-section.expanded'));
if (expandedSection) {
// If the section shouldn't be expanded, collapse it.
@@ -128,7 +126,7 @@ var MainPageBehaviorImpl = {
*/
maybeStopCurrentAnimation_: function() {
var currentRoute = settings.getCurrentRoute();
- var animatingSection = /** @type {?SettingsSectionElement} */(
+ var animatingSection = /** @type {?SettingsSectionElement} */ (
this.$$('settings-section.expanding, settings-section.collapsing'));
assert(animatingSection);
@@ -185,27 +183,32 @@ var MainPageBehaviorImpl = {
this.currentAnimation_ = section.animateExpand(this.scroller);
var finished;
- return this.currentAnimation_.finished.then(function() {
- // Hide other sections and scroll to the top of the subpage.
- this.classList.add('showing-subpage');
- this.toggleOtherSectionsHidden_(section.section, true);
- this.scroller.scrollTop = 0;
- section.setFrozen(false);
-
- // Notify that the page is fully expanded.
- this.fire('subpage-expand');
-
- finished = true;
- }.bind(this), function() {
- // The animation was canceled; restore the section and scroll position.
- section.setFrozen(false);
- this.scroller.scrollTop = this.origScrollTop_;
-
- finished = false;
- }.bind(this)).then(function() {
- this.fire('freeze-scroll', false);
- this.currentAnimation_ = null;
- }.bind(this));
+ return this.currentAnimation_.finished
+ .then(
+ function() {
+ // Hide other sections and scroll to the top of the subpage.
+ this.classList.add('showing-subpage');
+ this.toggleOtherSectionsHidden_(section.section, true);
+ this.scroller.scrollTop = 0;
+ section.setFrozen(false);
+
+ // Notify that the page is fully expanded.
+ this.fire('subpage-expand');
+
+ finished = true;
+ }.bind(this),
+ function() {
+ // The animation was canceled; restore the section and scroll
+ // position.
+ section.setFrozen(false);
+ this.scroller.scrollTop = this.origScrollTop_;
+
+ finished = false;
+ }.bind(this))
+ .then(function() {
+ this.fire('freeze-scroll', false);
+ this.currentAnimation_ = null;
+ }.bind(this));
},
/**
@@ -259,19 +262,22 @@ var MainPageBehaviorImpl = {
this.scroller.scrollTop = this.origScrollTop_;
this.currentAnimation_ = section.animateCollapse(
- /** @type {!HTMLElement} */(this.scroller));
-
- this.currentAnimation_.finished.catch(function() {
- // The collapse was canceled, so the page is showing a subpage still.
- this.fire('subpage-expand');
- }.bind(this)).then(function() {
- // Clean up after the animation succeeds or cancels.
- section.setFrozen(false);
- section.classList.remove('collapsing');
- this.fire('freeze-scroll', false);
- this.currentAnimation_ = null;
- resolve();
- }.bind(this));
+ /** @type {!HTMLElement} */ (this.scroller));
+
+ this.currentAnimation_.finished
+ .catch(function() {
+ // The collapse was canceled, so the page is showing a subpage
+ // still.
+ this.fire('subpage-expand');
+ }.bind(this))
+ .then(function() {
+ // Clean up after the animation succeeds or cancels.
+ section.setFrozen(false);
+ section.classList.remove('collapsing');
+ this.fire('freeze-scroll', false);
+ this.currentAnimation_ = null;
+ resolve();
+ }.bind(this));
}.bind(this));
}.bind(this));
},
@@ -284,8 +290,7 @@ var MainPageBehaviorImpl = {
* @private
*/
toggleOtherSectionsHidden_: function(sectionName, hidden) {
- var sections = Polymer.dom(this.root).querySelectorAll(
- 'settings-section');
+ var sections = Polymer.dom(this.root).querySelectorAll('settings-section');
for (var section of sections)
section.hidden = hidden && (section.section != sectionName);
},
@@ -298,7 +303,7 @@ var MainPageBehaviorImpl = {
getSection: function(section) {
if (!section)
return null;
- return /** @type {?SettingsSectionElement} */(
+ return /** @type {?SettingsSectionElement} */ (
this.$$('settings-section[section="' + section + '"]'));
},
};

Powered by Google App Engine
This is Rietveld 408576698