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

Side by Side Diff: ui/file_manager/gallery/js/slide_mode.js

Issue 571453002: Correct indentation, JSDoc, etc... to comply with closure linter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made it more strict. Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Slide mode displays a single image and has a set of controls to navigate 8 * Slide mode displays a single image and has a set of controls to navigate
9 * between the images and to edit an image. 9 * between the images and to edit an image.
10 * 10 *
11 * @param {Element} container Main container element. 11 * @param {Element} container Main container element.
12 * @param {Element} content Content container element. 12 * @param {Element} content Content container element.
13 * @param {Element} toolbar Toolbar element. 13 * @param {Element} toolbar Toolbar element.
14 * @param {ImageEditor.Prompt} prompt Prompt. 14 * @param {ImageEditor.Prompt} prompt Prompt.
15 * @param {cr.ui.ArrayDataModel} dataModel Data model. 15 * @param {cr.ui.ArrayDataModel} dataModel Data model.
16 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. 16 * @param {cr.ui.ListSelectionModel} selectionModel Selection model.
17 * @param {Object} context Context. 17 * @param {Object} context Context.
18 * @param {VolumeManager} volumeManager Volume manager.
18 * @param {function(function())} toggleMode Function to toggle the Gallery mode. 19 * @param {function(function())} toggleMode Function to toggle the Gallery mode.
19 * @param {function(string):string} displayStringFunction String formatting 20 * @param {function(string):string} displayStringFunction String formatting
20 * function. 21 * function.
21 * @constructor 22 * @constructor
22 */ 23 */
23 function SlideMode(container, content, toolbar, prompt, dataModel, 24 function SlideMode(container, content, toolbar, prompt, dataModel,
24 selectionModel, context, volumeManager, toggleMode, displayStringFunction) { 25 selectionModel, context, volumeManager, toggleMode, displayStringFunction) {
25 this.container_ = container; 26 this.container_ = container;
26 this.document_ = container.ownerDocument; 27 this.document_ = container.ownerDocument;
27 this.content = content; 28 this.content = content;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 }; 327 };
327 328
328 /** 329 /**
329 * Leave the mode. 330 * Leave the mode.
330 * @param {Rect} zoomToRect Rectangle for zoom effect. 331 * @param {Rect} zoomToRect Rectangle for zoom effect.
331 * @param {function} callback Called when the image is committed and 332 * @param {function} callback Called when the image is committed and
332 * the zoom-out animation has started. 333 * the zoom-out animation has started.
333 */ 334 */
334 SlideMode.prototype.leave = function(zoomToRect, callback) { 335 SlideMode.prototype.leave = function(zoomToRect, callback) {
335 var commitDone = function() { 336 var commitDone = function() {
336 this.stopEditing_(); 337 this.stopEditing_();
337 this.stopSlideshow_(); 338 this.stopSlideshow_();
338 ImageUtil.setAttribute(this.arrowBox_, 'active', false); 339 ImageUtil.setAttribute(this.arrowBox_, 'active', false);
339 this.selectionModel_.removeEventListener( 340 this.selectionModel_.removeEventListener(
340 'change', this.onSelectionBound_); 341 'change', this.onSelectionBound_);
341 this.dataModel_.removeEventListener('splice', this.onSpliceBound_); 342 this.dataModel_.removeEventListener('splice', this.onSpliceBound_);
342 this.ribbon_.disable(); 343 this.ribbon_.disable();
343 this.active_ = false; 344 this.active_ = false;
344 if (this.savedSelection_) 345 if (this.savedSelection_)
345 this.selectionModel_.selectedIndexes = this.savedSelection_; 346 this.selectionModel_.selectedIndexes = this.savedSelection_;
346 this.unloadImage_(zoomToRect); 347 this.unloadImage_(zoomToRect);
347 callback(); 348 callback();
348 }.bind(this); 349 }.bind(this);
349 350
350 this.viewport_.resetView(); 351 this.viewport_.resetView();
351 if (this.getItemCount_() === 0) { 352 if (this.getItemCount_() === 0) {
352 this.showErrorBanner_(false); 353 this.showErrorBanner_(false);
353 commitDone(); 354 commitDone();
354 } else { 355 } else {
355 this.commitItem_(commitDone); 356 this.commitItem_(commitDone);
356 } 357 }
357 358
358 // Disable the slide-mode only buttons when leaving. 359 // Disable the slide-mode only buttons when leaving.
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 * Max number that the overwrite info bubble is shown. 1025 * Max number that the overwrite info bubble is shown.
1025 * @type {number} 1026 * @type {number}
1026 */ 1027 */
1027 SlideMode.OVERWRITE_BUBBLE_MAX_TIMES = 5; 1028 SlideMode.OVERWRITE_BUBBLE_MAX_TIMES = 5;
1028 1029
1029 /** 1030 /**
1030 * @return {boolean} True if 'Overwrite original' is set. 1031 * @return {boolean} True if 'Overwrite original' is set.
1031 * @private 1032 * @private
1032 */ 1033 */
1033 SlideMode.prototype.shouldOverwriteOriginal_ = function() { 1034 SlideMode.prototype.shouldOverwriteOriginal_ = function() {
1034 return this.overwriteOriginal_.checked; 1035 return this.overwriteOriginal_.checked;
1035 }; 1036 };
1036 1037
1037 /** 1038 /**
1038 * 'Overwrite original' checkbox handler. 1039 * 'Overwrite original' checkbox handler.
1039 * @param {Event} event Event. 1040 * @param {Event} event Event.
1040 * @private 1041 * @private
1041 */ 1042 */
1042 SlideMode.prototype.onOverwriteOriginalClick_ = function(event) { 1043 SlideMode.prototype.onOverwriteOriginalClick_ = function(event) {
1043 util.platform.setPreference(SlideMode.OVERWRITE_KEY, event.target.checked); 1044 util.platform.setPreference(SlideMode.OVERWRITE_KEY, event.target.checked);
1044 }; 1045 };
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 * @param {number=} opt_interval Slideshow interval in ms. 1178 * @param {number=} opt_interval Slideshow interval in ms.
1178 * @private 1179 * @private
1179 */ 1180 */
1180 SlideMode.prototype.scheduleNextSlide_ = function(opt_interval) { 1181 SlideMode.prototype.scheduleNextSlide_ = function(opt_interval) {
1181 console.assert(this.isSlideshowPlaying_(), 'Inconsistent slideshow state'); 1182 console.assert(this.isSlideshowPlaying_(), 'Inconsistent slideshow state');
1182 1183
1183 if (this.slideShowTimeout_) 1184 if (this.slideShowTimeout_)
1184 clearTimeout(this.slideShowTimeout_); 1185 clearTimeout(this.slideShowTimeout_);
1185 1186
1186 this.slideShowTimeout_ = setTimeout(function() { 1187 this.slideShowTimeout_ = setTimeout(function() {
1187 this.slideShowTimeout_ = null; 1188 this.slideShowTimeout_ = null;
1188 this.selectNext(1); 1189 this.selectNext(1);
1189 }.bind(this), 1190 }.bind(this), opt_interval || SlideMode.SLIDESHOW_INTERVAL);
1190 opt_interval || SlideMode.SLIDESHOW_INTERVAL);
1191 }; 1191 };
1192 1192
1193 /** 1193 /**
1194 * Resumes the slideshow. 1194 * Resumes the slideshow.
1195 * @param {number=} opt_interval Slideshow interval in ms. 1195 * @param {number=} opt_interval Slideshow interval in ms.
1196 * @private 1196 * @private
1197 */ 1197 */
1198 SlideMode.prototype.resumeSlideshow_ = function(opt_interval) { 1198 SlideMode.prototype.resumeSlideshow_ = function(opt_interval) {
1199 this.container_.setAttribute('slideshow', 'playing'); 1199 this.container_.setAttribute('slideshow', 'playing');
1200 this.scheduleNextSlide_(opt_interval); 1200 this.scheduleNextSlide_(opt_interval);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 /** 1314 /**
1315 * Touch handlers of the slide mode. 1315 * Touch handlers of the slide mode.
1316 * @param {DOMElement} targetElement Event source. 1316 * @param {DOMElement} targetElement Event source.
1317 * @param {SlideMode} slideMode Slide mode to be operated by the handler. 1317 * @param {SlideMode} slideMode Slide mode to be operated by the handler.
1318 * @constructor 1318 * @constructor
1319 */ 1319 */
1320 function TouchHandler(targetElement, slideMode) { 1320 function TouchHandler(targetElement, slideMode) {
1321 /** 1321 /**
1322 * Event source. 1322 * Event source.
1323 * @type {DOMElement} 1323 * @type {DOMElement}
1324 * @private
1324 */ 1325 */
1325 this.targetElement_ = targetElement; 1326 this.targetElement_ = targetElement;
1326 1327
1327 /** 1328 /**
1328 * Target of touch operations. 1329 * Target of touch operations.
1329 * @type {SlideMode} 1330 * @type {SlideMode}
1330 * @private 1331 * @private
1331 */ 1332 */
1332 this.slideMode_ = slideMode; 1333 this.slideMode_ = slideMode;
1333 1334
1334 /** 1335 /**
1335 * Flag to enable/disable touch operation. 1336 * Flag to enable/disable touch operation.
1336 * @type {boolean} 1337 * @type {boolean}
1338 * @private
1337 */ 1339 */
1338 this.enabled_ = true; 1340 this.enabled_ = true;
1339 1341
1340 /** 1342 /**
1341 * Whether it is in a touch operation that is started from targetElement or 1343 * Whether it is in a touch operation that is started from targetElement or
1342 * not. 1344 * not.
1343 * @type {boolean} 1345 * @type {boolean}
1344 * @private 1346 * @private
1345 */ 1347 */
1346 this.touchStarted_ = false; 1348 this.touchStarted_ = false;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 TouchHandler.prototype.onMouseWheel_ = function(event) { 1568 TouchHandler.prototype.onMouseWheel_ = function(event) {
1567 var viewport = this.slideMode_.getViewport(); 1569 var viewport = this.slideMode_.getViewport();
1568 if (!this.enabled_ || !viewport.isZoomed()) 1570 if (!this.enabled_ || !viewport.isZoomed())
1569 return; 1571 return;
1570 this.stopOperation(); 1572 this.stopOperation();
1571 viewport.setOffset( 1573 viewport.setOffset(
1572 viewport.getOffsetX() + event.wheelDeltaX, 1574 viewport.getOffsetX() + event.wheelDeltaX,
1573 viewport.getOffsetY() + event.wheelDeltaY); 1575 viewport.getOffsetY() + event.wheelDeltaY);
1574 this.slideMode_.applyViewportChange(); 1576 this.slideMode_.applyViewportChange();
1575 }; 1577 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698