OLD | NEW |
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 * FileManager constructor. | 6 * FileManager constructor. |
7 * | 7 * |
8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 var self = this; | 431 var self = this; |
432 dm.addEventListener('begin-update-files', function() { | 432 dm.addEventListener('begin-update-files', function() { |
433 self.currentList_.startBatchUpdates(); | 433 self.currentList_.startBatchUpdates(); |
434 }); | 434 }); |
435 dm.addEventListener('end-update-files', function() { | 435 dm.addEventListener('end-update-files', function() { |
436 self.restoreItemBeingRenamed_(); | 436 self.restoreItemBeingRenamed_(); |
437 self.currentList_.endBatchUpdates(); | 437 self.currentList_.endBatchUpdates(); |
438 }); | 438 }); |
439 dm.addEventListener('scan-started', this.showSpinnerLater_.bind(this)); | 439 dm.addEventListener('scan-started', this.showSpinnerLater_.bind(this)); |
440 dm.addEventListener('scan-completed', this.showSpinner_.bind(this, false)); | 440 dm.addEventListener('scan-completed', this.showSpinner_.bind(this, false)); |
| 441 dm.addEventListener('scan-cancelled', this.hideSpinnerLater_.bind(this)); |
441 dm.addEventListener('scan-completed', | 442 dm.addEventListener('scan-completed', |
442 this.refreshCurrentDirectoryMetadata_.bind(this)); | 443 this.refreshCurrentDirectoryMetadata_.bind(this)); |
443 dm.addEventListener('rescan-completed', | 444 dm.addEventListener('rescan-completed', |
444 this.refreshCurrentDirectoryMetadata_.bind(this)); | 445 this.refreshCurrentDirectoryMetadata_.bind(this)); |
445 this.addEventListener('selection-summarized', | 446 this.addEventListener('selection-summarized', |
446 this.onSelectionSummarized_.bind(this)); | 447 this.onSelectionSummarized_.bind(this)); |
447 | 448 |
448 this.summarizeSelection_(); | 449 this.summarizeSelection_(); |
449 | 450 |
450 this.setupCurrentDirectory_(true /* page loading */); | 451 this.setupCurrentDirectory_(true /* page loading */); |
(...skipping 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3228 this.showSpinnerTimeout_ = null; | 3229 this.showSpinnerTimeout_ = null; |
3229 } | 3230 } |
3230 }; | 3231 }; |
3231 | 3232 |
3232 FileManager.prototype.showSpinnerLater_ = function() { | 3233 FileManager.prototype.showSpinnerLater_ = function() { |
3233 this.cancelSpinnerTimeout_(); | 3234 this.cancelSpinnerTimeout_(); |
3234 this.showSpinnerTimeout_ = | 3235 this.showSpinnerTimeout_ = |
3235 setTimeout(this.showSpinner_.bind(this, true), 500); | 3236 setTimeout(this.showSpinner_.bind(this, true), 500); |
3236 }; | 3237 }; |
3237 | 3238 |
| 3239 FileManager.prototype.hideSpinnerLater_ = function() { |
| 3240 setTimeout(this.showSpinner_.bind(this, false), 100); |
| 3241 }; |
| 3242 |
3238 FileManager.prototype.showSpinner_ = function(on) { | 3243 FileManager.prototype.showSpinner_ = function(on) { |
3239 this.cancelSpinnerTimeout_(); | 3244 if (on && this.directoryModel_ && this.directoryModel_.isScanning()) { |
3240 if (on) { | |
3241 if (this.directoryModel_.isSearching()) { | 3245 if (this.directoryModel_.isSearching()) { |
3242 this.dialogContainer_.classList.add('searching'); | 3246 this.dialogContainer_.classList.add('searching'); |
| 3247 this.spinner_.style.display = 'none'; |
3243 } else { | 3248 } else { |
3244 this.spinner_.style.display = ''; | 3249 this.spinner_.style.display = ''; |
| 3250 this.dialogContainer_.classList.remove('searching'); |
3245 } | 3251 } |
3246 } else { | 3252 } |
| 3253 |
| 3254 if (!on && (!this.directoryModel_ || !this.directoryModel_.isScanning())) { |
3247 this.spinner_.style.display = 'none'; | 3255 this.spinner_.style.display = 'none'; |
3248 if (this.dialogContainer_) | 3256 if (this.dialogContainer_) |
3249 this.dialogContainer_.classList.remove('searching'); | 3257 this.dialogContainer_.classList.remove('searching'); |
3250 } | 3258 } |
3251 }; | 3259 }; |
3252 | 3260 |
3253 FileManager.prototype.onNewFolderCommand_ = function(event) { | 3261 FileManager.prototype.onNewFolderCommand_ = function(event) { |
3254 var defaultName = str('DEFAULT_NEW_FOLDER_NAME'); | 3262 var defaultName = str('DEFAULT_NEW_FOLDER_NAME'); |
3255 | 3263 |
3256 // Find a name that doesn't exist in the data model. | 3264 // Find a name that doesn't exist in the data model. |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4180 } | 4188 } |
4181 | 4189 |
4182 var defaultActionSeparator = | 4190 var defaultActionSeparator = |
4183 this.dialogDom_.querySelector('#default-action-separator'); | 4191 this.dialogDom_.querySelector('#default-action-separator'); |
4184 | 4192 |
4185 this.defaultActionMenuItem_.hidden = !taskItem; | 4193 this.defaultActionMenuItem_.hidden = !taskItem; |
4186 defaultActionSeparator.hidden = !taskItem; | 4194 defaultActionSeparator.hidden = !taskItem; |
4187 } | 4195 } |
4188 })(); | 4196 })(); |
4189 | 4197 |
OLD | NEW |