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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 var controller = this.fileTransferController_ = | 441 var controller = this.fileTransferController_ = |
442 new FileTransferController(this.document_, | 442 new FileTransferController(this.document_, |
443 this.copyManager_, | 443 this.copyManager_, |
444 this.metadataCache_, | 444 this.metadataCache_, |
445 this.directoryModel_); | 445 this.directoryModel_); |
446 controller.attachDragSource(this.table_.list); | 446 controller.attachDragSource(this.table_.list); |
447 controller.attachFileListDropTarget(this.table_.list); | 447 controller.attachFileListDropTarget(this.table_.list); |
448 controller.attachDragSource(this.grid_); | 448 controller.attachDragSource(this.grid_); |
449 controller.attachFileListDropTarget(this.grid_); | 449 controller.attachFileListDropTarget(this.grid_); |
450 controller.attachTreeDropTarget(this.directoryTree_); | 450 controller.attachTreeDropTarget(this.directoryTree_); |
451 controller.attachVolumesDropTarget(this.volumeList_, true); | 451 controller.attachNavigationListDropTarget(this.navigationList_, true); |
452 controller.attachCopyPasteHandlers(); | 452 controller.attachCopyPasteHandlers(); |
453 controller.addEventListener('selection-copied', | 453 controller.addEventListener('selection-copied', |
454 this.blinkSelection.bind(this)); | 454 this.blinkSelection.bind(this)); |
455 controller.addEventListener('selection-cut', | 455 controller.addEventListener('selection-cut', |
456 this.blinkSelection.bind(this)); | 456 this.blinkSelection.bind(this)); |
457 }; | 457 }; |
458 | 458 |
459 /** | 459 /** |
460 * One-time initialization of context menus. | 460 * One-time initialization of context menus. |
461 * @private | 461 * @private |
462 */ | 462 */ |
463 FileManager.prototype.initContextMenus_ = function() { | 463 FileManager.prototype.initContextMenus_ = function() { |
464 this.fileContextMenu_ = this.dialogDom_.querySelector('#file-context-menu'); | 464 this.fileContextMenu_ = this.dialogDom_.querySelector('#file-context-menu'); |
465 cr.ui.Menu.decorate(this.fileContextMenu_); | 465 cr.ui.Menu.decorate(this.fileContextMenu_); |
466 | 466 |
467 cr.ui.contextMenuHandler.setContextMenu(this.grid_, this.fileContextMenu_); | 467 cr.ui.contextMenuHandler.setContextMenu(this.grid_, this.fileContextMenu_); |
468 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), | 468 cr.ui.contextMenuHandler.setContextMenu(this.table_.querySelector('.list'), |
469 this.fileContextMenu_); | 469 this.fileContextMenu_); |
470 cr.ui.contextMenuHandler.setContextMenu( | 470 cr.ui.contextMenuHandler.setContextMenu( |
471 this.document_.querySelector('.drive-welcome.page'), | 471 this.document_.querySelector('.drive-welcome.page'), |
472 this.fileContextMenu_); | 472 this.fileContextMenu_); |
473 | 473 |
474 this.rootsContextMenu_ = | 474 this.rootsContextMenu_ = |
475 this.dialogDom_.querySelector('#roots-context-menu'); | 475 this.dialogDom_.querySelector('#roots-context-menu'); |
476 cr.ui.Menu.decorate(this.rootsContextMenu_); | 476 cr.ui.Menu.decorate(this.rootsContextMenu_); |
477 this.volumeList_.setContextMenu(this.rootsContextMenu_); | 477 this.navigationList_.setContextMenu(this.rootsContextMenu_); |
478 | 478 |
479 this.directoryTreeContextMenu_ = | 479 this.directoryTreeContextMenu_ = |
480 this.dialogDom_.querySelector('#directory-tree-context-menu'); | 480 this.dialogDom_.querySelector('#directory-tree-context-menu'); |
481 cr.ui.Menu.decorate(this.directoryTreeContextMenu_); | 481 cr.ui.Menu.decorate(this.directoryTreeContextMenu_); |
482 this.directoryTree_.contextMenuForSubitems = this.directoryTreeContextMenu_; | 482 this.directoryTree_.contextMenuForSubitems = this.directoryTreeContextMenu_; |
483 | 483 |
484 this.textContextMenu_ = | 484 this.textContextMenu_ = |
485 this.dialogDom_.querySelector('#text-context-menu'); | 485 this.dialogDom_.querySelector('#text-context-menu'); |
486 cr.ui.Menu.decorate(this.textContextMenu_); | 486 cr.ui.Menu.decorate(this.textContextMenu_); |
487 | 487 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 558 |
559 CommandUtil.registerCommand(this.dialogContainer_, 'newfolder', | 559 CommandUtil.registerCommand(this.dialogContainer_, 'newfolder', |
560 Commands.newFolderCommand, this, this.directoryModel_); | 560 Commands.newFolderCommand, this, this.directoryModel_); |
561 | 561 |
562 CommandUtil.registerCommand(this.dialogContainer_, 'newwindow', | 562 CommandUtil.registerCommand(this.dialogContainer_, 'newwindow', |
563 Commands.newWindowCommand, this, this.directoryModel_); | 563 Commands.newWindowCommand, this, this.directoryModel_); |
564 | 564 |
565 CommandUtil.registerCommand(this.dialogContainer_, 'change-default-app', | 565 CommandUtil.registerCommand(this.dialogContainer_, 'change-default-app', |
566 Commands.changeDefaultAppCommand, this); | 566 Commands.changeDefaultAppCommand, this); |
567 | 567 |
568 CommandUtil.registerCommand(this.volumeList_, 'unmount', | 568 CommandUtil.registerCommand(this.navigationList_, 'unmount', |
569 Commands.unmountCommand, this.volumeList_, this); | 569 Commands.unmountCommand, this.navigationList_, this); |
570 | 570 |
571 CommandUtil.registerCommand(this.volumeList_, 'import-photos', | 571 CommandUtil.registerCommand(this.navigationList_, 'import-photos', |
572 Commands.importCommand, this.volumeList_); | 572 Commands.importCommand, this.navigationList_); |
573 | 573 |
574 CommandUtil.registerCommand(this.dialogContainer_, 'format', | 574 CommandUtil.registerCommand(this.dialogContainer_, 'format', |
575 Commands.formatCommand, this.volumeList_, this, | 575 Commands.formatCommand, this.navigationList_, this, |
576 this.directoryModel_); | 576 this.directoryModel_); |
577 | 577 |
578 CommandUtil.registerCommand(this.dialogContainer_, 'delete', | 578 CommandUtil.registerCommand(this.dialogContainer_, 'delete', |
579 Commands.deleteFileCommand, this); | 579 Commands.deleteFileCommand, this); |
580 | 580 |
581 CommandUtil.registerCommand(this.dialogContainer_, 'rename', | 581 CommandUtil.registerCommand(this.dialogContainer_, 'rename', |
582 Commands.renameFileCommand, this); | 582 Commands.renameFileCommand, this); |
583 | 583 |
584 CommandUtil.registerCommand(this.dialogContainer_, 'volume-help', | 584 CommandUtil.registerCommand(this.dialogContainer_, 'volume-help', |
585 Commands.volumeHelpCommand, this); | 585 Commands.volumeHelpCommand, this); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 CommandUtil.registerCommand(this.dialogContainer_, 'search', | 617 CommandUtil.registerCommand(this.dialogContainer_, 'search', |
618 Commands.searchCommand, this, | 618 Commands.searchCommand, this, |
619 this.dialogDom_.querySelector('#search-box')); | 619 this.dialogDom_.querySelector('#search-box')); |
620 | 620 |
621 // Register commands with CTRL-1..9 shortcuts for switching between | 621 // Register commands with CTRL-1..9 shortcuts for switching between |
622 // volumes. | 622 // volumes. |
623 for (var i = 1; i <= 9; i++) { | 623 for (var i = 1; i <= 9; i++) { |
624 CommandUtil.registerCommand(this.dialogContainer_, | 624 CommandUtil.registerCommand(this.dialogContainer_, |
625 'volume-switch-' + i, | 625 'volume-switch-' + i, |
626 Commands.volumeSwitchCommand, | 626 Commands.volumeSwitchCommand, |
627 this.volumeList_, | 627 this.navigationList_, |
628 i); | 628 i); |
629 } | 629 } |
630 | 630 |
631 CommandUtil.registerCommand(doc, 'zoom-in', Commands.zoomInCommand); | 631 CommandUtil.registerCommand(doc, 'zoom-in', Commands.zoomInCommand); |
632 CommandUtil.registerCommand(doc, 'zoom-out', Commands.zoomOutCommand); | 632 CommandUtil.registerCommand(doc, 'zoom-out', Commands.zoomOutCommand); |
633 CommandUtil.registerCommand(doc, 'zoom-reset', Commands.zoomResetCommand); | 633 CommandUtil.registerCommand(doc, 'zoom-reset', Commands.zoomResetCommand); |
634 | 634 |
635 CommandUtil.registerCommand(this.dialogContainer_, 'cut', | 635 CommandUtil.registerCommand(this.dialogContainer_, 'cut', |
636 Commands.defaultCommand, doc); | 636 Commands.defaultCommand, doc); |
637 CommandUtil.registerCommand(this.dialogContainer_, 'copy', | 637 CommandUtil.registerCommand(this.dialogContainer_, 'copy', |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 /** | 1174 /** |
1175 * @private | 1175 * @private |
1176 */ | 1176 */ |
1177 FileManager.prototype.initSidebar_ = function() { | 1177 FileManager.prototype.initSidebar_ = function() { |
1178 this.directoryTree_ = this.dialogDom_.querySelector('#directory-tree'); | 1178 this.directoryTree_ = this.dialogDom_.querySelector('#directory-tree'); |
1179 DirectoryTree.decorate(this.directoryTree_, this.directoryModel_); | 1179 DirectoryTree.decorate(this.directoryTree_, this.directoryModel_); |
1180 this.directoryTree_.addEventListener('content-updated', function() { | 1180 this.directoryTree_.addEventListener('content-updated', function() { |
1181 this.updateMiddleBarVisibility_(true); | 1181 this.updateMiddleBarVisibility_(true); |
1182 }.bind(this)); | 1182 }.bind(this)); |
1183 | 1183 |
1184 this.volumeList_ = this.dialogDom_.querySelector('#volume-list'); | 1184 this.navigationList_ = this.dialogDom_.querySelector('#volume-list'); |
1185 VolumeList.decorate(this.volumeList_, | 1185 NavigationList.decorate(this.navigationList_, |
1186 this.directoryModel_, | 1186 this.directoryModel_, |
1187 this.folderShortcutsModel_); | 1187 this.folderShortcutsModel_); |
1188 }; | 1188 }; |
1189 | 1189 |
1190 /** | 1190 /** |
1191 * @param {boolean=} opt_delayed If true, updating is delayed by 500ms. | 1191 * @param {boolean=} opt_delayed If true, updating is delayed by 500ms. |
1192 * @private | 1192 * @private |
1193 */ | 1193 */ |
1194 FileManager.prototype.updateMiddleBarVisibility_ = function(opt_delayed) { | 1194 FileManager.prototype.updateMiddleBarVisibility_ = function(opt_delayed) { |
1195 if (this.updateMiddleBarVisibilityTimer_) { | 1195 if (this.updateMiddleBarVisibilityTimer_) { |
1196 clearTimeout(this.updateMiddleBarVisibilityTimer_); | 1196 clearTimeout(this.updateMiddleBarVisibilityTimer_); |
1197 this.updateMiddleBarVisibilityTimer_ = null; | 1197 this.updateMiddleBarVisibilityTimer_ = null; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 FileManager.prototype.onResize_ = function() { | 1496 FileManager.prototype.onResize_ = function() { |
1497 if (this.listType_ == FileManager.ListType.THUMBNAIL) | 1497 if (this.listType_ == FileManager.ListType.THUMBNAIL) |
1498 this.grid_.relayout(); | 1498 this.grid_.relayout(); |
1499 else | 1499 else |
1500 this.table_.relayout(); | 1500 this.table_.relayout(); |
1501 | 1501 |
1502 // May not be available during initialization. | 1502 // May not be available during initialization. |
1503 if (this.directoryTree_) | 1503 if (this.directoryTree_) |
1504 this.directoryTree_.relayout(); | 1504 this.directoryTree_.relayout(); |
1505 | 1505 |
1506 // TODO(mtomasz, yoshiki): Initialize volume list earlier, before | 1506 // TODO(mtomasz, yoshiki): Initialize navigation list earlier, before |
1507 // file system is available. | 1507 // file system is available. |
1508 if (this.volumeList_) | 1508 if (this.navigationList_) |
1509 this.volumeList_.redraw(); | 1509 this.navigationList_.redraw(); |
1510 | 1510 |
1511 // Hide the search box if there is not enough space. | 1511 // Hide the search box if there is not enough space. |
1512 this.searchBoxWrapper_.classList.toggle( | 1512 this.searchBoxWrapper_.classList.toggle( |
1513 'too-short', | 1513 'too-short', |
1514 this.searchBoxWrapper_.clientWidth < 100); | 1514 this.searchBoxWrapper_.clientWidth < 100); |
1515 | 1515 |
1516 this.searchBreadcrumbs_.truncate(); | 1516 this.searchBreadcrumbs_.truncate(); |
1517 }; | 1517 }; |
1518 | 1518 |
1519 /** | 1519 /** |
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3868 */ | 3868 */ |
3869 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3869 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3870 this.ctrlKeyPressed_ = flag; | 3870 this.ctrlKeyPressed_ = flag; |
3871 // Before the DOM is constructed, the key event can be handled. | 3871 // Before the DOM is constructed, the key event can be handled. |
3872 var cacheClearCommand = | 3872 var cacheClearCommand = |
3873 this.document_.querySelector('#drive-clear-local-cache'); | 3873 this.document_.querySelector('#drive-clear-local-cache'); |
3874 if (cacheClearCommand) | 3874 if (cacheClearCommand) |
3875 cacheClearCommand.canExecuteChange(); | 3875 cacheClearCommand.canExecuteChange(); |
3876 }; | 3876 }; |
3877 })(); | 3877 })(); |
OLD | NEW |