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

Unified Diff: trunk/src/chrome/browser/resources/file_manager/js/file_selection.js

Issue 23903018: Revert 221579 "Files.app: Let the PreviewPanel class control the..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/resources/file_manager/js/file_selection.js
===================================================================
--- trunk/src/chrome/browser/resources/file_manager/js/file_selection.js (revision 221612)
+++ trunk/src/chrome/browser/resources/file_manager/js/file_selection.js (working copy)
@@ -26,7 +26,6 @@
this.iconType = null;
this.bytesKnown = false;
this.mustBeHidden_ = false;
- this.mimeTypes = null;
// Synchronously compute what we can.
for (var i = 0; i < this.indexes.length; i++) {
@@ -54,8 +53,6 @@
}
this.tasks = new FileTasks(this.fileManager_);
-
- Object.seal(this);
}
/**
@@ -159,13 +156,11 @@
// TODO(dgozman): create a shared object with most of UI elements.
this.okButton_ = fileManager.okButton_;
this.filenameInput_ = fileManager.filenameInput_;
- this.previewPanel_ = fileManager.previewPanel_;
- this.previewPanelElement_ =
- fileManager.dialogDom_.querySelector('.preview-panel');
- this.previewThumbnails_ = this.previewPanelElement_.
+
+ this.previewPanel_ = fileManager.dialogDom_.querySelector('.preview-panel');
+ this.previewThumbnails_ = this.previewPanel_.
querySelector('.preview-thumbnails');
- this.previewSummary_ =
- this.previewPanelElement_.querySelector('.preview-summary');
+ this.previewSummary_ = this.previewPanel_.querySelector('.preview-summary');
this.previewText_ = this.previewSummary_.querySelector('.preview-text');
this.calculatingSize_ = this.previewSummary_.
querySelector('.calculating-size');
@@ -315,6 +310,82 @@
};
/**
+ * Sets the flag to force the preview panel hidden.
+ * @param {boolean} hidden True to force hidden.
+ */
+FileSelectionHandler.prototype.setPreviewPanelMustBeHidden = function(hidden) {
+ this.previewPanelMustBeHidden_ = hidden;
+ this.updatePreviewPanelVisibility_();
+};
+
+/**
+ * Animates preview panel show/hide transitions.
+ *
+ * @private
+ */
+FileSelectionHandler.prototype.updatePreviewPanelVisibility_ = function() {
+ var panel = this.previewPanel_;
+ var state = panel.getAttribute('visibility');
+ var mustBeVisible =
+ // If one or more files are selected, show the file info.
+ (this.selection.totalCount > 0 ||
+ // If the directory is not root dir, show the directory info.
+ !PathUtil.isRootPath(this.fileManager_.getCurrentDirectory()) ||
+ // On Open File dialog, the preview panel is always shown.
+ this.fileManager_.dialogType == DialogType.SELECT_OPEN_FILE ||
+ this.fileManager_.dialogType == DialogType.SELECT_OPEN_MULTI_FILE);
+
+ var stopHidingAndShow = function() {
+ clearTimeout(this.hidingTimeout_);
+ this.hidingTimeout_ = 0;
+ setVisibility('visible');
+ }.bind(this);
+
+ var startHiding = function() {
+ setVisibility('hiding');
+ this.hidingTimeout_ = setTimeout(function() {
+ this.hidingTimeout_ = 0;
+ setVisibility('hidden');
+ cr.dispatchSimpleEvent(this, 'hide-preview-panel');
+ }.bind(this), 250);
+ }.bind(this);
+
+ var show = function() {
+ setVisibility('visible');
+ this.previewThumbnails_.textContent = '';
+ cr.dispatchSimpleEvent(this, 'show-preview-panel');
+ }.bind(this);
+
+ var setVisibility = function(visibility) {
+ panel.setAttribute('visibility', visibility);
+ };
+
+ switch (state) {
+ case 'visible':
+ if (!mustBeVisible || this.previewPanelMustBeHidden_)
+ startHiding();
+ break;
+
+ case 'hiding':
+ if (mustBeVisible && !this.previewPanelMustBeHidden_)
+ stopHidingAndShow();
+ break;
+
+ case 'hidden':
+ if (mustBeVisible && !this.previewPanelMustBeHidden_)
+ show();
+ }
+};
+
+/**
+ * @return {boolean} True if space reserverd for the preview panel.
+ * @private
+ */
+FileSelectionHandler.prototype.isPreviewPanelVisibile_ = function() {
+ return this.previewPanel_.getAttribute('visibility') == 'visible';
+};
+
+/**
* Update the selection summary in preview panel.
*
* @private
@@ -422,7 +493,7 @@
}
// Update preview panels.
- var wasVisible = this.previewPanel_.visible;
+ var wasVisible = this.isPreviewPanelVisibile_();
var thumbnailEntries;
if (selection.totalCount == 0) {
thumbnailEntries = [
@@ -438,7 +509,7 @@
}.bind(this));
}
}
- this.previewPanel_.entries = selection.entries;
+ this.updatePreviewPanelVisibility_();
this.updatePreviewPanelText_();
this.showPreviewThumbnails_(thumbnailEntries);
@@ -449,7 +520,7 @@
// Shows the breadcrumb list when a file is selected.
updateTarget = selection.entries[0].fullPath;
} else if (selection.totalCount == 0 &&
- this.previewPanel_.visible) {
+ this.isPreviewPanelVisibile_()) {
// Shows the breadcrumb list when no file is selected and the preview
// panel is visible.
updateTarget = path;

Powered by Google App Engine
This is Rietveld 408576698