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

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: Fix the fail of test. 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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 this.grid_ = dom.querySelector('.thumbnail-grid'); 835 this.grid_ = dom.querySelector('.thumbnail-grid');
827 this.spinner_ = dom.querySelector('#spinner-with-text'); 836 this.spinner_ = dom.querySelector('#spinner-with-text');
828 this.showSpinner_(true); 837 this.showSpinner_(true);
829 838
830 this.searchBreadcrumbs_ = new BreadcrumbsController( 839 this.searchBreadcrumbs_ = new BreadcrumbsController(
831 dom.querySelector('#search-breadcrumbs'), this.metadataCache_); 840 dom.querySelector('#search-breadcrumbs'), this.metadataCache_);
832 this.searchBreadcrumbs_.addEventListener( 841 this.searchBreadcrumbs_.addEventListener(
833 'pathclick', this.onBreadcrumbClick_.bind(this)); 842 'pathclick', this.onBreadcrumbClick_.bind(this));
834 this.searchBreadcrumbs_.setHideLast(false); 843 this.searchBreadcrumbs_.setHideLast(false);
835 844
845 this.previewPanel_ = new PreviewPanel(
846 dom.querySelector('.preview-panel'),
847 DialogType.isOpenDialog(this.dialogType) ?
848 PreviewPanel.VisibilityType.ALWAYS_VISIBLE :
849 PreviewPanel.VisibilityType.AUTO,
850 this.getCurrentDirectory());
851 this.previewPanel_.addEventListener(
852 PreviewPanel.Event.VISIBILITY_CHANGE,
853 this.onPreviewPanelVisibilityChange_.bind(this));
854 this.previewPanel_.initialize();
855
836 // Check the option to hide the selecting checkboxes. 856 // Check the option to hide the selecting checkboxes.
837 this.table_.showCheckboxes = this.showCheckboxes_; 857 this.table_.showCheckboxes = this.showCheckboxes_;
838 858
839 var fullPage = this.dialogType == DialogType.FULL_PAGE; 859 var fullPage = this.dialogType == DialogType.FULL_PAGE;
840 FileTable.decorate(this.table_, this.metadataCache_, fullPage); 860 FileTable.decorate(this.table_, this.metadataCache_, fullPage);
841 FileGrid.decorate(this.grid_, this.metadataCache_); 861 FileGrid.decorate(this.grid_, this.metadataCache_);
842 862
843 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); 863 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this));
844 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this)); 864 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this));
845 865
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 this.fileFilter_, 1070 this.fileFilter_,
1051 this.fileWatcher_, 1071 this.fileWatcher_,
1052 this.metadataCache_, 1072 this.metadataCache_,
1053 this.volumeManager_, 1073 this.volumeManager_,
1054 showSpecialSearchRoots); 1074 showSpecialSearchRoots);
1055 this.directoryModel_.start(); 1075 this.directoryModel_.start();
1056 1076
1057 this.folderShortcutsModel_ = new FolderShortcutsDataModel(); 1077 this.folderShortcutsModel_ = new FolderShortcutsDataModel();
1058 1078
1059 this.selectionHandler_ = new FileSelectionHandler(this); 1079 this.selectionHandler_ = new FileSelectionHandler(this);
1060 this.selectionHandler_.addEventListener('show-preview-panel',
1061 this.onPreviewPanelVisibilityChanged_.bind(this, true));
1062 this.selectionHandler_.addEventListener('hide-preview-panel',
1063 this.onPreviewPanelVisibilityChanged_.bind(this, false));
1064 1080
1065 var dataModel = this.directoryModel_.getFileList(); 1081 var dataModel = this.directoryModel_.getFileList();
1066 1082
1067 this.table_.setupCompareFunctions(dataModel); 1083 this.table_.setupCompareFunctions(dataModel);
1068 1084
1069 dataModel.addEventListener('permuted', 1085 dataModel.addEventListener('permuted',
1070 this.updateStartupPrefs_.bind(this)); 1086 this.updateStartupPrefs_.bind(this));
1071 1087
1072 this.directoryModel_.getFileListSelection().addEventListener('change', 1088 this.directoryModel_.getFileListSelection().addEventListener('change',
1073 this.selectionHandler_.onFileSelectionChanged.bind( 1089 this.selectionHandler_.onFileSelectionChanged.bind(
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 * @private 1508 * @private
1493 */ 1509 */
1494 FileManager.prototype.onWatcherMetadataChanged_ = function(event) { 1510 FileManager.prototype.onWatcherMetadataChanged_ = function(event) {
1495 this.updateMetadataInUI_(event.metadataType, event.urls, event.properties); 1511 this.updateMetadataInUI_(event.metadataType, event.urls, event.properties);
1496 }; 1512 };
1497 1513
1498 /** 1514 /**
1499 * Resize details and thumb views to fit the new window size. 1515 * Resize details and thumb views to fit the new window size.
1500 * @private 1516 * @private
1501 */ 1517 */
1502 FileManager.prototype.onPreviewPanelVisibilityChanged_ = function(visible) { 1518 FileManager.prototype.onPreviewPanelVisibilityChange_ = function() {
1503 var panelHeight = visible ? this.getPreviewPanelHeight_() : 0; 1519 var panelHeight = this.previewPanel_.visible ?
1520 this.previewPanel_.height : 0;
1504 this.grid_.setBottomMarginForPanel(panelHeight); 1521 this.grid_.setBottomMarginForPanel(panelHeight);
1505 this.table_.setBottomMarginForPanel(panelHeight); 1522 this.table_.setBottomMarginForPanel(panelHeight);
1506 this.directoryTree_.setBottomMarginForPanel(panelHeight); 1523 this.directoryTree_.setBottomMarginForPanel(panelHeight);
1507 }; 1524 };
1508 1525
1509 /** 1526 /**
1510 * Invoked when the drag is started on the list or the grid. 1527 * Invoked when the drag is started on the list or the grid.
1511 * @private 1528 * @private
1512 */ 1529 */
1513 FileManager.prototype.onDragStart_ = function() { 1530 FileManager.prototype.onDragStart_ = function() {
1514 this.selectionHandler_.setPreviewPanelMustBeHidden(true); 1531 // On open file dialog, the preview panel is always shown.
1532 if (DialogType.isOpenDialog(this.dialogType))
1533 return;
1534 this.previewPanel_.visibilityType =
1535 PreviewPanel.VisibilityType.ALWAYS_HIDDEN;
1515 }; 1536 };
1516 1537
1517 /** 1538 /**
1518 * Invoked when the drag is ended on the list or the grid. 1539 * Invoked when the drag is ended on the list or the grid.
1519 * @private 1540 * @private
1520 */ 1541 */
1521 FileManager.prototype.onDragEnd_ = function() { 1542 FileManager.prototype.onDragEnd_ = function() {
1522 this.selectionHandler_.setPreviewPanelMustBeHidden(false); 1543 // On open file dialog, the preview panel is always shown.
1544 if (DialogType.isOpenDialog(this.dialogType))
1545 return;
1546 this.previewPanel_.visibilityType = PreviewPanel.VisibilityType.AUTO;
1523 }; 1547 };
1524 1548
1525 /** 1549 /**
1526 * Gets height of the preview panel, using cached value if available. This
1527 * returns the value even when the preview panel is hidden.
1528 *
1529 * @return {number} Height of the preview panel. If failure, returns 0.
1530 */
1531 FileManager.prototype.getPreviewPanelHeight_ = function() {
1532 if (!this.cachedPreviewPanelHeight_) {
1533 var previewPanel = this.dialogDom_.querySelector('.preview-panel');
1534 this.cachedPreviewPanelHeight_ = previewPanel.clientHeight;
1535 }
1536 return this.cachedPreviewPanelHeight_;
1537 };
1538
1539 /**
1540 * Restores current directory and may be a selected item after page load (or 1550 * Restores current directory and may be a selected item after page load (or
1541 * reload) or popping a state (after click on back/forward). If location.hash 1551 * reload) or popping a state (after click on back/forward). If location.hash
1542 * is present it means that the user has navigated somewhere and that place 1552 * is present it means that the user has navigated somewhere and that place
1543 * will be restored. defaultPath primarily is used with save/open dialogs. 1553 * will be restored. defaultPath primarily is used with save/open dialogs.
1544 * Default path may also contain a file name. Freshly opened file manager 1554 * Default path may also contain a file name. Freshly opened file manager
1545 * window has neither. 1555 * window has neither.
1546 * 1556 *
1547 * @private 1557 * @private
1548 */ 1558 */
1549 FileManager.prototype.setupCurrentDirectory_ = function() { 1559 FileManager.prototype.setupCurrentDirectory_ = function() {
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 if (this.closeOnUnmount_ && !event.initial && 2465 if (this.closeOnUnmount_ && !event.initial &&
2456 PathUtil.getRootPath(event.previousDirEntry.fullPath) != 2466 PathUtil.getRootPath(event.previousDirEntry.fullPath) !=
2457 PathUtil.getRootPath(event.newDirEntry.fullPath)) { 2467 PathUtil.getRootPath(event.newDirEntry.fullPath)) {
2458 this.closeOnUnmount_ = false; 2468 this.closeOnUnmount_ = false;
2459 } 2469 }
2460 2470
2461 this.updateCommands(); 2471 this.updateCommands();
2462 this.updateUnformattedDriveStatus_(); 2472 this.updateUnformattedDriveStatus_();
2463 this.updateTitle_(); 2473 this.updateTitle_();
2464 this.updateGearMenu_(); 2474 this.updateGearMenu_();
2475 this.previewPanel_.currentPath_ = this.getCurrentDirectory();
2465 }; 2476 };
2466 2477
2467 /** 2478 /**
2468 * Updates commands' states by emiting canExecute events. Should be used 2479 * Updates commands' states by emiting canExecute events. Should be used
2469 * only if there is need to reevaluate states without an user action, eg. 2480 * only if there is need to reevaluate states without an user action, eg.
2470 * external events. 2481 * external events.
2471 */ 2482 */
2472 FileManager.prototype.updateCommands = function() { 2483 FileManager.prototype.updateCommands = function() {
2473 var commands = this.dialogDom_.querySelectorAll('command'); 2484 var commands = this.dialogDom_.querySelectorAll('command');
2474 for (var i = 0; i < commands.length; i++) { 2485 for (var i = 0; i < commands.length; i++) {
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3936 */ 3947 */
3937 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { 3948 FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
3938 this.ctrlKeyPressed_ = flag; 3949 this.ctrlKeyPressed_ = flag;
3939 // Before the DOM is constructed, the key event can be handled. 3950 // Before the DOM is constructed, the key event can be handled.
3940 var cacheClearCommand = 3951 var cacheClearCommand =
3941 this.document_.querySelector('#drive-clear-local-cache'); 3952 this.document_.querySelector('#drive-clear-local-cache');
3942 if (cacheClearCommand) 3953 if (cacheClearCommand)
3943 cacheClearCommand.canExecuteChange(); 3954 cacheClearCommand.canExecuteChange();
3944 }; 3955 };
3945 })(); 3956 })();
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