OLD | NEW |
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 Loading... |
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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 'pathclick', this.onBreadcrumbClick_.bind(this)); | 842 'pathclick', this.onBreadcrumbClick_.bind(this)); |
834 this.searchBreadcrumbs_.setHideLast(false); | 843 this.searchBreadcrumbs_.setHideLast(false); |
835 | 844 |
836 // Check the option to hide the selecting checkboxes. | 845 // Check the option to hide the selecting checkboxes. |
837 this.table_.showCheckboxes = this.showCheckboxes_; | 846 this.table_.showCheckboxes = this.showCheckboxes_; |
838 | 847 |
839 var fullPage = this.dialogType == DialogType.FULL_PAGE; | 848 var fullPage = this.dialogType == DialogType.FULL_PAGE; |
840 FileTable.decorate(this.table_, this.metadataCache_, fullPage); | 849 FileTable.decorate(this.table_, this.metadataCache_, fullPage); |
841 FileGrid.decorate(this.grid_, this.metadataCache_); | 850 FileGrid.decorate(this.grid_, this.metadataCache_); |
842 | 851 |
| 852 this.previewPanel_ = new PreviewPanel( |
| 853 dom.querySelector('.preview-panel'), |
| 854 DialogType.isOpenDialog(this.dialogType) ? |
| 855 PreviewPanel.VisibilityType.ALWAYS_VISIBLE : |
| 856 PreviewPanel.VisibilityType.AUTO, |
| 857 this.getCurrentDirectory()); |
| 858 this.previewPanel_.addEventListener( |
| 859 PreviewPanel.Event.VISIBILITY_CHANGE, |
| 860 this.onPreviewPanelVisibilityChange_.bind(this)); |
| 861 this.previewPanel_.initialize(); |
| 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 |
846 // This capturing event is only used to distinguish focusing using | 866 // This capturing event is only used to distinguish focusing using |
847 // keyboard from focusing using mouse. | 867 // keyboard from focusing using mouse. |
848 this.document_.addEventListener('mousedown', function() { | 868 this.document_.addEventListener('mousedown', function() { |
849 this.suppressFocus_ = true; | 869 this.suppressFocus_ = true; |
850 }.bind(this), true); | 870 }.bind(this), true); |
851 | 871 |
852 this.renameInput_ = this.document_.createElement('input'); | 872 this.renameInput_ = this.document_.createElement('input'); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 ? |
1504 this.grid_.setBottomMarginForPanel(panelHeight); | 1520 this.previewPanel_.height : 0; |
1505 this.table_.setBottomMarginForPanel(panelHeight); | 1521 if (this.grid_) |
1506 this.directoryTree_.setBottomMarginForPanel(panelHeight); | 1522 this.grid_.setBottomMarginForPanel(panelHeight); |
| 1523 if (this.table_) |
| 1524 this.table_.setBottomMarginForPanel(panelHeight); |
| 1525 if (this.directoryTree_) |
| 1526 this.directoryTree_.setBottomMarginForPanel(panelHeight); |
1507 }; | 1527 }; |
1508 | 1528 |
1509 /** | 1529 /** |
1510 * Invoked when the drag is started on the list or the grid. | 1530 * Invoked when the drag is started on the list or the grid. |
1511 * @private | 1531 * @private |
1512 */ | 1532 */ |
1513 FileManager.prototype.onDragStart_ = function() { | 1533 FileManager.prototype.onDragStart_ = function() { |
1514 this.selectionHandler_.setPreviewPanelMustBeHidden(true); | 1534 // On open file dialog, the preview panel is always shown. |
| 1535 if (DialogType.isOpenDialog(this.dialogType)) |
| 1536 return; |
| 1537 this.previewPanel_.visibilityType = |
| 1538 PreviewPanel.VisibilityType.ALWAYS_HIDDEN; |
1515 }; | 1539 }; |
1516 | 1540 |
1517 /** | 1541 /** |
1518 * Invoked when the drag is ended on the list or the grid. | 1542 * Invoked when the drag is ended on the list or the grid. |
1519 * @private | 1543 * @private |
1520 */ | 1544 */ |
1521 FileManager.prototype.onDragEnd_ = function() { | 1545 FileManager.prototype.onDragEnd_ = function() { |
1522 this.selectionHandler_.setPreviewPanelMustBeHidden(false); | 1546 // On open file dialog, the preview panel is always shown. |
| 1547 if (DialogType.isOpenDialog(this.dialogType)) |
| 1548 return; |
| 1549 this.previewPanel_.visibilityType = PreviewPanel.VisibilityType.AUTO; |
1523 }; | 1550 }; |
1524 | 1551 |
1525 /** | 1552 /** |
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 | 1553 * 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 | 1554 * 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 | 1555 * 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. | 1556 * will be restored. defaultPath primarily is used with save/open dialogs. |
1544 * Default path may also contain a file name. Freshly opened file manager | 1557 * Default path may also contain a file name. Freshly opened file manager |
1545 * window has neither. | 1558 * window has neither. |
1546 * | 1559 * |
1547 * @private | 1560 * @private |
1548 */ | 1561 */ |
1549 FileManager.prototype.setupCurrentDirectory_ = function() { | 1562 FileManager.prototype.setupCurrentDirectory_ = function() { |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 if (this.closeOnUnmount_ && !event.initial && | 2456 if (this.closeOnUnmount_ && !event.initial && |
2444 PathUtil.getRootPath(event.previousDirEntry.fullPath) != | 2457 PathUtil.getRootPath(event.previousDirEntry.fullPath) != |
2445 PathUtil.getRootPath(event.newDirEntry.fullPath)) { | 2458 PathUtil.getRootPath(event.newDirEntry.fullPath)) { |
2446 this.closeOnUnmount_ = false; | 2459 this.closeOnUnmount_ = false; |
2447 } | 2460 } |
2448 | 2461 |
2449 this.updateCommands(); | 2462 this.updateCommands(); |
2450 this.updateUnformattedDriveStatus_(); | 2463 this.updateUnformattedDriveStatus_(); |
2451 this.updateTitle_(); | 2464 this.updateTitle_(); |
2452 this.updateGearMenu_(); | 2465 this.updateGearMenu_(); |
| 2466 this.previewPanel_.currentPath_ = this.getCurrentDirectory(); |
2453 }; | 2467 }; |
2454 | 2468 |
2455 /** | 2469 /** |
2456 * Updates commands' states by emiting canExecute events. Should be used | 2470 * Updates commands' states by emiting canExecute events. Should be used |
2457 * only if there is need to reevaluate states without an user action, eg. | 2471 * only if there is need to reevaluate states without an user action, eg. |
2458 * external events. | 2472 * external events. |
2459 */ | 2473 */ |
2460 FileManager.prototype.updateCommands = function() { | 2474 FileManager.prototype.updateCommands = function() { |
2461 var commands = this.dialogDom_.querySelectorAll('command'); | 2475 var commands = this.dialogDom_.querySelectorAll('command'); |
2462 for (var i = 0; i < commands.length; i++) { | 2476 for (var i = 0; i < commands.length; i++) { |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 */ | 3938 */ |
3925 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3939 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3926 this.ctrlKeyPressed_ = flag; | 3940 this.ctrlKeyPressed_ = flag; |
3927 // Before the DOM is constructed, the key event can be handled. | 3941 // Before the DOM is constructed, the key event can be handled. |
3928 var cacheClearCommand = | 3942 var cacheClearCommand = |
3929 this.document_.querySelector('#drive-clear-local-cache'); | 3943 this.document_.querySelector('#drive-clear-local-cache'); |
3930 if (cacheClearCommand) | 3944 if (cacheClearCommand) |
3931 cacheClearCommand.canExecuteChange(); | 3945 cacheClearCommand.canExecuteChange(); |
3932 }; | 3946 }; |
3933 })(); | 3947 })(); |
OLD | NEW |