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 * FileManager constructor. | 8 * FileManager constructor. |
9 * | 9 * |
10 * FileManager objects encapsulate the functionality of the file selector | 10 * FileManager objects encapsulate the functionality of the file selector |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 this.selectionHandler_.onFileSelectionChanged.bind( | 992 this.selectionHandler_.onFileSelectionChanged.bind( |
993 this.selectionHandler_)); | 993 this.selectionHandler_)); |
994 | 994 |
995 this.initList_(this.grid_); | 995 this.initList_(this.grid_); |
996 this.initList_(this.table_.list); | 996 this.initList_(this.table_.list); |
997 | 997 |
998 var fileListFocusBound = this.onFileListFocus_.bind(this); | 998 var fileListFocusBound = this.onFileListFocus_.bind(this); |
999 this.table_.list.addEventListener('focus', fileListFocusBound); | 999 this.table_.list.addEventListener('focus', fileListFocusBound); |
1000 this.grid_.addEventListener('focus', fileListFocusBound); | 1000 this.grid_.addEventListener('focus', fileListFocusBound); |
1001 | 1001 |
1002 var dragStartBound = this.onDragStart_.bind(this); | 1002 var draggingBound = this.onDragging_.bind(this); |
1003 this.table_.list.addEventListener('dragstart', dragStartBound); | 1003 var dragEndBound = this.onDragEnd_.bind(this); |
1004 this.grid_.addEventListener('dragstart', dragStartBound); | |
1005 | 1004 |
1006 var dragEndBound = this.onDragEnd_.bind(this); | 1005 // Listen to drag events to hide preview panel while user is dragging files. |
| 1006 // Files.app prevents default actions in 'dragstart' in some situations, |
| 1007 // so we listen to 'drag' to know the list is actually being dragged. |
| 1008 this.table_.list.addEventListener('drag', draggingBound); |
| 1009 this.grid_.addEventListener('drag', draggingBound); |
1007 this.table_.list.addEventListener('dragend', dragEndBound); | 1010 this.table_.list.addEventListener('dragend', dragEndBound); |
1008 this.grid_.addEventListener('dragend', dragEndBound); | 1011 this.grid_.addEventListener('dragend', dragEndBound); |
1009 // This event is published by DragSelector because drag end event is not | 1012 |
1010 // published at the end of drag selection. | 1013 // Listen to dragselection events to hide preview panel while the user is |
| 1014 // selecting files by drag operation. |
| 1015 this.table_.list.addEventListener('dragselectionstart', draggingBound); |
| 1016 this.grid_.addEventListener('dragselectionstart', draggingBound); |
1011 this.table_.list.addEventListener('dragselectionend', dragEndBound); | 1017 this.table_.list.addEventListener('dragselectionend', dragEndBound); |
1012 this.grid_.addEventListener('dragselectionend', dragEndBound); | 1018 this.grid_.addEventListener('dragselectionend', dragEndBound); |
1013 | 1019 |
1014 // TODO(mtomasz, yoshiki): Create navigation list earlier, and here just | 1020 // TODO(mtomasz, yoshiki): Create navigation list earlier, and here just |
1015 // attach the directory model. | 1021 // attach the directory model. |
1016 this.initNavigationList_(); | 1022 this.initNavigationList_(); |
1017 | 1023 |
1018 this.table_.addEventListener('column-resize-end', | 1024 this.table_.addEventListener('column-resize-end', |
1019 this.updateStartupPrefs_.bind(this)); | 1025 this.updateStartupPrefs_.bind(this)); |
1020 | 1026 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 if (this.table_) | 1402 if (this.table_) |
1397 this.table_.setBottomMarginForPanel(panelHeight); | 1403 this.table_.setBottomMarginForPanel(panelHeight); |
1398 | 1404 |
1399 if (this.directoryTree_) { | 1405 if (this.directoryTree_) { |
1400 this.directoryTree_.setBottomMarginForPanel(panelHeight); | 1406 this.directoryTree_.setBottomMarginForPanel(panelHeight); |
1401 this.ensureDirectoryTreeItemNotBehindPreviewPanel_(); | 1407 this.ensureDirectoryTreeItemNotBehindPreviewPanel_(); |
1402 } | 1408 } |
1403 }; | 1409 }; |
1404 | 1410 |
1405 /** | 1411 /** |
1406 * Invoked when the drag is started on the list or the grid. | 1412 * Invoked while the drag is being performed on the list or the grid. |
| 1413 * Note: this method may be called multiple times before onDragEnd_(). |
1407 * @private | 1414 * @private |
1408 */ | 1415 */ |
1409 FileManager.prototype.onDragStart_ = function() { | 1416 FileManager.prototype.onDragging_ = function() { |
1410 // On open file dialog, the preview panel is always shown. | 1417 // On open file dialog, the preview panel is always shown. |
1411 if (DialogType.isOpenDialog(this.dialogType)) | 1418 if (DialogType.isOpenDialog(this.dialogType)) |
1412 return; | 1419 return; |
1413 this.previewPanel_.visibilityType = | 1420 this.previewPanel_.visibilityType = |
1414 PreviewPanel.VisibilityType.ALWAYS_HIDDEN; | 1421 PreviewPanel.VisibilityType.ALWAYS_HIDDEN; |
1415 }; | 1422 }; |
1416 | 1423 |
1417 /** | 1424 /** |
1418 * Invoked when the drag is ended on the list or the grid. | 1425 * Invoked when the drag is ended on the list or the grid. |
1419 * @private | 1426 * @private |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 callback(this.preferences_); | 3704 callback(this.preferences_); |
3698 return; | 3705 return; |
3699 } | 3706 } |
3700 | 3707 |
3701 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3708 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
3702 this.preferences_ = prefs; | 3709 this.preferences_ = prefs; |
3703 callback(prefs); | 3710 callback(prefs); |
3704 }.bind(this)); | 3711 }.bind(this)); |
3705 }; | 3712 }; |
3706 })(); | 3713 })(); |
OLD | NEW |