Index: ui/file_manager/file_manager/foreground/js/file_selection.js |
diff --git a/ui/file_manager/file_manager/foreground/js/file_selection.js b/ui/file_manager/file_manager/foreground/js/file_selection.js |
index 409ad34241ea137c26a3cac5bdad682ae53f58cf..cee1cdc80d1686a0002edf3e0b39efbbbca1b07d 100644 |
--- a/ui/file_manager/file_manager/foreground/js/file_selection.js |
+++ b/ui/file_manager/file_manager/foreground/js/file_selection.js |
@@ -19,12 +19,6 @@ function FileSelection(fileManager, indexes) { |
this.fileManager_ = fileManager; |
/** |
- * @type {number} |
- * @private |
- */ |
- this.computeBytesSequence_ = 0; |
- |
- /** |
* @type {!Array.<number>} |
* @const |
*/ |
@@ -52,16 +46,6 @@ function FileSelection(fileManager, indexes) { |
this.directoryCount = 0; |
/** |
- * @type {number} |
- */ |
- this.bytes = 0; |
- |
- /** |
- * @type {boolean} |
- */ |
- this.showBytes = false; |
- |
- /** |
* @type {boolean} |
*/ |
this.allDriveFilesPresent = false; |
@@ -73,11 +57,6 @@ function FileSelection(fileManager, indexes) { |
/** |
* @type {boolean} |
- */ |
- this.bytesKnown = false; |
- |
- /** |
- * @type {boolean} |
* @private |
*/ |
this.mustBeHidden_ = false; |
@@ -155,69 +134,6 @@ FileSelection.prototype.completeInit = function() { |
}; |
/** |
- * Computes the total size of selected files. |
- * |
- * @param {function()} callback Completion callback. Not called when cancelled, |
- * or a new call has been invoked in the meantime. |
- */ |
-FileSelection.prototype.computeBytes = function(callback) { |
- if (this.entries.length == 0) { |
- this.bytesKnown = true; |
- this.showBytes = false; |
- this.bytes = 0; |
- return; |
- } |
- |
- var computeBytesSequence = ++this.computeBytesSequence_; |
- var pendingMetadataCount = 0; |
- |
- var maybeDone = function() { |
- if (pendingMetadataCount == 0) { |
- this.bytesKnown = true; |
- callback(); |
- } |
- }.bind(this); |
- |
- var onProps = function(properties) { |
- // Ignore if the call got cancelled, or there is another new one fired. |
- if (computeBytesSequence != this.computeBytesSequence_) |
- return; |
- |
- // It may happen that the metadata is not available because a file has been |
- // deleted in the meantime. |
- if (properties) |
- this.bytes += properties.size; |
- pendingMetadataCount--; |
- maybeDone(); |
- }.bind(this); |
- |
- for (var index = 0; index < this.entries.length; index++) { |
- var entry = this.entries[index]; |
- if (entry.isFile) { |
- this.showBytes |= !FileType.isHosted(entry); |
- pendingMetadataCount++; |
- this.fileManager_.metadataCache_.getOne(entry, 'filesystem', onProps); |
- } else if (entry.isDirectory) { |
- // Don't compute the directory size as it's expensive. |
- // crbug.com/179073. |
- this.showBytes = false; |
- break; |
- } |
- } |
- maybeDone(); |
-}; |
- |
-/** |
- * Cancels any async computation by increasing the sequence number. Results |
- * of any previous call to computeBytes() will be discarded. |
- * |
- * @private |
- */ |
-FileSelection.prototype.cancelComputing_ = function() { |
- this.computeBytesSequence_++; |
-}; |
- |
-/** |
* This object encapsulates everything related to current selection. |
* |
* @param {!FileManager} fileManager File manager instance. |
@@ -230,9 +146,6 @@ function FileSelectionHandler(fileManager) { |
cr.EventTarget.call(this); |
this.fileManager_ = fileManager; |
- // TODO(dgozman): create a shared object with most of UI elements. |
- this.previewPanel_ = fileManager.ui.previewPanel; |
- this.taskMenuButton_ = fileManager.ui.taskMenuButton; |
this.selection = new FileSelection(this.fileManager_, []); |
/** |
@@ -279,30 +192,11 @@ FileSelectionHandler.EventType = { |
FileSelectionHandler.prototype.__proto__ = cr.EventTarget.prototype; |
/** |
- * Maximum amount of thumbnails in the preview pane. |
- * |
- * @const |
- * @type {number} |
- */ |
-FileSelectionHandler.MAX_PREVIEW_THUMBNAIL_COUNT = 4; |
- |
-/** |
- * Maximum width or height of an image what pops up when the mouse hovers |
- * thumbnail in the bottom panel (in pixels). |
- * |
- * @const |
- * @type {number} |
- */ |
-FileSelectionHandler.IMAGE_HOVER_PREVIEW_SIZE = 200; |
- |
-/** |
* Update the UI when the selection model changes. |
*/ |
FileSelectionHandler.prototype.onFileSelectionChanged = function() { |
var indexes = |
this.fileManager_.getCurrentList().selectionModel.selectedIndexes; |
- if (this.selection) |
- this.selection.cancelComputing_(); |
var selection = new FileSelection(this.fileManager_, indexes); |
this.selection = selection; |
@@ -342,16 +236,29 @@ FileSelectionHandler.prototype.updateFileSelectionAsync_ = function(selection) { |
if (this.selection !== selection) |
return; |
- // Update preview panels. |
- var wasVisible = this.previewPanel_.visible; |
- this.previewPanel_.setSelection(selection); |
- |
- // Scroll to item |
- if (!wasVisible && this.selection.totalCount == 1) { |
- var list = this.fileManager_.getCurrentList(); |
- list.scrollIndexIntoView(list.selectionModel.selectedIndex); |
+ // Update the label "x files selected." on the header. |
+ // TODO(fukino): Make presenter class which listen to the FileSelection's |
+ // events and update the UI components accordingly. |
+ if (selection.totalCount === 0) { |
+ this.fileManager_.ui.filesSelectedLabel.textContent = ''; |
+ this.fileManager_.ui.filesSelectedLabel.hidden = true; |
+ } else { |
+ var text; |
+ if (selection.directoryCount == 0) |
+ text = strf('MANY_FILES_SELECTED', selection.fileCount); |
+ else if (selection.fileCount == 0) |
+ text = strf('MANY_DIRECTORIES_SELECTED', selection.directoryCount); |
+ else |
+ text = strf('MANY_ENTRIES_SELECTED', selection.totalCount); |
+ this.fileManager_.ui.filesSelectedLabel.textContent = text; |
+ this.fileManager_.ui.filesSelectedLabel.hidden = false; |
} |
+ // Hide search box if one or more items are selected. |
+ // TODO(fukino): Make presenter class which listen to the FileSelection's |
+ // events and update the UI components accordingly. |
+ this.fileManager_.ui.searchBox.setHidden(selection.totalCount !== 0); |
+ |
// Sync the commands availability. |
if (this.fileManager_.commandHandler) |
this.fileManager_.commandHandler.updateAvailability(); |