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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 23464030: Files.app: Let the PreviewPanel class control the visibility of the preview panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_selection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 3ac37665c5161b2ae5fa010b0d0579e6e7dc109f..e9683bda7a10e3ac81c770383dc6d13097d6aeea 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -82,6 +82,15 @@ DialogType.isModal = function(type) {
};
/**
+ * @param {string} type Dialog type.
+ * @return {boolean} Whther the type is open dialog.
+ */
+DialogType.isOpenDialog = function(type) {
+ return type == DialogType.SELECT_OPEN_FILE ||
+ type == DialogType.SELECT_OPEN_MULTI_FILE;
+};
+
+/**
* Bottom magrin of the list and tree for transparent preview panel.
* @const
*/
@@ -838,6 +847,17 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
'pathclick', this.onBreadcrumbClick_.bind(this));
this.searchBreadcrumbs_.setHideLast(false);
+ this.previewPanel_ = new PreviewPanel(
+ dom.querySelector('.preview-panel'),
+ DialogType.isOpenDialog(this.dialogType) ?
+ PreviewPanel.VisibilityType.ALWAYS :
yoshiki 2013/09/04 13:45:02 ALWAYS_VISIBLE or FORCE_VISIBLE is better, instead
hirono 2013/09/05 02:26:20 Done.
+ PreviewPanel.VisibilityType.AUTO,
+ this.getCurrentDirectory());
+ this.previewPanel_.addEventListener(
+ PreviewPanel.Event.VISIBILITY_CHANGE,
+ this.onPreviewPanelVisibilityChange_.bind(this));
+ this.previewPanel_.initialize();
+
// Check the option to hide the selecting checkboxes.
this.table_.showCheckboxes = this.showCheckboxes_;
@@ -1062,10 +1082,6 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
this.folderShortcutsModel_ = new FolderShortcutsDataModel();
this.selectionHandler_ = new FileSelectionHandler(this);
- this.selectionHandler_.addEventListener('show-preview-panel',
- this.onPreviewPanelVisibilityChanged_.bind(this, true));
- this.selectionHandler_.addEventListener('hide-preview-panel',
- this.onPreviewPanelVisibilityChanged_.bind(this, false));
var dataModel = this.directoryModel_.getFileList();
@@ -1504,8 +1520,9 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
* Resize details and thumb views to fit the new window size.
* @private
*/
- FileManager.prototype.onPreviewPanelVisibilityChanged_ = function(visible) {
- var panelHeight = visible ? this.getPreviewPanelHeight_() : 0;
+ FileManager.prototype.onPreviewPanelVisibilityChange_ = function() {
+ var panelHeight = this.previewPanel_.visible ?
+ this.previewPanel_.height : 0;
this.grid_.setBottomMarginForPanel(panelHeight);
this.table_.setBottomMarginForPanel(panelHeight);
this.directoryTree_.setBottomMarginForPanel(panelHeight);
@@ -1516,7 +1533,11 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
* @private
*/
FileManager.prototype.onDragStart_ = function() {
- this.selectionHandler_.setPreviewPanelMustBeHidden(true);
+ // On open file dialog, the preview panel is always shown.
+ if (DialogType.isOpenDialog(this.dialogType))
+ return;
+ this.selectionHandler_.previewPanel_.visibilityType =
yoshiki 2013/09/04 13:45:02 We can't access this.selectionHandler_.previewPane
hirono 2013/09/05 02:26:20 Done.
+ PreviewPanel.VisibilityType.HIDDEN;
yoshiki 2013/09/04 13:45:02 ALWAYS_HIDDEN or FORCE_HIDDEN?
hirono 2013/09/05 02:26:20 Done.
};
/**
@@ -1524,21 +1545,11 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
* @private
*/
FileManager.prototype.onDragEnd_ = function() {
- this.selectionHandler_.setPreviewPanelMustBeHidden(false);
- };
-
- /**
- * Gets height of the preview panel, using cached value if available. This
- * returns the value even when the preview panel is hidden.
- *
- * @return {number} Height of the preview panel. If failure, returns 0.
- */
- FileManager.prototype.getPreviewPanelHeight_ = function() {
- if (!this.cachedPreviewPanelHeight_) {
- var previewPanel = this.dialogDom_.querySelector('.preview-panel');
- this.cachedPreviewPanelHeight_ = previewPanel.clientHeight;
- }
- return this.cachedPreviewPanelHeight_;
+ // On open file dialog, the preview panel is always shown.
+ if (DialogType.isOpenDialog(this.dialogType))
+ return;
+ this.selectionHandler_.previewPanel_.visibilityType =
+ PreviewPanel.VisibilityType.AUTO;
};
/**
@@ -2465,6 +2476,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
this.updateUnformattedDriveStatus_();
this.updateTitle_();
this.updateGearMenu_();
+ this.previewPanel_.currentPath_ = this.getCurrentDirectory();
};
/**
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_selection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698