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

Side by Side Diff: chrome/browser/resources/file_manager/js/butter_bar.js

Issue 12212187: [Cleanup] Files.app: Misc style fixes in Javascript code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * The minimum about of time to display the butter bar for, in ms. 6 * The minimum about of time to display the butter bar for, in ms.
7 * Justification is 1000ms for minimum display time plus 300ms for transition 7 * Justification is 1000ms for minimum display time plus 300ms for transition
8 * duration. 8 * duration.
9 */ 9 */
10 var MINIMUM_BUTTER_DISPLAY_TIME_MS = 1300; 10 var MINIMUM_BUTTER_DISPLAY_TIME_MS = 1300;
11 11
12 /** 12 /**
13 * Butter bar is shown on top of the file list and is used to show the copy 13 * Butter bar is shown on top of the file list and is used to show the copy
14 * progress and other messages. 14 * progress and other messages.
15 * @constructor
16 * @param {HTMLElement} dialogDom FileManager top-level div. 15 * @param {HTMLElement} dialogDom FileManager top-level div.
17 * @param {FileCopyManagerWrapper} copyManager The copy manager. 16 * @param {FileCopyManagerWrapper} copyManager The copy manager.
18 * @param {MetadataCache} metadataCache The metadata cache. 17 * @param {MetadataCache} metadataCache The metadata cache.
18 * @constructor
19 */ 19 */
20 function ButterBar(dialogDom, copyManager, metadataCache) { 20 function ButterBar(dialogDom, copyManager, metadataCache) {
21 this.dialogDom_ = dialogDom; 21 this.dialogDom_ = dialogDom;
22 this.butter_ = this.dialogDom_.querySelector('#butter-bar'); 22 this.butter_ = this.dialogDom_.querySelector('#butter-bar');
23 this.document_ = this.butter_.ownerDocument; 23 this.document_ = this.butter_.ownerDocument;
24 this.copyManager_ = copyManager; 24 this.copyManager_ = copyManager;
25 this.metadataCache_ = metadataCache; 25 this.metadataCache_ = metadataCache;
26 this.hideTimeout_ = null; 26 this.hideTimeout_ = null;
27 this.showTimeout_ = null; 27 this.showTimeout_ = null;
28 this.lastShowTime_ = 0; 28 this.lastShowTime_ = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 this.butter_.querySelector('.progress-bar').hidden = 89 this.butter_.querySelector('.progress-bar').hidden =
90 !(opt_options && 'progress' in opt_options); 90 !(opt_options && 'progress' in opt_options);
91 91
92 this.butter_.classList.remove('error'); 92 this.butter_.classList.remove('error');
93 this.butter_.classList.remove('visible'); // Will be shown in update_ 93 this.butter_.classList.remove('visible'); // Will be shown in update_
94 this.update_(message, opt_options); 94 this.update_(message, opt_options);
95 }; 95 };
96 96
97 /** 97 /**
98 * Show error message in butter bar. 98 * Show error message in butter bar.
99 * @private
100 * @param {string} message Message. 99 * @param {string} message Message.
101 * @param {object} opt_options Same as in show(). 100 * @param {object} opt_options Same as in show().
101 * @private
102 */ 102 */
103 ButterBar.prototype.showError_ = function(message, opt_options) { 103 ButterBar.prototype.showError_ = function(message, opt_options) {
104 this.show(message, opt_options); 104 this.show(message, opt_options);
105 this.butter_.classList.add('error'); 105 this.butter_.classList.add('error');
106 }; 106 };
107 107
108 /** 108 /**
109 * Set message and/or progress. 109 * Set message and/or progress.
110 * @private
111 * @param {string} message Message. 110 * @param {string} message Message.
112 * @param {object} opt_options Same as in show(). 111 * @param {object} opt_options Same as in show().
112 * @private
113 */ 113 */
114 ButterBar.prototype.update_ = function(message, opt_options) { 114 ButterBar.prototype.update_ = function(message, opt_options) {
115 if (!opt_options) 115 if (!opt_options)
116 opt_options = {}; 116 opt_options = {};
117 117
118 this.clearHideTimeout_(); 118 this.clearHideTimeout_();
119 119
120 var timeout = ('timeout' in opt_options) ? opt_options.timeout : 10 * 1000; 120 var timeout = ('timeout' in opt_options) ? opt_options.timeout : 10 * 1000;
121 if (timeout) { 121 if (timeout) {
122 this.hideTimeout_ = setTimeout(function() { 122 this.hideTimeout_ = setTimeout(function() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 * @private 197 * @private
198 */ 198 */
199 ButterBar.prototype.clearHideTimeout_ = function() { 199 ButterBar.prototype.clearHideTimeout_ = function() {
200 if (this.hideTimeout_) { 200 if (this.hideTimeout_) {
201 clearTimeout(this.hideTimeout_); 201 clearTimeout(this.hideTimeout_);
202 this.hideTimeout_ = null; 202 this.hideTimeout_ = null;
203 } 203 }
204 }; 204 };
205 205
206 /** 206 /**
207 * @return {string?} The type of operation.
207 * @private 208 * @private
208 * @return {string?} The type of operation.
209 */ 209 */
210 ButterBar.prototype.transferType_ = function() { 210 ButterBar.prototype.transferType_ = function() {
211 var progress = this.progress_; 211 var progress = this.progress_;
212 if (!progress) 212 if (!progress)
213 return 'TRANSFER'; 213 return 'TRANSFER';
214 214
215 var pendingTransferTypesCount = 215 var pendingTransferTypesCount =
216 (progress.pendingMoves === 0 ? 0 : 1) + 216 (progress.pendingMoves === 0 ? 0 : 1) +
217 (progress.pendingCopies === 0 ? 0 : 1) + 217 (progress.pendingCopies === 0 ? 0 : 1) +
218 (progress.pendingZips === 0 ? 0 : 1); 218 (progress.pendingZips === 0 ? 0 : 1);
(...skipping 25 matching lines...) Expand all
244 this.update_(progressString, options); 244 this.update_(progressString, options);
245 } else { 245 } else {
246 options.actions[ButterBar.ACTION_X] = 246 options.actions[ButterBar.ACTION_X] =
247 this.copyManager_.requestCancel.bind(this.copyManager_); 247 this.copyManager_.requestCancel.bind(this.copyManager_);
248 this.show(progressString, options); 248 this.show(progressString, options);
249 } 249 }
250 }; 250 };
251 251
252 /** 252 /**
253 * 'copy-progress' event handler. Show progress or an appropriate message. 253 * 'copy-progress' event handler. Show progress or an appropriate message.
254 * @param {cr.Event} event A 'copy-progress' event from FileCopyManager.
254 * @private 255 * @private
255 * @param {cr.Event} event A 'copy-progress' event from FileCopyManager.
256 */ 256 */
257 ButterBar.prototype.onCopyProgress_ = function(event) { 257 ButterBar.prototype.onCopyProgress_ = function(event) {
258 // Delete operation has higher priority. 258 // Delete operation has higher priority.
259 if (this.deleteTaskId_) return; 259 if (this.deleteTaskId_) return;
260 260
261 if (event.reason != 'PROGRESS') 261 if (event.reason != 'PROGRESS')
262 this.clearShowTimeout_(); 262 this.clearShowTimeout_();
263 263
264 switch (event.reason) { 264 switch (event.reason) {
265 case 'BEGIN': 265 case 'BEGIN':
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 * @return {boolean} Whether there was a delete task. 346 * @return {boolean} Whether there was a delete task.
347 */ 347 */
348 ButterBar.prototype.forceDeleteAndHide = function() { 348 ButterBar.prototype.forceDeleteAndHide = function() {
349 var result = this.forceDelete_(); 349 var result = this.forceDelete_();
350 if (result) this.hide_(); 350 if (result) this.hide_();
351 return result; 351 return result;
352 }; 352 };
353 353
354 /** 354 /**
355 * 'delete' event handler. Shows information about deleting files. 355 * 'delete' event handler. Shows information about deleting files.
356 * @param {cr.Event} event A 'delete' event from FileCopyManager.
356 * @private 357 * @private
357 * @param {cr.Event} event A 'delete' event from FileCopyManager.
358 */ 358 */
359 ButterBar.prototype.onDelete_ = function(event) { 359 ButterBar.prototype.onDelete_ = function(event) {
360 if (event.id != this.deleteTaskId_) return; 360 if (event.id != this.deleteTaskId_) return;
361 361
362 switch (event.reason) { 362 switch (event.reason) {
363 case 'SCHEDULED': 363 case 'SCHEDULED':
364 var props = []; 364 var props = [];
365 for (var i = 0; i < event.urls.length; i++) { 365 for (var i = 0; i < event.urls.length; i++) {
366 props[i] = {deleted: true}; 366 props[i] = {deleted: true};
367 } 367 }
(...skipping 28 matching lines...) Expand all
396 } 396 }
397 }; 397 };
398 398
399 /** 399 /**
400 * Undo the delete operation. 400 * Undo the delete operation.
401 * @private 401 * @private
402 */ 402 */
403 ButterBar.prototype.undoDelete_ = function() { 403 ButterBar.prototype.undoDelete_ = function() {
404 this.copyManager_.cancelDeleteTask(this.deleteTaskId_); 404 this.copyManager_.cancelDeleteTask(this.deleteTaskId_);
405 }; 405 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698