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

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

Powered by Google App Engine
This is Rietveld 408576698