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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2984843003: MD Settings: Convert all usages of .bind(this) to use ES6 arrow function. (Closed)
Patch Set: Resolve conflicts. Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @typedef {{about: boolean, settings: boolean}} 6 * @typedef {{about: boolean, settings: boolean}}
7 */ 7 */
8 var MainPageVisibility; 8 var MainPageVisibility;
9 9
10 /** 10 /**
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 this.unlisten(this, 'freeze-scroll', 'onFreezeScroll_'); 100 this.unlisten(this, 'freeze-scroll', 'onFreezeScroll_');
101 }, 101 },
102 102
103 /** @private */ 103 /** @private */
104 overscrollChanged_: function() { 104 overscrollChanged_: function() {
105 if (!this.overscroll_ && this.boundScroll_) { 105 if (!this.overscroll_ && this.boundScroll_) {
106 this.offsetParent.removeEventListener('scroll', this.boundScroll_); 106 this.offsetParent.removeEventListener('scroll', this.boundScroll_);
107 window.removeEventListener('resize', this.boundScroll_); 107 window.removeEventListener('resize', this.boundScroll_);
108 this.boundScroll_ = null; 108 this.boundScroll_ = null;
109 } else if (this.overscroll_ && !this.boundScroll_) { 109 } else if (this.overscroll_ && !this.boundScroll_) {
110 this.boundScroll_ = function() { 110 this.boundScroll_ = () => {
111 if (!this.ignoreScroll_) 111 if (!this.ignoreScroll_)
112 this.setOverscroll_(0); 112 this.setOverscroll_(0);
113 }.bind(this); 113 };
114 this.offsetParent.addEventListener('scroll', this.boundScroll_); 114 this.offsetParent.addEventListener('scroll', this.boundScroll_);
115 window.addEventListener('resize', this.boundScroll_); 115 window.addEventListener('resize', this.boundScroll_);
116 } 116 }
117 }, 117 },
118 118
119 /** 119 /**
120 * Sets the overscroll padding. Never forces a scroll, i.e., always leaves 120 * Sets the overscroll padding. Never forces a scroll, i.e., always leaves
121 * any currently visible overflow as-is. 121 * any currently visible overflow as-is.
122 * @param {number=} opt_minHeight The minimum overscroll height needed. 122 * @param {number=} opt_minHeight The minimum overscroll height needed.
123 * @private 123 * @private
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 * @private 177 * @private
178 */ 178 */
179 updatePagesShown_: function() { 179 updatePagesShown_: function() {
180 var inAbout = settings.routes.ABOUT.contains(settings.getCurrentRoute()); 180 var inAbout = settings.routes.ABOUT.contains(settings.getCurrentRoute());
181 this.showPages_ = {about: inAbout, settings: !inAbout}; 181 this.showPages_ = {about: inAbout, settings: !inAbout};
182 182
183 // Calculate and set the overflow padding. 183 // Calculate and set the overflow padding.
184 this.updateOverscrollForPage_(); 184 this.updateOverscrollForPage_();
185 185
186 // Wait for any other changes, then calculate the overflow padding again. 186 // Wait for any other changes, then calculate the overflow padding again.
187 setTimeout(function() { 187 setTimeout(() => {
188 // Ensure any dom-if reflects the current properties. 188 // Ensure any dom-if reflects the current properties.
189 Polymer.dom.flush(); 189 Polymer.dom.flush();
190 this.updateOverscrollForPage_(); 190 this.updateOverscrollForPage_();
191 }.bind(this)); 191 });
192 }, 192 },
193 193
194 /** 194 /**
195 * Calculates the necessary overscroll and sets the overscroll to that value 195 * Calculates the necessary overscroll and sets the overscroll to that value
196 * (at minimum). For the About page, this just zeroes the overscroll. 196 * (at minimum). For the About page, this just zeroes the overscroll.
197 * @private 197 * @private
198 */ 198 */
199 updateOverscrollForPage_: function() { 199 updateOverscrollForPage_: function() {
200 if (this.showPages_.about || this.inSearchMode_) { 200 if (this.showPages_.about || this.inSearchMode_) {
201 // Set overscroll directly to remove any existing overscroll that 201 // Set overscroll directly to remove any existing overscroll that
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 /** 253 /**
254 * @param {string} query 254 * @param {string} query
255 * @return {!Promise} A promise indicating that searching finished. 255 * @return {!Promise} A promise indicating that searching finished.
256 */ 256 */
257 searchContents: function(query) { 257 searchContents: function(query) {
258 // Trigger rendering of the basic and advanced pages and search once ready. 258 // Trigger rendering of the basic and advanced pages and search once ready.
259 this.inSearchMode_ = true; 259 this.inSearchMode_ = true;
260 this.toolbarSpinnerActive = true; 260 this.toolbarSpinnerActive = true;
261 261
262 return new Promise(function(resolve, reject) { 262 return new Promise((resolve, reject) => {
263 setTimeout(function() { 263 setTimeout(() => {
264 var whenSearchDone = 264 var whenSearchDone =
265 assert(this.getPage_(settings.routes.BASIC)).searchContents(query); 265 assert(this.getPage_(settings.routes.BASIC)).searchContents(query);
266 whenSearchDone.then(function(result) { 266 whenSearchDone.then(result => {
267 resolve(); 267 resolve();
268 if (result.canceled) { 268 if (result.canceled) {
269 // Nothing to do here. A previous search request was canceled 269 // Nothing to do here. A previous search request was canceled
270 // because a new search request was issued with a different query 270 // because a new search request was issued with a different query
271 // before the previous completed. 271 // before the previous completed.
272 return; 272 return;
273 } 273 }
274 274
275 this.toolbarSpinnerActive = false; 275 this.toolbarSpinnerActive = false;
276 this.inSearchMode_ = !result.wasClearSearch; 276 this.inSearchMode_ = !result.wasClearSearch;
277 this.showNoResultsFound_ = 277 this.showNoResultsFound_ =
278 this.inSearchMode_ && !result.didFindMatches; 278 this.inSearchMode_ && !result.didFindMatches;
279 279
280 if (this.inSearchMode_) { 280 if (this.inSearchMode_) {
281 Polymer.IronA11yAnnouncer.requestAvailability(); 281 Polymer.IronA11yAnnouncer.requestAvailability();
282 this.fire('iron-announce', { 282 this.fire('iron-announce', {
283 text: this.showNoResultsFound_ ? 283 text: this.showNoResultsFound_ ?
284 loadTimeData.getString('searchNoResults') : 284 loadTimeData.getString('searchNoResults') :
285 loadTimeData.getStringF('searchResults', query) 285 loadTimeData.getStringF('searchResults', query)
286 }); 286 });
287 } 287 }
288 }.bind(this)); 288 });
289 }.bind(this), 0); 289 }, 0);
290 }.bind(this)); 290 });
291 }, 291 },
292 }); 292 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698