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

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

Issue 10828153: Change butter bar message depending on the type of operation and the number of files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix move to GData. Created 8 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 | 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;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 * @private 179 * @private
180 */ 180 */
181 ButterBar.prototype.clearHideTimeout_ = function() { 181 ButterBar.prototype.clearHideTimeout_ = function() {
182 if (this.hideTimeout_) { 182 if (this.hideTimeout_) {
183 clearTimeout(this.hideTimeout_); 183 clearTimeout(this.hideTimeout_);
184 this.hideTimeout_ = null; 184 this.hideTimeout_ = null;
185 } 185 }
186 }; 186 };
187 187
188 /** 188 /**
189 * @private
190 * @return {string?} The type of operation.
191 */
192 ButterBar.prototype.transferType_ = function() {
193 var progress = this.progress_;
194 if (!progress ||
195 progress.pendingMoves === 0 && progress.pendingCopies === 0)
196 return 'TRANSFER';
197
198 if (progress.pendingMoves > 0) {
199 if (progress.pendingCopies > 0)
200 return 'TRANSFER';
201 return 'MOVE';
202 }
203
204 return 'COPY';
205 };
206
207 /**
189 * Set up butter bar for showing copy progress. 208 * Set up butter bar for showing copy progress.
190 * @private 209 * @private
191 */ 210 */
192 ButterBar.prototype.showProgress_ = function() { 211 ButterBar.prototype.showProgress_ = function() {
193 var progress = this.copyManager_.getProgress(); 212 this.progress_ = this.copyManager_.getStatus();
194 var options = {progress: progress.percentage, actions: {}, timeout: 0}; 213 console.log(this.progress_.pendingItems);
Vladislav Kaznacheev 2012/08/03 14:50:10 You probably did not mean to leave this?
Oleg Eterevsky 2012/08/03 14:53:01 Done.
195 options.actions[str('CANCEL_LABEL')] = 214 var options = {progress: this.progress_.percentage, actions: {}, timeout: 0};
196 this.copyManager_.requestCancel.bind(this.copyManager_); 215
197 this.show(strf('PASTE_ITEMS_REMAINING', progress.pendingItems), options); 216 var type = this.transferType_();
217 var progressString = (this.progress_.pendingItems === 1) ?
218 strf(type + '_FILE_NAME', this.progress_.filename) :
219 strf(type + '_ITEMS_REMAINING', this.progress_.pendingItems);
220
221 if (this.isVisible_()) {
222 this.update_(progressString, options);
223 } else {
224 options.actions[str('CANCEL_LABEL')] =
225 this.copyManager_.requestCancel.bind(this.copyManager_);
226 this.show(progressString, options);
227 }
198 }; 228 };
199 229
200 /** 230 /**
201 * 'copy-progress' event handler. Show progress or an appropriate message. 231 * 'copy-progress' event handler. Show progress or an appropriate message.
202 * @private 232 * @private
203 * @param {cr.Event} event A 'copy-progress' event from FileCopyManager. 233 * @param {cr.Event} event A 'copy-progress' event from FileCopyManager.
204 */ 234 */
205 ButterBar.prototype.onCopyProgress_ = function(event) { 235 ButterBar.prototype.onCopyProgress_ = function(event) {
206 var progress = this.copyManager_.getProgress();
207
208 if (event.reason != 'PROGRESS') 236 if (event.reason != 'PROGRESS')
209 this.clearShowTimeout_(); 237 this.clearShowTimeout_();
210 238
211 switch (event.reason) { 239 switch (event.reason) {
212 case 'BEGIN': 240 case 'BEGIN':
213 this.showTimeout_ = setTimeout(function() { 241 this.showTimeout_ = setTimeout(function() {
214 this.showTimeout_ = null; 242 this.showTimeout_ = null;
215 this.showProgress_(); 243 this.showProgress_();
216 }.bind(this), 500); 244 }.bind(this), 500);
217 break; 245 break;
218 246
219 case 'PROGRESS': 247 case 'PROGRESS':
220 if (this.isVisible_()) { 248 this.showProgress_();
221 var options = {'progress': progress.percentage, timeout: 0};
222 this.update_(strf('PASTE_ITEMS_REMAINING', progress.pendingItems),
223 options);
224 }
225 break; 249 break;
226 250
227 case 'SUCCESS': 251 case 'SUCCESS':
228 this.hide_(); 252 this.hide_();
229 break; 253 break;
230 254
231 case 'CANCELLED': 255 case 'CANCELLED':
232 this.show(str('PASTE_CANCELLED'), {timeout: 1000}); 256 this.show(str(this.transferType_() + '_CANCELLED'), {timeout: 1000});
233 break; 257 break;
234 258
235 case 'ERROR': 259 case 'ERROR':
236 if (event.error.reason === 'TARGET_EXISTS') { 260 if (event.error.reason === 'TARGET_EXISTS') {
237 var name = event.error.data.name; 261 var name = event.error.data.name;
238 if (event.error.data.isDirectory) 262 if (event.error.data.isDirectory)
239 name += '/'; 263 name += '/';
240 this.showError_(strf('PASTE_TARGET_EXISTS_ERROR', name)); 264 this.showError_(strf(this.transferType_() +
265 '_TARGET_EXISTS_ERROR', name));
241 } else if (event.error.reason === 'FILESYSTEM_ERROR') { 266 } else if (event.error.reason === 'FILESYSTEM_ERROR') {
242 if (event.error.data.toGDrive && 267 if (event.error.data.toGDrive &&
243 event.error.data.code === FileError.QUOTA_EXCEEDED_ERR) { 268 event.error.data.code === FileError.QUOTA_EXCEEDED_ERR) {
244 // The alert will be shown in FileManager.onCopyProgress_. 269 // The alert will be shown in FileManager.onCopyProgress_.
245 this.hide_(); 270 this.hide_();
246 } else { 271 } else {
247 this.showError_(strf('PASTE_FILESYSTEM_ERROR', 272 this.showError_(strf(this.transferType_() + '_FILESYSTEM_ERROR',
248 getFileErrorString(event.error.data.code))); 273 getFileErrorString(event.error.data.code)));
249 } 274 }
250 } else { 275 } else {
251 this.showError_(strf('PASTE_UNEXPECTED_ERROR', event.error)); 276 this.showError_(strf(this.transferType_() + '_UNEXPECTED_ERROR',
277 event.error));
252 } 278 }
253 break; 279 break;
254 280
255 default: 281 default:
256 console.log('Unknown "copy-progress" event reason: ' + event.reason); 282 console.log('Unknown "copy-progress" event reason: ' + event.reason);
257 } 283 }
258 }; 284 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698