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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_selection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * This variable is checked in SelectFileDialogExtensionBrowserTest. 8 * This variable is checked in SelectFileDialogExtensionBrowserTest.
9 * @type {number} 9 * @type {number}
10 */ 10 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 */ 75 */
76 DialogType.isModal = function(type) { 76 DialogType.isModal = function(type) {
77 return type == DialogType.SELECT_FOLDER || 77 return type == DialogType.SELECT_FOLDER ||
78 type == DialogType.SELECT_UPLOAD_FOLDER || 78 type == DialogType.SELECT_UPLOAD_FOLDER ||
79 type == DialogType.SELECT_SAVEAS_FILE || 79 type == DialogType.SELECT_SAVEAS_FILE ||
80 type == DialogType.SELECT_OPEN_FILE || 80 type == DialogType.SELECT_OPEN_FILE ||
81 type == DialogType.SELECT_OPEN_MULTI_FILE; 81 type == DialogType.SELECT_OPEN_MULTI_FILE;
82 }; 82 };
83 83
84 /** 84 /**
85 * @param {string} type Dialog type.
86 * @return {boolean} Whther the type is open dialog.
87 */
88 DialogType.isOpenDialog = function(type) {
89 return type == DialogType.SELECT_OPEN_FILE ||
90 type == DialogType.SELECT_OPEN_MULTI_FILE;
91 };
92
93 /**
85 * Bottom magrin of the list and tree for transparent preview panel. 94 * Bottom magrin of the list and tree for transparent preview panel.
86 * @const 95 * @const
87 */ 96 */
88 var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; 97 var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
89 98
90 // Anonymous "namespace". 99 // Anonymous "namespace".
91 (function() { 100 (function() {
92 101
93 // Private variables and helper functions. 102 // Private variables and helper functions.
94 103
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 this.grid_ = dom.querySelector('.thumbnail-grid'); 840 this.grid_ = dom.querySelector('.thumbnail-grid');
832 this.spinner_ = dom.querySelector('#spinner-with-text'); 841 this.spinner_ = dom.querySelector('#spinner-with-text');
833 this.showSpinner_(true); 842 this.showSpinner_(true);
834 843
835 this.searchBreadcrumbs_ = new BreadcrumbsController( 844 this.searchBreadcrumbs_ = new BreadcrumbsController(
836 dom.querySelector('#search-breadcrumbs'), this.metadataCache_); 845 dom.querySelector('#search-breadcrumbs'), this.metadataCache_);
837 this.searchBreadcrumbs_.addEventListener( 846 this.searchBreadcrumbs_.addEventListener(
838 'pathclick', this.onBreadcrumbClick_.bind(this)); 847 'pathclick', this.onBreadcrumbClick_.bind(this));
839 this.searchBreadcrumbs_.setHideLast(false); 848 this.searchBreadcrumbs_.setHideLast(false);
840 849
850 this.previewPanel_ = new PreviewPanel(
851 dom.querySelector('.preview-panel'),
852 DialogType.isOpenDialog(this.dialogType) ?
853 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.
854 PreviewPanel.VisibilityType.AUTO,
855 this.getCurrentDirectory());
856 this.previewPanel_.addEventListener(
857 PreviewPanel.Event.VISIBILITY_CHANGE,
858 this.onPreviewPanelVisibilityChange_.bind(this));
859 this.previewPanel_.initialize();
860
841 // Check the option to hide the selecting checkboxes. 861 // Check the option to hide the selecting checkboxes.
842 this.table_.showCheckboxes = this.showCheckboxes_; 862 this.table_.showCheckboxes = this.showCheckboxes_;
843 863
844 var fullPage = this.dialogType == DialogType.FULL_PAGE; 864 var fullPage = this.dialogType == DialogType.FULL_PAGE;
845 FileTable.decorate(this.table_, this.metadataCache_, fullPage); 865 FileTable.decorate(this.table_, this.metadataCache_, fullPage);
846 FileGrid.decorate(this.grid_, this.metadataCache_); 866 FileGrid.decorate(this.grid_, this.metadataCache_);
847 867
848 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); 868 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this));
849 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this)); 869 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this));
850 870
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 this.fileFilter_, 1075 this.fileFilter_,
1056 this.fileWatcher_, 1076 this.fileWatcher_,
1057 this.metadataCache_, 1077 this.metadataCache_,
1058 this.volumeManager_, 1078 this.volumeManager_,
1059 showSpecialSearchRoots); 1079 showSpecialSearchRoots);
1060 this.directoryModel_.start(); 1080 this.directoryModel_.start();
1061 1081
1062 this.folderShortcutsModel_ = new FolderShortcutsDataModel(); 1082 this.folderShortcutsModel_ = new FolderShortcutsDataModel();
1063 1083
1064 this.selectionHandler_ = new FileSelectionHandler(this); 1084 this.selectionHandler_ = new FileSelectionHandler(this);
1065 this.selectionHandler_.addEventListener('show-preview-panel',
1066 this.onPreviewPanelVisibilityChanged_.bind(this, true));
1067 this.selectionHandler_.addEventListener('hide-preview-panel',
1068 this.onPreviewPanelVisibilityChanged_.bind(this, false));
1069 1085
1070 var dataModel = this.directoryModel_.getFileList(); 1086 var dataModel = this.directoryModel_.getFileList();
1071 1087
1072 this.table_.setupCompareFunctions(dataModel); 1088 this.table_.setupCompareFunctions(dataModel);
1073 1089
1074 dataModel.addEventListener('permuted', 1090 dataModel.addEventListener('permuted',
1075 this.updateStartupPrefs_.bind(this)); 1091 this.updateStartupPrefs_.bind(this));
1076 1092
1077 this.directoryModel_.getFileListSelection().addEventListener('change', 1093 this.directoryModel_.getFileListSelection().addEventListener('change',
1078 this.selectionHandler_.onFileSelectionChanged.bind( 1094 this.selectionHandler_.onFileSelectionChanged.bind(
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 * @private 1513 * @private
1498 */ 1514 */
1499 FileManager.prototype.onWatcherMetadataChanged_ = function(event) { 1515 FileManager.prototype.onWatcherMetadataChanged_ = function(event) {
1500 this.updateMetadataInUI_(event.metadataType, event.urls, event.properties); 1516 this.updateMetadataInUI_(event.metadataType, event.urls, event.properties);
1501 }; 1517 };
1502 1518
1503 /** 1519 /**
1504 * Resize details and thumb views to fit the new window size. 1520 * Resize details and thumb views to fit the new window size.
1505 * @private 1521 * @private
1506 */ 1522 */
1507 FileManager.prototype.onPreviewPanelVisibilityChanged_ = function(visible) { 1523 FileManager.prototype.onPreviewPanelVisibilityChange_ = function() {
1508 var panelHeight = visible ? this.getPreviewPanelHeight_() : 0; 1524 var panelHeight = this.previewPanel_.visible ?
1525 this.previewPanel_.height : 0;
1509 this.grid_.setBottomMarginForPanel(panelHeight); 1526 this.grid_.setBottomMarginForPanel(panelHeight);
1510 this.table_.setBottomMarginForPanel(panelHeight); 1527 this.table_.setBottomMarginForPanel(panelHeight);
1511 this.directoryTree_.setBottomMarginForPanel(panelHeight); 1528 this.directoryTree_.setBottomMarginForPanel(panelHeight);
1512 }; 1529 };
1513 1530
1514 /** 1531 /**
1515 * Invoked when the drag is started on the list or the grid. 1532 * Invoked when the drag is started on the list or the grid.
1516 * @private 1533 * @private
1517 */ 1534 */
1518 FileManager.prototype.onDragStart_ = function() { 1535 FileManager.prototype.onDragStart_ = function() {
1519 this.selectionHandler_.setPreviewPanelMustBeHidden(true); 1536 // On open file dialog, the preview panel is always shown.
1537 if (DialogType.isOpenDialog(this.dialogType))
1538 return;
1539 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.
1540 PreviewPanel.VisibilityType.HIDDEN;
yoshiki 2013/09/04 13:45:02 ALWAYS_HIDDEN or FORCE_HIDDEN?
hirono 2013/09/05 02:26:20 Done.
1520 }; 1541 };
1521 1542
1522 /** 1543 /**
1523 * Invoked when the drag is ended on the list or the grid. 1544 * Invoked when the drag is ended on the list or the grid.
1524 * @private 1545 * @private
1525 */ 1546 */
1526 FileManager.prototype.onDragEnd_ = function() { 1547 FileManager.prototype.onDragEnd_ = function() {
1527 this.selectionHandler_.setPreviewPanelMustBeHidden(false); 1548 // On open file dialog, the preview panel is always shown.
1549 if (DialogType.isOpenDialog(this.dialogType))
1550 return;
1551 this.selectionHandler_.previewPanel_.visibilityType =
1552 PreviewPanel.VisibilityType.AUTO;
1528 }; 1553 };
1529 1554
1530 /** 1555 /**
1531 * Gets height of the preview panel, using cached value if available. This
1532 * returns the value even when the preview panel is hidden.
1533 *
1534 * @return {number} Height of the preview panel. If failure, returns 0.
1535 */
1536 FileManager.prototype.getPreviewPanelHeight_ = function() {
1537 if (!this.cachedPreviewPanelHeight_) {
1538 var previewPanel = this.dialogDom_.querySelector('.preview-panel');
1539 this.cachedPreviewPanelHeight_ = previewPanel.clientHeight;
1540 }
1541 return this.cachedPreviewPanelHeight_;
1542 };
1543
1544 /**
1545 * Restores current directory and may be a selected item after page load (or 1556 * Restores current directory and may be a selected item after page load (or
1546 * reload) or popping a state (after click on back/forward). If location.hash 1557 * reload) or popping a state (after click on back/forward). If location.hash
1547 * is present it means that the user has navigated somewhere and that place 1558 * is present it means that the user has navigated somewhere and that place
1548 * will be restored. defaultPath primarily is used with save/open dialogs. 1559 * will be restored. defaultPath primarily is used with save/open dialogs.
1549 * Default path may also contain a file name. Freshly opened file manager 1560 * Default path may also contain a file name. Freshly opened file manager
1550 * window has neither. 1561 * window has neither.
1551 * 1562 *
1552 * @private 1563 * @private
1553 */ 1564 */
1554 FileManager.prototype.setupCurrentDirectory_ = function() { 1565 FileManager.prototype.setupCurrentDirectory_ = function() {
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 if (this.closeOnUnmount_ && !event.initial && 2469 if (this.closeOnUnmount_ && !event.initial &&
2459 PathUtil.getRootPath(event.previousDirEntry.fullPath) != 2470 PathUtil.getRootPath(event.previousDirEntry.fullPath) !=
2460 PathUtil.getRootPath(event.newDirEntry.fullPath)) { 2471 PathUtil.getRootPath(event.newDirEntry.fullPath)) {
2461 this.closeOnUnmount_ = false; 2472 this.closeOnUnmount_ = false;
2462 } 2473 }
2463 2474
2464 this.updateCommands(); 2475 this.updateCommands();
2465 this.updateUnformattedDriveStatus_(); 2476 this.updateUnformattedDriveStatus_();
2466 this.updateTitle_(); 2477 this.updateTitle_();
2467 this.updateGearMenu_(); 2478 this.updateGearMenu_();
2479 this.previewPanel_.currentPath_ = this.getCurrentDirectory();
2468 }; 2480 };
2469 2481
2470 /** 2482 /**
2471 * Updates commands' states by emiting canExecute events. Should be used 2483 * Updates commands' states by emiting canExecute events. Should be used
2472 * only if there is need to reevaluate states without an user action, eg. 2484 * only if there is need to reevaluate states without an user action, eg.
2473 * external events. 2485 * external events.
2474 */ 2486 */
2475 FileManager.prototype.updateCommands = function() { 2487 FileManager.prototype.updateCommands = function() {
2476 var commands = this.dialogDom_.querySelectorAll('command'); 2488 var commands = this.dialogDom_.querySelectorAll('command');
2477 for (var i = 0; i < commands.length; i++) { 2489 for (var i = 0; i < commands.length; i++) {
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 */ 3951 */
3940 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { 3952 FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
3941 this.ctrlKeyPressed_ = flag; 3953 this.ctrlKeyPressed_ = flag;
3942 // Before the DOM is constructed, the key event can be handled. 3954 // Before the DOM is constructed, the key event can be handled.
3943 var cacheClearCommand = 3955 var cacheClearCommand =
3944 this.document_.querySelector('#drive-clear-local-cache'); 3956 this.document_.querySelector('#drive-clear-local-cache');
3945 if (cacheClearCommand) 3957 if (cacheClearCommand)
3946 cacheClearCommand.canExecuteChange(); 3958 cacheClearCommand.canExecuteChange();
3947 }; 3959 };
3948 })(); 3960 })();
OLDNEW
« 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