| Index: chrome/browser/resources/file_manager/js/file_selection.js
|
| diff --git a/chrome/browser/resources/file_manager/js/file_selection.js b/chrome/browser/resources/file_manager/js/file_selection.js
|
| index ddd399e42c6cb62379d061073c5f683802bdba6e..88c5c15ea925060dd9538b63763b61d29dbb2493 100644
|
| --- a/chrome/browser/resources/file_manager/js/file_selection.js
|
| +++ b/chrome/browser/resources/file_manager/js/file_selection.js
|
| @@ -89,6 +89,7 @@ FileSelection.prototype.createTasks = function(callback) {
|
| FileSelection.prototype.computeBytes = function(callback) {
|
| if (this.entries.length == 0) {
|
| this.bytesKnown = true;
|
| + this.showBytes = false;
|
| this.bytes = 0;
|
| return;
|
| }
|
| @@ -215,7 +216,7 @@ FileSelectionHandler.prototype.onFileSelectionChanged = function(event) {
|
| this.selectionUpdateTimer_ = null;
|
| }
|
|
|
| - if (!indexes.length) {
|
| + if (!util.platform.newUI() && !indexes.length) {
|
| this.updatePreviewPanelVisibility_();
|
| this.updatePreviewPanelText_();
|
| this.fileManager_.updateContextMenuActionItems(null, false);
|
| @@ -316,6 +317,10 @@ FileSelectionHandler.prototype.updatePreviewPanelVisibility_ = function() {
|
| var panel = this.previewPanel_;
|
| var state = panel.getAttribute('visibility');
|
| var mustBeVisible = (this.selection.totalCount > 0);
|
| + if (util.platform.newUI()) {
|
| + mustBeVisible = (this.selection.totalCount > 0 ||
|
| + !PathUtil.isRootPath(this.fileManager_.getCurrentDirectory()));
|
| + }
|
| var self = this;
|
| var fm = this.fileManager_;
|
|
|
| @@ -376,9 +381,19 @@ FileSelectionHandler.prototype.isPreviewPanelVisibile_ = function() {
|
| */
|
| FileSelectionHandler.prototype.updatePreviewPanelText_ = function() {
|
| var selection = this.selection;
|
| - if (selection.totalCount == 0) {
|
| - // We dont want to change the string during preview panel animating away.
|
| - return;
|
| + if (!util.platform.newUI()) {
|
| + if (selection.totalCount == 0) {
|
| + // We dont want to change the string during preview panel animating
|
| + return;
|
| + }
|
| + } else {
|
| + if (selection.totalCount <= 1) {
|
| + // Hides the preview text if zero or one file is selected. We shows a
|
| + // breadcrumb list instead on the preview panel.
|
| + this.hideCalculating_();
|
| + this.previewText_.textContent = '';
|
| + return;
|
| + }
|
| }
|
|
|
| var text = '';
|
| @@ -477,7 +492,20 @@ FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) {
|
| // Update the UI.
|
| var wasVisible = this.isPreviewPanelVisibile_();
|
| this.updatePreviewPanelVisibility_();
|
| - this.updateSearchBreadcrumbs_();
|
| +
|
| + if (util.platform.newUI() && selection.totalCount == 0) {
|
| + var path = this.fileManager_.getCurrentDirectory();
|
| + // Hides the breadcrumbs list on the root path.
|
| + if (PathUtil.isRootPath(path))
|
| + this.updatePreviewPanelBreadcrumbs_(null);
|
| + else
|
| + this.updatePreviewPanelBreadcrumbs_(path);
|
| + var entry = this.fileManager_.getCurrentDirectoryEntry();
|
| + this.showPreviewThumbnails_([entry]);
|
| + this.updatePreviewPanelText_();
|
| + return;
|
| + }
|
| +
|
| this.fileManager_.updateContextMenuActionItems(null, false);
|
| if (!wasVisible && this.selection.totalCount == 1) {
|
| var list = this.fileManager_.getCurrentList();
|
| @@ -489,28 +517,49 @@ FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) {
|
| for (var i = 0; i < commands.length; i++)
|
| commands[i].canExecuteChange();
|
|
|
| - // Update the summary information.
|
| - var onBytes = function() {
|
| - if (this.selection != selection) return;
|
| + if (!util.platform.newUI()) {
|
| + this.updateSearchBreadcrumbs_();
|
| + // Update the summary information.
|
| + var onBytes = function() {
|
| + if (this.selection != selection) return;
|
| + this.updatePreviewPanelText_();
|
| + }.bind(this);
|
| + selection.computeBytes(onBytes);
|
| this.updatePreviewPanelText_();
|
| - }.bind(this);
|
| - selection.computeBytes(onBytes);
|
| - this.updatePreviewPanelText_();
|
| + } else {
|
| + if (selection.totalCount == 1) {
|
| + // Shows the breadcrumb list.
|
| + var firstEntry = selection.entries[0];
|
| + this.updatePreviewPanelBreadcrumbs_(firstEntry.fullPath);
|
| + this.updatePreviewPanelText_();
|
| + } else {
|
| + this.updatePreviewPanelBreadcrumbs_(null);
|
| +
|
| + // Update the summary information.
|
| + var onBytes = function() {
|
| + if (this.selection != selection) return;
|
| + this.updatePreviewPanelText_();
|
| + }.bind(this);
|
| + selection.computeBytes(onBytes);
|
| + this.updatePreviewPanelText_();
|
| + }
|
| + }
|
|
|
| // Inform tests it's OK to click buttons now.
|
| chrome.test.sendMessage('selection-change-complete');
|
|
|
| // Show thumbnails.
|
| - this.showPreviewThumbnails_(selection);
|
| + this.showPreviewThumbnails_(selection.entries);
|
| };
|
|
|
| /**
|
| * Renders preview thumbnails in preview panel.
|
| *
|
| - * @param {FileSelection} selection The selection object.
|
| + * @param {Array.<FileEntry>} entries The entries of selected object.
|
| * @private
|
| */
|
| -FileSelectionHandler.prototype.showPreviewThumbnails_ = function(selection) {
|
| +FileSelectionHandler.prototype.showPreviewThumbnails_ = function(entries) {
|
| + var selection = this.selection;
|
| var thumbnails = [];
|
| var thumbnailCount = 0;
|
| var thumbnailLoaded = -1;
|
| @@ -554,8 +603,8 @@ FileSelectionHandler.prototype.showPreviewThumbnails_ = function(selection) {
|
| };
|
|
|
| var doc = this.fileManager_.document_;
|
| - for (var i = 0; i < selection.entries.length; i++) {
|
| - var entry = selection.entries[i];
|
| + for (var i = 0; i < entries.length; i++) {
|
| + var entry = entries[i];
|
|
|
| if (thumbnailCount < FileSelectionHandler.MAX_PREVIEW_THUMBNAIL_COUNT) {
|
| var box = doc.createElement('div');
|
| @@ -611,7 +660,20 @@ FileSelectionHandler.prototype.renderThumbnail_ = function(entry, callback) {
|
| };
|
|
|
| /**
|
| - * Updates the search breadcrumbs.
|
| + * Updates the breadcrumbs in the preview panel.
|
| + *
|
| + * @param {?string} path Path to be shown in the breadcrumbs list
|
| + * @private
|
| + */
|
| +FileSelectionHandler.prototype.updatePreviewPanelBreadcrumbs_ = function(path) {
|
| + if (!path)
|
| + this.searchBreadcrumbs_.hide();
|
| + else
|
| + this.searchBreadcrumbs_.show(PathUtil.getRootPath(path), path);
|
| +};
|
| +
|
| +/**
|
| + * Updates the search breadcrumbs. This method should not be used in the new ui.
|
| *
|
| * @private
|
| */
|
|
|