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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 if (!util.platform.newUI()) { | 762 if (!util.platform.newUI()) { |
763 this.breadcrumbs_ = new BreadcrumbsController( | 763 this.breadcrumbs_ = new BreadcrumbsController( |
764 dom.querySelector('#dir-breadcrumbs'), this.metadataCache_); | 764 dom.querySelector('#dir-breadcrumbs'), this.metadataCache_); |
765 this.breadcrumbs_.addEventListener( | 765 this.breadcrumbs_.addEventListener( |
766 'pathclick', this.onBreadcrumbClick_.bind(this)); | 766 'pathclick', this.onBreadcrumbClick_.bind(this)); |
767 } | 767 } |
768 this.searchBreadcrumbs_ = new BreadcrumbsController( | 768 this.searchBreadcrumbs_ = new BreadcrumbsController( |
769 dom.querySelector('#search-breadcrumbs'), this.metadataCache_); | 769 dom.querySelector('#search-breadcrumbs'), this.metadataCache_); |
770 this.searchBreadcrumbs_.addEventListener( | 770 this.searchBreadcrumbs_.addEventListener( |
771 'pathclick', this.onBreadcrumbClick_.bind(this)); | 771 'pathclick', this.onBreadcrumbClick_.bind(this)); |
772 this.searchBreadcrumbs_.setHideLast(true); | 772 if (!util.platform.newUI()) |
| 773 this.searchBreadcrumbs_.setHideLast(true); |
| 774 else |
| 775 this.searchBreadcrumbs_.setHideLast(false); |
773 | 776 |
774 var fullPage = this.dialogType == DialogType.FULL_PAGE; | 777 var fullPage = this.dialogType == DialogType.FULL_PAGE; |
775 FileTable.decorate(this.table_, this.metadataCache_, fullPage); | 778 FileTable.decorate(this.table_, this.metadataCache_, fullPage); |
776 FileGrid.decorate(this.grid_, this.metadataCache_); | 779 FileGrid.decorate(this.grid_, this.metadataCache_); |
777 | 780 |
778 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); | 781 this.document_.addEventListener('keydown', this.onKeyDown_.bind(this)); |
779 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this)); | 782 this.document_.addEventListener('keyup', this.onKeyUp_.bind(this)); |
780 | 783 |
781 // This capturing event is only used to distinguish focusing using | 784 // This capturing event is only used to distinguish focusing using |
782 // keyboard from focusing using mouse. | 785 // keyboard from focusing using mouse. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 setTimeout(this.dailyUpdateModificationTime_.bind(this), | 1058 setTimeout(this.dailyUpdateModificationTime_.bind(this), |
1056 today.getTime() + MILLISECONDS_IN_DAY - Date.now() + 1000); | 1059 today.getTime() + MILLISECONDS_IN_DAY - Date.now() + 1000); |
1057 }; | 1060 }; |
1058 | 1061 |
1059 /** | 1062 /** |
1060 * @private | 1063 * @private |
1061 */ | 1064 */ |
1062 FileManager.prototype.initSidebar_ = function() { | 1065 FileManager.prototype.initSidebar_ = function() { |
1063 this.directoryTree_ = this.dialogDom_.querySelector('#directory-tree'); | 1066 this.directoryTree_ = this.dialogDom_.querySelector('#directory-tree'); |
1064 DirectoryTree.decorate(this.directoryTree_, this.directoryModel_); | 1067 DirectoryTree.decorate(this.directoryTree_, this.directoryModel_); |
1065 this.directoryTree_.addEventListener('content-updated', function() { | |
1066 this.updateMiddleBarVisibility_(true); | |
1067 }.bind(this)); | |
1068 if (util.platform.newUI()) { | 1068 if (util.platform.newUI()) { |
| 1069 this.directoryTree_.addEventListener('content-updated', function() { |
| 1070 this.updateMiddleBarVisibility_(true); |
| 1071 }.bind(this)); |
| 1072 |
1069 this.volumeList_ = this.dialogDom_.querySelector('#volume-list'); | 1073 this.volumeList_ = this.dialogDom_.querySelector('#volume-list'); |
1070 VolumeList.decorate(this.volumeList_, this.directoryModel_); | 1074 VolumeList.decorate(this.volumeList_, this.directoryModel_); |
1071 } | 1075 } |
1072 }; | 1076 }; |
1073 | 1077 |
1074 /** | 1078 /** |
1075 * @param {boolean=} opt_delayed If true, updating is delayed by 500ms. | 1079 * @param {boolean=} opt_delayed If true, updating is delayed by 500ms. |
1076 * @private | 1080 * @private |
1077 */ | 1081 */ |
1078 FileManager.prototype.updateMiddleBarVisibility_ = function(opt_delayed) { | 1082 FileManager.prototype.updateMiddleBarVisibility_ = function(opt_delayed) { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 g.columns = 0; | 1425 g.columns = 0; |
1422 g.redraw(); | 1426 g.redraw(); |
1423 g.endBatchUpdates(); | 1427 g.endBatchUpdates(); |
1424 }, 0); | 1428 }, 0); |
1425 } else { | 1429 } else { |
1426 if (util.platform.newUI()) { | 1430 if (util.platform.newUI()) { |
1427 if (this.table_.clientWidth > 0) | 1431 if (this.table_.clientWidth > 0) |
1428 this.table_.normalizeColumns(); | 1432 this.table_.normalizeColumns(); |
1429 } | 1433 } |
1430 this.table_.redraw(); | 1434 this.table_.redraw(); |
1431 this.volumeList_.redraw(); | |
1432 } | 1435 } |
1433 | 1436 |
1434 if (!util.platform.newUI()) | 1437 if (!util.platform.newUI()) |
1435 this.breadcrumbs_.truncate(); | 1438 this.breadcrumbs_.truncate(); |
| 1439 else |
| 1440 this.volumeList_.redraw(); |
1436 | 1441 |
1437 // Hide the search box if there is not enough space. | 1442 // Hide the search box if there is not enough space. |
1438 if (util.platform.newUI()) | 1443 if (util.platform.newUI()) |
1439 this.searchBox_.hidden = this.searchBoxWrapper_.clientWidth < 100; | 1444 this.searchBox_.hidden = this.searchBoxWrapper_.clientWidth < 100; |
1440 | 1445 |
1441 this.searchBreadcrumbs_.truncate(); | 1446 this.searchBreadcrumbs_.truncate(); |
1442 | 1447 |
1443 this.updateWindowState_(); | 1448 this.updateWindowState_(); |
1444 }; | 1449 }; |
1445 | 1450 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 | 2043 |
2039 /** | 2044 /** |
2040 * Return URL of the current directory or null. | 2045 * Return URL of the current directory or null. |
2041 * @return {string} URL representing the current directory. | 2046 * @return {string} URL representing the current directory. |
2042 */ | 2047 */ |
2043 FileManager.prototype.getCurrentDirectoryURL = function() { | 2048 FileManager.prototype.getCurrentDirectoryURL = function() { |
2044 return this.directoryModel_ && | 2049 return this.directoryModel_ && |
2045 this.directoryModel_.getCurrentDirectoryURL(); | 2050 this.directoryModel_.getCurrentDirectoryURL(); |
2046 }; | 2051 }; |
2047 | 2052 |
| 2053 /** |
| 2054 * Return DirectoryEntry of the current directory or null. |
| 2055 * @return {DirectoryEntry} DirectoryEntry of the current directory. Returns |
| 2056 * null if the directory model is not ready or the current directory is |
| 2057 * not set. |
| 2058 */ |
| 2059 FileManager.prototype.getCurrentDirectoryEntry = function() { |
| 2060 return this.directoryModel_ && |
| 2061 this.directoryModel_.getCurrentDirEntry(); |
| 2062 }; |
| 2063 |
2048 FileManager.prototype.deleteSelection = function() { | 2064 FileManager.prototype.deleteSelection = function() { |
2049 // TODO(mtomasz): Remove this temporary dialog. crbug.com/167364 | 2065 // TODO(mtomasz): Remove this temporary dialog. crbug.com/167364 |
2050 var entries = this.getSelection().entries; | 2066 var entries = this.getSelection().entries; |
2051 var message = entries.length == 1 ? | 2067 var message = entries.length == 1 ? |
2052 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) : | 2068 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) : |
2053 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length); | 2069 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length); |
2054 this.confirm.show(message, function() { | 2070 this.confirm.show(message, function() { |
2055 this.copyManager_.deleteEntries(entries); | 2071 this.copyManager_.deleteEntries(entries); |
2056 }.bind(this)); | 2072 }.bind(this)); |
2057 }; | 2073 }; |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2540 if (this.scanUpdatedAtLeastOnceOrCompleted_) | 2556 if (this.scanUpdatedAtLeastOnceOrCompleted_) |
2541 return; | 2557 return; |
2542 this.scanUpdatedAtLeastOnceOrCompleted_ = true; | 2558 this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
2543 this.scanInProgress_ = false; | 2559 this.scanInProgress_ = false; |
2544 if (this.scanUpdatedTimer_) { | 2560 if (this.scanUpdatedTimer_) { |
2545 clearTimeout(this.scanUpdatedTimer_); | 2561 clearTimeout(this.scanUpdatedTimer_); |
2546 this.scanUpdatedTimer_ = null; | 2562 this.scanUpdatedTimer_ = null; |
2547 } | 2563 } |
2548 this.table_.list.endBatchUpdates(); | 2564 this.table_.list.endBatchUpdates(); |
2549 this.grid_.endBatchUpdates(); | 2565 this.grid_.endBatchUpdates(); |
2550 this.updateMiddleBarVisibility_(); | 2566 if (util.platform.newUI()) |
| 2567 this.updateMiddleBarVisibility_(); |
2551 this.scanCompletedTimer_ = null; | 2568 this.scanCompletedTimer_ = null; |
2552 }.bind(this), 50); | 2569 }.bind(this), 50); |
2553 }; | 2570 }; |
2554 | 2571 |
2555 /** | 2572 /** |
2556 * @private | 2573 * @private |
2557 */ | 2574 */ |
2558 FileManager.prototype.onScanUpdated_ = function() { | 2575 FileManager.prototype.onScanUpdated_ = function() { |
2559 if (!this.scanInProgress_) { | 2576 if (!this.scanInProgress_) { |
2560 console.error('Scan-updated event recieved. But scan is not started.'); | 2577 console.error('Scan-updated event recieved. But scan is not started.'); |
(...skipping 12 matching lines...) Expand all Loading... |
2573 return; | 2590 return; |
2574 if (this.scanCompletedTimer_) { | 2591 if (this.scanCompletedTimer_) { |
2575 clearTimeout(this.scanCompletedTimer_); | 2592 clearTimeout(this.scanCompletedTimer_); |
2576 this.scanCompletedTimer_ = null; | 2593 this.scanCompletedTimer_ = null; |
2577 } | 2594 } |
2578 this.scanUpdatedAtLeastOnceOrCompleted_ = true; | 2595 this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
2579 this.scanInProgress_ = false; | 2596 this.scanInProgress_ = false; |
2580 this.hideSpinnerLater_(); | 2597 this.hideSpinnerLater_(); |
2581 this.table_.list.endBatchUpdates(); | 2598 this.table_.list.endBatchUpdates(); |
2582 this.grid_.endBatchUpdates(); | 2599 this.grid_.endBatchUpdates(); |
2583 this.updateMiddleBarVisibility_(); | 2600 if (util.platform.newUI()) |
| 2601 this.updateMiddleBarVisibility_(); |
2584 this.scanUpdatedTimer_ = null; | 2602 this.scanUpdatedTimer_ = null; |
2585 }.bind(this), 200); | 2603 }.bind(this), 200); |
2586 }; | 2604 }; |
2587 | 2605 |
2588 /** | 2606 /** |
2589 * @private | 2607 * @private |
2590 */ | 2608 */ |
2591 FileManager.prototype.onScanCancelled_ = function() { | 2609 FileManager.prototype.onScanCancelled_ = function() { |
2592 if (!this.scanInProgress_) { | 2610 if (!this.scanInProgress_) { |
2593 console.error('Scan-cancelled event recieved. But scan is not started.'); | 2611 console.error('Scan-cancelled event recieved. But scan is not started.'); |
2594 return; | 2612 return; |
2595 } | 2613 } |
2596 | 2614 |
2597 this.hideSpinnerLater_(); | 2615 this.hideSpinnerLater_(); |
2598 if (this.scanCompletedTimer_) { | 2616 if (this.scanCompletedTimer_) { |
2599 clearTimeout(this.scanCompletedTimer_); | 2617 clearTimeout(this.scanCompletedTimer_); |
2600 this.scanCompletedTimer_ = null; | 2618 this.scanCompletedTimer_ = null; |
2601 } | 2619 } |
2602 if (this.scanUpdatedTimer_) { | 2620 if (this.scanUpdatedTimer_) { |
2603 clearTimeout(this.scanUpdatedTimer_); | 2621 clearTimeout(this.scanUpdatedTimer_); |
2604 this.scanUpdatedTimer_ = null; | 2622 this.scanUpdatedTimer_ = null; |
2605 } | 2623 } |
2606 // Finish unfinished batch updates. | 2624 // Finish unfinished batch updates. |
2607 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { | 2625 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
2608 this.scanUpdatedAtLeastOnceOrCompleted_ = true; | 2626 this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
2609 this.scanInProgress_ = false; | 2627 this.scanInProgress_ = false; |
2610 this.table_.list.endBatchUpdates(); | 2628 this.table_.list.endBatchUpdates(); |
2611 this.grid_.endBatchUpdates(); | 2629 this.grid_.endBatchUpdates(); |
2612 this.updateMiddleBarVisibility_(); | 2630 if (util.platform.newUI()) |
| 2631 this.updateMiddleBarVisibility_(); |
2613 } | 2632 } |
2614 }; | 2633 }; |
2615 | 2634 |
2616 /** | 2635 /** |
2617 * @private | 2636 * @private |
2618 */ | 2637 */ |
2619 FileManager.prototype.cancelSpinnerTimeout_ = function() { | 2638 FileManager.prototype.cancelSpinnerTimeout_ = function() { |
2620 if (this.showSpinnerTimeout_) { | 2639 if (this.showSpinnerTimeout_) { |
2621 clearTimeout(this.showSpinnerTimeout_); | 2640 clearTimeout(this.showSpinnerTimeout_); |
2622 this.showSpinnerTimeout_ = null; | 2641 this.showSpinnerTimeout_ = null; |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 * Set the flag expressing whether the ctrl key is pressed or not. | 3680 * Set the flag expressing whether the ctrl key is pressed or not. |
3662 * @param {boolean} flag New value of the flag | 3681 * @param {boolean} flag New value of the flag |
3663 * @private | 3682 * @private |
3664 */ | 3683 */ |
3665 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3684 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3666 this.ctrlKeyPressed_ = flag; | 3685 this.ctrlKeyPressed_ = flag; |
3667 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); | 3686 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); |
3668 this.document_.querySelector('#drive-reload').canExecuteChange(); | 3687 this.document_.querySelector('#drive-reload').canExecuteChange(); |
3669 }; | 3688 }; |
3670 })(); | 3689 })(); |
OLD | NEW |