| 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 3439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 var selectAllCheckbox = | 3450 var selectAllCheckbox = |
| 3451 this.document_.getElementById('select-all-checkbox'); | 3451 this.document_.getElementById('select-all-checkbox'); |
| 3452 if (selectAllCheckbox) | 3452 if (selectAllCheckbox) |
| 3453 this.updateSelectAllCheckboxState_(selectAllCheckbox); | 3453 this.updateSelectAllCheckboxState_(selectAllCheckbox); |
| 3454 }; | 3454 }; |
| 3455 | 3455 |
| 3456 FileManager.prototype.updateOkButton_ = function(event) { | 3456 FileManager.prototype.updateOkButton_ = function(event) { |
| 3457 var selectable; | 3457 var selectable; |
| 3458 | 3458 |
| 3459 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { | 3459 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) { |
| 3460 selectable = this.selection.directoryCount == 1 && | 3460 // In SELECT_FOLDER mode, we allow to select current directory |
| 3461 // when nothing is selected. |
| 3462 selectable = this.selection.directoryCount <= 1 && |
| 3461 this.selection.fileCount == 0; | 3463 this.selection.fileCount == 0; |
| 3462 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { | 3464 } else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) { |
| 3463 selectable = (this.isSelectionAvailable() && | 3465 selectable = (this.isSelectionAvailable() && |
| 3464 this.selection.directoryCount == 0 && | 3466 this.selection.directoryCount == 0 && |
| 3465 this.selection.fileCount == 1); | 3467 this.selection.fileCount == 1); |
| 3466 } else if (this.dialogType_ == | 3468 } else if (this.dialogType_ == |
| 3467 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) { | 3469 FileManager.DialogType.SELECT_OPEN_MULTI_FILE) { |
| 3468 selectable = (this.isSelectionAvailable() && | 3470 selectable = (this.isSelectionAvailable() && |
| 3469 this.selection.directoryCount == 0 && | 3471 this.selection.directoryCount == 0 && |
| 3470 this.selection.fileCount >= 1); | 3472 this.selection.fileCount >= 1); |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4285 } | 4287 } |
| 4286 | 4288 |
| 4287 this.resolvePath(this.getCurrentDirectory() + '/' + filename, | 4289 this.resolvePath(this.getCurrentDirectory() + '/' + filename, |
| 4288 resolveCallback, resolveCallback); | 4290 resolveCallback, resolveCallback); |
| 4289 return; | 4291 return; |
| 4290 } | 4292 } |
| 4291 | 4293 |
| 4292 var files = []; | 4294 var files = []; |
| 4293 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes; | 4295 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes; |
| 4294 | 4296 |
| 4297 if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER && |
| 4298 selectedIndexes.length == 0) { |
| 4299 var url = this.getSearchOrCurrentDirectoryURL(); |
| 4300 var singleSelection = { |
| 4301 urls: [url], |
| 4302 multiple: false, |
| 4303 filterIndex: this.getSelectedFilterIndex_(url) |
| 4304 }; |
| 4305 this.selectFilesAndClose_(singleSelection); |
| 4306 return; |
| 4307 } |
| 4308 |
| 4295 // All other dialog types require at least one selected list item. | 4309 // All other dialog types require at least one selected list item. |
| 4296 // The logic to control whether or not the ok button is enabled should | 4310 // The logic to control whether or not the ok button is enabled should |
| 4297 // prevent us from ever getting here, but we sanity check to be sure. | 4311 // prevent us from ever getting here, but we sanity check to be sure. |
| 4298 if (!selectedIndexes.length) | 4312 if (!selectedIndexes.length) |
| 4299 throw new Error('Nothing selected!'); | 4313 throw new Error('Nothing selected!'); |
| 4300 | 4314 |
| 4301 var dm = this.directoryModel_.getFileList(); | 4315 var dm = this.directoryModel_.getFileList(); |
| 4302 for (var i = 0; i < selectedIndexes.length; i++) { | 4316 for (var i = 0; i < selectedIndexes.length; i++) { |
| 4303 var entry = dm.item(selectedIndexes[i]); | 4317 var entry = dm.item(selectedIndexes[i]); |
| 4304 if (!entry) { | 4318 if (!entry) { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4627 function closeBanner() { | 4641 function closeBanner() { |
| 4628 self.cleanupGDataWelcome_(); | 4642 self.cleanupGDataWelcome_(); |
| 4629 // Stop showing the welcome banner. | 4643 // Stop showing the welcome banner. |
| 4630 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; | 4644 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; |
| 4631 } | 4645 } |
| 4632 | 4646 |
| 4633 return maybeShowBanner; | 4647 return maybeShowBanner; |
| 4634 }; | 4648 }; |
| 4635 })(); | 4649 })(); |
| 4636 | 4650 |
| OLD | NEW |