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 /** | 5 /** |
6 * FileManager constructor. | 6 * FileManager constructor. |
7 * | 7 * |
8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 this.setupCurrentDirectory_( | 499 this.setupCurrentDirectory_( |
500 invokeHandler, true /* blankWhileOpeningAFile */); | 500 invokeHandler, true /* blankWhileOpeningAFile */); |
501 } | 501 } |
502 | 502 |
503 this.summarizeSelection_(); | 503 this.summarizeSelection_(); |
504 | 504 |
505 var sortField = | 505 var sortField = |
506 window.localStorage['sort-field-' + this.dialogType_] || 'cachedMtime_'; | 506 window.localStorage['sort-field-' + this.dialogType_] || 'cachedMtime_'; |
507 var sortDirection = | 507 var sortDirection = |
508 window.localStorage['sort-direction-' + this.dialogType_] || 'desc'; | 508 window.localStorage['sort-direction-' + this.dialogType_] || 'desc'; |
509 this.directoryModel_.fileList.sort(sortField, sortDirection); | 509 this.directoryModel_.sortFileList(sortField, sortDirection); |
510 | 510 |
511 this.refocus(); | 511 this.refocus(); |
512 | 512 |
513 this.metadataProvider_ = | 513 this.metadataProvider_ = |
514 new MetadataProvider(this.filesystem_.root.toURL()); | 514 new MetadataProvider(this.filesystem_.root.toURL()); |
515 | 515 |
516 // PyAuto tests monitor this state by polling this variable | 516 // PyAuto tests monitor this state by polling this variable |
517 this.__defineGetter__('workerInitialized_', function() { | 517 this.__defineGetter__('workerInitialized_', function() { |
518 return self.getMetadataProvider().isInitialized(); | 518 return self.getMetadataProvider().isInitialized(); |
519 }); | 519 }); |
520 | 520 |
521 this.directoryModel_.offline = this.isOffline(); | 521 this.directoryModel_.setOffline(this.isOffline()); |
522 | 522 |
523 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) | 523 if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) |
524 this.initDataTransferOperations_(); | 524 this.initDataTransferOperations_(); |
525 | 525 |
526 this.table_.endBatchUpdates(); | 526 this.table_.endBatchUpdates(); |
527 this.grid_.endBatchUpdates(); | 527 this.grid_.endBatchUpdates(); |
528 | 528 |
529 metrics.recordInterval('Load.DOM'); | 529 metrics.recordInterval('Load.DOM'); |
530 metrics.recordInterval('Load.Total'); | 530 metrics.recordInterval('Load.Total'); |
531 }; | 531 }; |
532 | 532 |
533 FileManager.prototype.initDataTransferOperations_ = function() { | 533 FileManager.prototype.initDataTransferOperations_ = function() { |
534 this.copyManager_ = new FileCopyManager(this.filesystem_.root); | 534 this.copyManager_ = new FileCopyManager(this.filesystem_.root); |
535 this.copyManager_.addEventListener('copy-progress', | 535 this.copyManager_.addEventListener('copy-progress', |
536 this.onCopyProgress_.bind(this)); | 536 this.onCopyProgress_.bind(this)); |
537 this.copyManager_.addEventListener('copy-operation-complete', | 537 this.copyManager_.addEventListener('copy-operation-complete', |
538 this.onCopyManagerOperationComplete_.bind(this)); | 538 this.onCopyManagerOperationComplete_.bind(this)); |
539 | 539 |
540 var controller = this.fileTransferController_ = new FileTransferController( | 540 var controller = this.fileTransferController_ = new FileTransferController( |
541 this.directoryModel_.fileList, | 541 this.directoryModel_.getFileList(), |
542 this.directoryModel_.fileListSelection, | 542 this.directoryModel_.getFileListSelection(), |
543 GridItem.bind(null, this), | 543 GridItem.bind(null, this), |
544 this.copyManager_, | 544 this.copyManager_, |
545 this.directoryModel_); | 545 this.directoryModel_); |
546 controller.attachDragSource(this.table_.list); | 546 controller.attachDragSource(this.table_.list); |
547 controller.attachDropTarget(this.table_.list); | 547 controller.attachDropTarget(this.table_.list); |
548 controller.attachDragSource(this.grid_); | 548 controller.attachDragSource(this.grid_); |
549 controller.attachDropTarget(this.grid_); | 549 controller.attachDropTarget(this.grid_); |
550 controller.attachCopyPasteHandlers(this.document_); | 550 controller.attachCopyPasteHandlers(this.document_); |
551 controller.addEventListener('selection-copied', | 551 controller.addEventListener('selection-copied', |
552 this.blinkSelection.bind(this)); | 552 this.blinkSelection.bind(this)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || | 713 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || |
714 this.dialogType_ == FileManager.DialogType.SELECT_FOLDER || | 714 this.dialogType_ == FileManager.DialogType.SELECT_FOLDER || |
715 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE; | 715 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE; |
716 | 716 |
717 this.directoryModel_ = new DirectoryModel( | 717 this.directoryModel_ = new DirectoryModel( |
718 this.filesystem_.root, | 718 this.filesystem_.root, |
719 sigleSelection, | 719 sigleSelection, |
720 str('ENABLE_GDATA') == '1', | 720 str('ENABLE_GDATA') == '1', |
721 this.metadataCache_); | 721 this.metadataCache_); |
722 | 722 |
723 var dataModel = this.directoryModel_.fileList; | 723 var dataModel = this.directoryModel_.getFileList(); |
724 var collator = this.collator_; | 724 var collator = this.collator_; |
725 // TODO(dgozman): refactor comparison functions together with | 725 // TODO(dgozman): refactor comparison functions together with |
726 // render/update/display. | 726 // render/update/display. |
727 dataModel.setCompareFunction('name', function(a, b) { | 727 dataModel.setCompareFunction('name', function(a, b) { |
728 return collator.compare(a.name, b.name); | 728 return collator.compare(a.name, b.name); |
729 }); | 729 }); |
730 dataModel.setCompareFunction('modificationTime', | 730 dataModel.setCompareFunction('modificationTime', |
731 this.compareMtime_.bind(this)); | 731 this.compareMtime_.bind(this)); |
732 dataModel.setCompareFunction('size', | 732 dataModel.setCompareFunction('size', |
733 this.compareSize_.bind(this)); | 733 this.compareSize_.bind(this)); |
734 dataModel.setCompareFunction('type', | 734 dataModel.setCompareFunction('type', |
735 this.compareType_.bind(this)); | 735 this.compareType_.bind(this)); |
736 | 736 |
737 dataModel.addEventListener('splice', | 737 dataModel.addEventListener('splice', |
738 this.onDataModelSplice_.bind(this)); | 738 this.onDataModelSplice_.bind(this)); |
739 dataModel.addEventListener('permuted', | 739 dataModel.addEventListener('permuted', |
740 this.onDataModelPermuted_.bind(this)); | 740 this.onDataModelPermuted_.bind(this)); |
741 | 741 |
742 this.directoryModel_.fileListSelection.addEventListener( | 742 this.directoryModel_.getFileListSelection().addEventListener( |
743 'change', this.onSelectionChanged_.bind(this)); | 743 'change', this.onSelectionChanged_.bind(this)); |
744 | 744 |
745 this.directoryModel_.autoSelectIndex = | 745 this.directoryModel_.setAutoSelectIndex( |
746 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ? -1 : 0; | 746 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ? -1 : 0); |
747 | 747 |
748 this.initTable_(); | 748 this.initTable_(); |
749 this.initGrid_(); | 749 this.initGrid_(); |
750 this.initRootsList_(); | 750 this.initRootsList_(); |
751 | 751 |
752 var listType = FileManager.ListType.DETAIL; | 752 var listType = FileManager.ListType.DETAIL; |
753 if (FileManager.DialogType.isModal(this.dialogType_)) | 753 if (FileManager.DialogType.isModal(this.dialogType_)) |
754 listType = window.localStorage['listType-' + this.dialogType_] || | 754 listType = window.localStorage['listType-' + this.dialogType_] || |
755 FileManager.ListType.DETAIL; | 755 FileManager.ListType.DETAIL; |
756 this.setListType(listType); | 756 this.setListType(listType); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 learnMore.appendChild(learnMoreLink); | 877 learnMore.appendChild(learnMoreLink); |
878 }; | 878 }; |
879 | 879 |
880 FileManager.prototype.onDataModelSplice_ = function(event) { | 880 FileManager.prototype.onDataModelSplice_ = function(event) { |
881 var checkbox = this.document_.querySelector('#select-all-checkbox'); | 881 var checkbox = this.document_.querySelector('#select-all-checkbox'); |
882 if (checkbox) | 882 if (checkbox) |
883 this.updateSelectAllCheckboxState_(checkbox); | 883 this.updateSelectAllCheckboxState_(checkbox); |
884 }; | 884 }; |
885 | 885 |
886 FileManager.prototype.onDataModelPermuted_ = function(event) { | 886 FileManager.prototype.onDataModelPermuted_ = function(event) { |
887 var sortStatus = this.directoryModel_.fileList.sortStatus; | 887 var sortStatus = this.directoryModel_.getFileList().sortStatus; |
888 window.localStorage['sort-field-' + this.dialogType_] = sortStatus.field; | 888 window.localStorage['sort-field-' + this.dialogType_] = sortStatus.field; |
889 window.localStorage['sort-direction-' + this.dialogType_] = | 889 window.localStorage['sort-direction-' + this.dialogType_] = |
890 sortStatus.direction; | 890 sortStatus.direction; |
891 }; | 891 }; |
892 | 892 |
893 /** | 893 /** |
894 * Compare by mtime first, then by name. | 894 * Compare by mtime first, then by name. |
895 */ | 895 */ |
896 FileManager.prototype.compareMtime_ = function(a, b) { | 896 FileManager.prototype.compareMtime_ = function(a, b) { |
897 var aTime = this.metadataCache_.getCached(a, 'filesystem').modificationTime; | 897 var aTime = this.metadataCache_.getCached(a, 'filesystem').modificationTime; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 window.localStorage['listType-' + this.dialogType_] = type; | 1149 window.localStorage['listType-' + this.dialogType_] = type; |
1150 | 1150 |
1151 this.table_.list.startBatchUpdates(); | 1151 this.table_.list.startBatchUpdates(); |
1152 this.grid_.startBatchUpdates(); | 1152 this.grid_.startBatchUpdates(); |
1153 | 1153 |
1154 // TODO(dzvorygin): style.display and dataModel setting order shouldn't | 1154 // TODO(dzvorygin): style.display and dataModel setting order shouldn't |
1155 // cause any UI bugs. Currently, the only right way is first to set display | 1155 // cause any UI bugs. Currently, the only right way is first to set display |
1156 // style and only then set dataModel. | 1156 // style and only then set dataModel. |
1157 | 1157 |
1158 if (type == FileManager.ListType.DETAIL) { | 1158 if (type == FileManager.ListType.DETAIL) { |
1159 this.table_.dataModel = this.directoryModel_.fileList; | 1159 this.table_.dataModel = this.directoryModel_.getFileList(); |
1160 this.table_.selectionModel = this.directoryModel_.fileListSelection; | 1160 this.table_.selectionModel = this.directoryModel_.getFileListSelection(); |
1161 this.table_.style.display = ''; | 1161 this.table_.style.display = ''; |
1162 this.grid_.style.display = 'none'; | 1162 this.grid_.style.display = 'none'; |
1163 this.grid_.selectionModel = this.emptySelectionModel_; | 1163 this.grid_.selectionModel = this.emptySelectionModel_; |
1164 this.grid_.dataModel = this.emptyDataModel_; | 1164 this.grid_.dataModel = this.emptyDataModel_; |
1165 this.table_.style.display = ''; | 1165 this.table_.style.display = ''; |
1166 /** @type {cr.ui.List} */ | 1166 /** @type {cr.ui.List} */ |
1167 this.currentList_ = this.table_.list; | 1167 this.currentList_ = this.table_.list; |
1168 this.dialogDom_.querySelector('div.detail-view') | 1168 this.dialogDom_.querySelector('div.detail-view') |
1169 .setAttribute('disabled', 'disabled'); | 1169 .setAttribute('disabled', 'disabled'); |
1170 this.dialogDom_.querySelector('div.thumbnail-view') | 1170 this.dialogDom_.querySelector('div.thumbnail-view') |
1171 .removeAttribute('disabled'); | 1171 .removeAttribute('disabled'); |
1172 } else if (type == FileManager.ListType.THUMBNAIL) { | 1172 } else if (type == FileManager.ListType.THUMBNAIL) { |
1173 this.grid_.dataModel = this.directoryModel_.fileList; | 1173 this.grid_.dataModel = this.directoryModel_.getFileList(); |
1174 this.grid_.selectionModel = this.directoryModel_.fileListSelection; | 1174 this.grid_.selectionModel = this.directoryModel_.getFileListSelection(); |
1175 this.grid_.style.display = ''; | 1175 this.grid_.style.display = ''; |
1176 this.table_.style.display = 'none'; | 1176 this.table_.style.display = 'none'; |
1177 this.table_.selectionModel = this.emptySelectionModel_; | 1177 this.table_.selectionModel = this.emptySelectionModel_; |
1178 this.table_.dataModel = this.emptyDataModel_; | 1178 this.table_.dataModel = this.emptyDataModel_; |
1179 this.grid_.style.display = ''; | 1179 this.grid_.style.display = ''; |
1180 /** @type {cr.ui.List} */ | 1180 /** @type {cr.ui.List} */ |
1181 this.currentList_ = this.grid_; | 1181 this.currentList_ = this.grid_; |
1182 this.dialogDom_.querySelector('div.thumbnail-view') | 1182 this.dialogDom_.querySelector('div.thumbnail-view') |
1183 .setAttribute('disabled', 'disabled'); | 1183 .setAttribute('disabled', 'disabled'); |
1184 this.dialogDom_.querySelector('div.detail-view') | 1184 this.dialogDom_.querySelector('div.detail-view') |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 } | 1347 } |
1348 } | 1348 } |
1349 }; | 1349 }; |
1350 | 1350 |
1351 /** | 1351 /** |
1352 * Handler of file manager operations. Update directory model | 1352 * Handler of file manager operations. Update directory model |
1353 * to reflect operation result iimediatelly (not waiting directory | 1353 * to reflect operation result iimediatelly (not waiting directory |
1354 * update event). | 1354 * update event). |
1355 */ | 1355 */ |
1356 FileManager.prototype.onCopyManagerOperationComplete_ = function(event) { | 1356 FileManager.prototype.onCopyManagerOperationComplete_ = function(event) { |
1357 var currentPath = this.directoryModel_.currentEntry.fullPath; | 1357 var currentPath = this.directoryModel_.getCurrentDirEntry().fullPath; |
1358 function inCurrentDirectory(entry) { | 1358 function inCurrentDirectory(entry) { |
1359 var fullPath = entry.fullPath; | 1359 var fullPath = entry.fullPath; |
1360 var dirPath = fullPath.substr(0, fullPath.length - | 1360 var dirPath = fullPath.substr(0, fullPath.length - |
1361 entry.name.length - 1); | 1361 entry.name.length - 1); |
1362 return dirPath == currentPath; | 1362 return dirPath == currentPath; |
1363 } | 1363 } |
1364 for (var i = 0; i < event.affectedEntries.length; i++) { | 1364 for (var i = 0; i < event.affectedEntries.length; i++) { |
1365 entry = event.affectedEntries[i]; | 1365 entry = event.affectedEntries[i]; |
1366 if (inCurrentDirectory(entry)) | 1366 if (inCurrentDirectory(entry)) |
1367 this.directoryModel_.onEntryChanged(entry.name); | 1367 this.directoryModel_.onEntryChanged(entry.name); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 }; | 1421 }; |
1422 | 1422 |
1423 /** | 1423 /** |
1424 * Respond to the back and forward buttons. | 1424 * Respond to the back and forward buttons. |
1425 */ | 1425 */ |
1426 FileManager.prototype.onPopState_ = function(event) { | 1426 FileManager.prototype.onPopState_ = function(event) { |
1427 this.closeFilePopup_(); | 1427 this.closeFilePopup_(); |
1428 // Nothing left to do if the current directory is not changing. This happens | 1428 // Nothing left to do if the current directory is not changing. This happens |
1429 // if we are exiting the Gallery. | 1429 // if we are exiting the Gallery. |
1430 if (this.getPathFromUrlOrParams_() == | 1430 if (this.getPathFromUrlOrParams_() == |
1431 this.directoryModel_.currentEntry.fullPath) | 1431 this.directoryModel_.getCurrentDirEntry().fullPath) |
1432 return; | 1432 return; |
1433 this.setupCurrentDirectory_(true /* invokeHandler */); | 1433 this.setupCurrentDirectory_(true /* invokeHandler */); |
1434 }; | 1434 }; |
1435 | 1435 |
1436 FileManager.prototype.requestResize_ = function(timeout) { | 1436 FileManager.prototype.requestResize_ = function(timeout) { |
1437 setTimeout(this.onResize_.bind(this), timeout || 0); | 1437 setTimeout(this.onResize_.bind(this), timeout || 0); |
1438 }; | 1438 }; |
1439 | 1439 |
1440 /** | 1440 /** |
1441 * Resize details and thumb views to fit the new window size. | 1441 * Resize details and thumb views to fit the new window size. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 var fragment = this.document_.createDocumentFragment(); | 1671 var fragment = this.document_.createDocumentFragment(); |
1672 fragment.appendChild(input); | 1672 fragment.appendChild(input); |
1673 fragment.appendChild(this.document_.createTextNode(name)); | 1673 fragment.appendChild(this.document_.createTextNode(name)); |
1674 return fragment; | 1674 return fragment; |
1675 }; | 1675 }; |
1676 | 1676 |
1677 /** | 1677 /** |
1678 * Update check and disable states of the 'Select all' checkbox. | 1678 * Update check and disable states of the 'Select all' checkbox. |
1679 */ | 1679 */ |
1680 FileManager.prototype.updateSelectAllCheckboxState_ = function(checkbox) { | 1680 FileManager.prototype.updateSelectAllCheckboxState_ = function(checkbox) { |
1681 var dm = this.directoryModel_.fileList; | 1681 var dm = this.directoryModel_.getFileList(); |
1682 checkbox.checked = this.selection && dm.length > 0 && | 1682 checkbox.checked = this.selection && dm.length > 0 && |
1683 dm.length == this.selection.totalCount; | 1683 dm.length == this.selection.totalCount; |
1684 checkbox.disabled = dm.length == 0; | 1684 checkbox.disabled = dm.length == 0; |
1685 }; | 1685 }; |
1686 | 1686 |
1687 /** | 1687 /** |
1688 * Update the thumbnail image to fit/fill the square container. | 1688 * Update the thumbnail image to fit/fill the square container. |
1689 * | 1689 * |
1690 * Using webkit center packing does not align the image properly, so we need | 1690 * Using webkit center packing does not align the image properly, so we need |
1691 * to wait until the image loads and its proportions are known, then manually | 1691 * to wait until the image loads and its proportions are known, then manually |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 * Render filename label for grid and list view. | 1938 * Render filename label for grid and list view. |
1939 * @param {Entry} entry The Entry object to render. | 1939 * @param {Entry} entry The Entry object to render. |
1940 * @return {HTMLDivElement} The label. | 1940 * @return {HTMLDivElement} The label. |
1941 */ | 1941 */ |
1942 FileManager.prototype.renderFileNameLabel_ = function(entry) { | 1942 FileManager.prototype.renderFileNameLabel_ = function(entry) { |
1943 // Filename need to be in a '.filename-label' container for correct | 1943 // Filename need to be in a '.filename-label' container for correct |
1944 // work of inplace renaming. | 1944 // work of inplace renaming. |
1945 var fileName = this.document_.createElement('div'); | 1945 var fileName = this.document_.createElement('div'); |
1946 fileName.className = 'filename-label'; | 1946 fileName.className = 'filename-label'; |
1947 | 1947 |
1948 fileName.textContent = this.directoryModel_.currentEntry.name == '' ? | 1948 fileName.textContent = |
1949 this.getRootLabel_(entry.name) : entry.name; | 1949 this.directoryModel_.getCurrentDirEntry().name == '' ? |
| 1950 this.getRootLabel_(entry.name) : entry.name; |
1950 return fileName; | 1951 return fileName; |
1951 }; | 1952 }; |
1952 | 1953 |
1953 /** | 1954 /** |
1954 * Render the Size column of the detail table. | 1955 * Render the Size column of the detail table. |
1955 * | 1956 * |
1956 * @param {Entry} entry The Entry object to render. | 1957 * @param {Entry} entry The Entry object to render. |
1957 * @param {string} columnId The id of the column to be rendered. | 1958 * @param {string} columnId The id of the column to be rendered. |
1958 * @param {cr.ui.Table} table The table doing the rendering. | 1959 * @param {cr.ui.Table} table The table doing the rendering. |
1959 */ | 1960 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 }; | 2034 }; |
2034 | 2035 |
2035 FileManager.prototype.updateDate_ = function(div, entry) { | 2036 FileManager.prototype.updateDate_ = function(div, entry) { |
2036 div.textContent = '...'; | 2037 div.textContent = '...'; |
2037 this.displayDateInDiv_( | 2038 this.displayDateInDiv_( |
2038 div, this.metadataCache_.getCached(entry, 'filesystem')); | 2039 div, this.metadataCache_.getCached(entry, 'filesystem')); |
2039 }; | 2040 }; |
2040 | 2041 |
2041 FileManager.prototype.displayDateInDiv_ = function(div, filesystemProps) { | 2042 FileManager.prototype.displayDateInDiv_ = function(div, filesystemProps) { |
2042 if (!filesystemProps) return; | 2043 if (!filesystemProps) return; |
2043 if (this.directoryModel_.isSystemDirectoy && | 2044 if (this.directoryModel_.isSystemDirectory() && |
2044 filesystemProps.modificationTime.getTime() == 0) { | 2045 filesystemProps.modificationTime.getTime() == 0) { |
2045 // Mount points for FAT volumes have this time associated with them. | 2046 // Mount points for FAT volumes have this time associated with them. |
2046 // We'd rather display nothing than this bogus date. | 2047 // We'd rather display nothing than this bogus date. |
2047 div.textContent = ''; | 2048 div.textContent = ''; |
2048 } else { | 2049 } else { |
2049 div.textContent = | 2050 div.textContent = |
2050 this.shortDateFormatter_.format(filesystemProps.modificationTime); | 2051 this.shortDateFormatter_.format(filesystemProps.modificationTime); |
2051 } | 2052 } |
2052 }; | 2053 }; |
2053 | 2054 |
(...skipping 15 matching lines...) Expand all Loading... |
2069 if (entry.gdata_.isHosted) | 2070 if (entry.gdata_.isHosted) |
2070 return; | 2071 return; |
2071 checkbox.checked = entry.gdata_.isPinned; | 2072 checkbox.checked = entry.gdata_.isPinned; |
2072 div.appendChild(checkbox); | 2073 div.appendChild(checkbox); |
2073 }); | 2074 }); |
2074 } | 2075 } |
2075 return div; | 2076 return div; |
2076 }; | 2077 }; |
2077 | 2078 |
2078 FileManager.prototype.refreshCurrentDirectoryMetadata_ = function() { | 2079 FileManager.prototype.refreshCurrentDirectoryMetadata_ = function() { |
2079 var entries = this.directoryModel_.fileList.slice(); | 2080 var entries = this.directoryModel_.getFileList().slice(); |
2080 this.metadataCache_.clear(entries, 'filesystem'); | 2081 this.metadataCache_.clear(entries, 'filesystem'); |
2081 // We don't pass callback here. When new metadata arrives, we have an | 2082 // We don't pass callback here. When new metadata arrives, we have an |
2082 // observer registered to update the UI. | 2083 // observer registered to update the UI. |
2083 this.metadataCache_.get(entries, 'filesystem', null); | 2084 this.metadataCache_.get(entries, 'filesystem', null); |
2084 }; | 2085 }; |
2085 | 2086 |
2086 FileManager.prototype.updateFilesystemPropertiesInUI_ = function( | 2087 FileManager.prototype.updateFilesystemPropertiesInUI_ = function( |
2087 urls, properties) { | 2088 urls, properties) { |
2088 if (this.listType_ != FileManager.ListType.DETAIL) return; | 2089 if (this.listType_ != FileManager.ListType.DETAIL) return; |
2089 | 2090 |
2090 var items = {}; | 2091 var items = {}; |
2091 var dm = this.directoryModel_.fileList; | 2092 var dm = this.directoryModel_.getFileList(); |
2092 for (var index = 0; index < dm.length; index++) { | 2093 for (var index = 0; index < dm.length; index++) { |
2093 var listItem = this.currentList_.getListItemByIndex(index); | 2094 var listItem = this.currentList_.getListItemByIndex(index); |
2094 if (!listItem) continue; | 2095 if (!listItem) continue; |
2095 var entry = dm.item(index); | 2096 var entry = dm.item(index); |
2096 items[entry.toURL()] = listItem; | 2097 items[entry.toURL()] = listItem; |
2097 } | 2098 } |
2098 | 2099 |
2099 for (var index = 0; index < urls.length; index++) { | 2100 for (var index = 0; index < urls.length; index++) { |
2100 var url = urls[index]; | 2101 var url = urls[index]; |
2101 if (!(url in items)) continue; | 2102 if (!(url in items)) continue; |
(...skipping 11 matching lines...) Expand all Loading... |
2113 * | 2114 * |
2114 * While refreshing file list it gets repopulated with new file entries. | 2115 * While refreshing file list it gets repopulated with new file entries. |
2115 * There is not a big difference wether DOM items stay the same or not. | 2116 * There is not a big difference wether DOM items stay the same or not. |
2116 * Except for the item that the user is renaming. | 2117 * Except for the item that the user is renaming. |
2117 */ | 2118 */ |
2118 FileManager.prototype.restoreItemBeingRenamed_ = function() { | 2119 FileManager.prototype.restoreItemBeingRenamed_ = function() { |
2119 if (!this.isRenamingInProgress()) | 2120 if (!this.isRenamingInProgress()) |
2120 return; | 2121 return; |
2121 | 2122 |
2122 var dm = this.directoryModel_; | 2123 var dm = this.directoryModel_; |
2123 var leadIndex = dm.fileListSelection.leadIndex; | 2124 var leadIndex = dm.getFileListSelection().leadIndex; |
2124 if (leadIndex < 0) | 2125 if (leadIndex < 0) |
2125 return; | 2126 return; |
2126 | 2127 |
2127 var leadEntry = dm.fileList.item(leadIndex); | 2128 var leadEntry = dm.getFileList().item(leadIndex); |
2128 if (this.renameInput_.currentEntry.fullPath != leadEntry.fullPath) | 2129 if (this.renameInput_.currentEntry.fullPath != leadEntry.fullPath) |
2129 return; | 2130 return; |
2130 | 2131 |
2131 var leadListItem = this.findListItemForNode_(this.renameInput_); | 2132 var leadListItem = this.findListItemForNode_(this.renameInput_); |
2132 if (this.currentList_ == this.table_.list) { | 2133 if (this.currentList_ == this.table_.list) { |
2133 this.updateType_(leadListItem.querySelector('.type'), leadEntry); | 2134 this.updateType_(leadListItem.querySelector('.type'), leadEntry); |
2134 this.updateDate_(leadListItem.querySelector('.date'), leadEntry); | 2135 this.updateDate_(leadListItem.querySelector('.date'), leadEntry); |
2135 this.updateSize_(leadListItem.querySelector('.size'), leadEntry); | 2136 this.updateSize_(leadListItem.querySelector('.size'), leadEntry); |
2136 } | 2137 } |
2137 this.currentList_.restoreLeadItem(leadListItem); | 2138 this.currentList_.restoreLeadItem(leadListItem); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 } | 2187 } |
2187 } | 2188 } |
2188 | 2189 |
2189 function onThumbnailLoaded() { | 2190 function onThumbnailLoaded() { |
2190 thumbnailLoaded++; | 2191 thumbnailLoaded++; |
2191 if (thumbnailLoaded == thumbnailCount) | 2192 if (thumbnailLoaded == thumbnailCount) |
2192 showThumbnails(); | 2193 showThumbnails(); |
2193 } | 2194 } |
2194 | 2195 |
2195 for (var i = 0; i < selection.indexes.length; i++) { | 2196 for (var i = 0; i < selection.indexes.length; i++) { |
2196 var entry = this.directoryModel_.fileList.item(selection.indexes[i]); | 2197 var entry = this.directoryModel_.getFileList().item(selection.indexes[i]); |
2197 if (!entry) | 2198 if (!entry) |
2198 continue; | 2199 continue; |
2199 | 2200 |
2200 selection.entries.push(entry); | 2201 selection.entries.push(entry); |
2201 selection.urls.push(entry.toURL()); | 2202 selection.urls.push(entry.toURL()); |
2202 | 2203 |
2203 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { | 2204 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { |
2204 var box = this.document_.createElement('div'); | 2205 var box = this.document_.createElement('div'); |
2205 function imageLoadCalback(index, box, img, transform) { | 2206 function imageLoadCalback(index, box, img, transform) { |
2206 if (index == 0) | 2207 if (index == 0) |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 }; | 2607 }; |
2607 | 2608 |
2608 FileManager.prototype.onOnlineOffline_ = function() { | 2609 FileManager.prototype.onOnlineOffline_ = function() { |
2609 if (this.isOffline()) { | 2610 if (this.isOffline()) { |
2610 console.log('OFFLINE'); | 2611 console.log('OFFLINE'); |
2611 this.dialogContainer_.setAttribute('offline', true); | 2612 this.dialogContainer_.setAttribute('offline', true); |
2612 } else { | 2613 } else { |
2613 console.log('ONLINE'); | 2614 console.log('ONLINE'); |
2614 this.dialogContainer_.removeAttribute('offline'); | 2615 this.dialogContainer_.removeAttribute('offline'); |
2615 } | 2616 } |
2616 this.directoryModel_.offline = this.isOffline(); | 2617 this.directoryModel_.setOffline(this.isOffline()); |
2617 }; | 2618 }; |
2618 | 2619 |
2619 FileManager.prototype.isOnGDataOffline = function() { | 2620 FileManager.prototype.isOnGDataOffline = function() { |
2620 return this.isOnGData() && this.isOffline(); | 2621 return this.isOnGData() && this.isOffline(); |
2621 }; | 2622 }; |
2622 | 2623 |
2623 FileManager.prototype.isOnReadonlyDirectory = function() { | 2624 FileManager.prototype.isOnReadonlyDirectory = function() { |
2624 return this.directoryModel_.readonly; | 2625 return this.directoryModel_.isReadOnly(); |
2625 }; | 2626 }; |
2626 | 2627 |
2627 /** | 2628 /** |
2628 * Event handler called when some volume was mounted or unmouted. | 2629 * Event handler called when some volume was mounted or unmouted. |
2629 */ | 2630 */ |
2630 FileManager.prototype.onMountCompleted_ = function(event) { | 2631 FileManager.prototype.onMountCompleted_ = function(event) { |
2631 var self = this; | 2632 var self = this; |
2632 | 2633 |
2633 var changeDirectoryTo = null; | 2634 var changeDirectoryTo = null; |
2634 | 2635 |
2635 if (event && event.mountType == 'gdata') { | 2636 if (event && event.mountType == 'gdata') { |
2636 metrics.recordInterval('Load.GData'); | 2637 metrics.recordInterval('Load.GData'); |
2637 console.log('GData mounted'); | 2638 console.log('GData mounted'); |
2638 if (event.status == 'success') { | 2639 if (event.status == 'success') { |
2639 this.gdataMounted_ = true; | 2640 this.gdataMounted_ = true; |
2640 this.gdataMountInfo_ = { | 2641 this.gdataMountInfo_ = { |
2641 'mountPath': event.mountPath, | 2642 'mountPath': event.mountPath, |
2642 'sourceUrl': event.sourceUrl, | 2643 'sourceUrl': event.sourceUrl, |
2643 'mountType': event.mountType, | 2644 'mountType': event.mountType, |
2644 'mountCondition': event.status | 2645 'mountCondition': event.status |
2645 }; | 2646 }; |
2646 // Not calling clearGDataLoadingTimer_ here because we want to keep | 2647 // Not calling clearGDataLoadingTimer_ here because we want to keep |
2647 // "Loading Google Docs" message until the directory loads. It is OK if | 2648 // "Loading Google Docs" message until the directory loads. It is OK if |
2648 // the timer fires after the mount because onDirectoryChanged_ will hide | 2649 // the timer fires after the mount because onDirectoryChanged_ will hide |
2649 // the unmounted panel. | 2650 // the unmounted panel. |
2650 if (this.setupCurrentDirectoryPostponed_) { | 2651 if (this.setupCurrentDirectoryPostponed_) { |
2651 this.setupCurrentDirectoryPostponed_(false /* execute */); | 2652 this.setupCurrentDirectoryPostponed_(false /* execute */); |
2652 } else if (this.isOnGData() && | 2653 } else if (this.isOnGData() && |
2653 this.directoryModel_.currentEntry.unmounted) { | 2654 this.directoryModel_.getCurrentDirEntry().unmounted) { |
2654 // We are currently on an unmounted GData directory, force a rescan. | 2655 // We are currently on an unmounted GData directory, force a rescan. |
2655 changeDirectoryTo = this.directoryModel_.getCurrentRootPath(); | 2656 changeDirectoryTo = this.directoryModel_.getCurrentRootPath(); |
2656 } | 2657 } |
2657 } else { | 2658 } else { |
2658 this.gdataMounted_ = false; | 2659 this.gdataMounted_ = false; |
2659 this.gdataMountInfo_ = null; | 2660 this.gdataMountInfo_ = null; |
2660 this.clearGDataLoadingTimer_(); | 2661 this.clearGDataLoadingTimer_(); |
2661 this.onGDataUnreachable_('GData mount failed: ' + event.status); | 2662 this.onGDataUnreachable_('GData mount failed: ' + event.status); |
2662 if (this.setupCurrentDirectoryPostponed_) { | 2663 if (this.setupCurrentDirectoryPostponed_) { |
2663 this.setupCurrentDirectoryPostponed_(true /* cancel */); | 2664 this.setupCurrentDirectoryPostponed_(true /* cancel */); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2783 FileManager.prototype.closeFilePopup_ = function() { | 2784 FileManager.prototype.closeFilePopup_ = function() { |
2784 if (this.filePopup_) { | 2785 if (this.filePopup_) { |
2785 this.dialogDom_.removeChild(this.filePopup_); | 2786 this.dialogDom_.removeChild(this.filePopup_); |
2786 this.filePopup_ = null; | 2787 this.filePopup_ = null; |
2787 this.refocus(); | 2788 this.refocus(); |
2788 } | 2789 } |
2789 }; | 2790 }; |
2790 | 2791 |
2791 FileManager.prototype.getAllUrlsInCurrentDirectory_ = function() { | 2792 FileManager.prototype.getAllUrlsInCurrentDirectory_ = function() { |
2792 var urls = []; | 2793 var urls = []; |
2793 var dm = this.directoryModel_.fileList; | 2794 var fileList = this.directoryModel_.getFileList(); |
2794 for (var i = 0; i != dm.length; i++) { | 2795 for (var i = 0; i != fileList.length; i++) { |
2795 urls.push(dm.item(i).toURL()); | 2796 urls.push(fileList.item(i).toURL()); |
2796 } | 2797 } |
2797 return urls; | 2798 return urls; |
2798 }; | 2799 }; |
2799 | 2800 |
2800 FileManager.prototype.getShareActions_ = function(urls, callback) { | 2801 FileManager.prototype.getShareActions_ = function(urls, callback) { |
2801 chrome.fileBrowserPrivate.getFileTasks(urls, function(tasks) { | 2802 chrome.fileBrowserPrivate.getFileTasks(urls, function(tasks) { |
2802 var shareActions = []; | 2803 var shareActions = []; |
2803 for (var index = 0; index < tasks.length; index++) { | 2804 for (var index = 0; index < tasks.length; index++) { |
2804 var task = tasks[index]; | 2805 var task = tasks[index]; |
2805 if (task.taskId != this.getExtensionId_() + '|gallery') { | 2806 if (task.taskId != this.getExtensionId_() + '|gallery') { |
(...skipping 23 matching lines...) Expand all Loading... |
2829 // in the ribbon. | 2830 // in the ribbon. |
2830 // We do not do that if a single video is selected because the UI is | 2831 // We do not do that if a single video is selected because the UI is |
2831 // cleaner without the ribbon. | 2832 // cleaner without the ribbon. |
2832 urls = this.getAllUrlsInCurrentDirectory_().filter( | 2833 urls = this.getAllUrlsInCurrentDirectory_().filter( |
2833 FileType.isImageOrVideo); | 2834 FileType.isImageOrVideo); |
2834 } else { | 2835 } else { |
2835 // Pass just the selected items, select the first entry. | 2836 // Pass just the selected items, select the first entry. |
2836 selectedUrl = urls[0]; | 2837 selectedUrl = urls[0]; |
2837 } | 2838 } |
2838 | 2839 |
2839 var dirPath = this.directoryModel_.currentEntry.fullPath; | 2840 var dirPath = this.directoryModel_.getCurrentDirEntry().fullPath; |
2840 | 2841 |
2841 // Push a temporary state which will be replaced every time an individual | 2842 // Push a temporary state which will be replaced every time an individual |
2842 // item is selected in the Gallery. | 2843 // item is selected in the Gallery. |
2843 this.updateLocation_(false /*push*/, dirPath); | 2844 this.updateLocation_(false /*push*/, dirPath); |
2844 | 2845 |
2845 galleryFrame.onload = function() { | 2846 galleryFrame.onload = function() { |
2846 galleryFrame.contentWindow.ImageUtil.metrics = metrics; | 2847 galleryFrame.contentWindow.ImageUtil.metrics = metrics; |
2847 galleryFrame.contentWindow.FileType = FileType; | 2848 galleryFrame.contentWindow.FileType = FileType; |
2848 galleryFrame.contentWindow.util = util; | 2849 galleryFrame.contentWindow.util = util; |
2849 | 2850 |
2850 // Gallery shoud treat GData folder as readonly even when online | 2851 // Gallery shoud treat GData folder as readonly even when online |
2851 // until we learn to save files directly to GData. | 2852 // until we learn to save files directly to GData. |
2852 var readonly = self.isOnReadonlyDirectory() || self.isOnGData(); | 2853 var readonly = self.isOnReadonlyDirectory() || self.isOnGData(); |
2853 var currentDir = self.directoryModel_.currentEntry; | 2854 var currentDir = self.directoryModel_.getCurrentDirEntry(); |
2854 var downloadsDir = self.directoryModel_.getRootsList().item(0); | 2855 var downloadsDir = self.directoryModel_.getRootsList().item(0); |
2855 | 2856 |
2856 var gallerySelection; | 2857 var gallerySelection; |
2857 var context = { | 2858 var context = { |
2858 // We show the root label in readonly warning (e.g. archive name). | 2859 // We show the root label in readonly warning (e.g. archive name). |
2859 readonlyDirName: | 2860 readonlyDirName: |
2860 readonly ? | 2861 readonly ? |
2861 (self.isOnGData() ? | 2862 (self.isOnGData() ? |
2862 self.getRootLabel_(currentDir.fullPath) : | 2863 self.getRootLabel_(currentDir.fullPath) : |
2863 self.directoryModel_.rootName) : | 2864 self.directoryModel_.getRootName()) : |
2864 null, | 2865 null, |
2865 saveDirEntry: readonly ? downloadsDir : currentDir, | 2866 saveDirEntry: readonly ? downloadsDir : currentDir, |
2866 metadataProvider: self.getMetadataProvider(), | 2867 metadataProvider: self.getMetadataProvider(), |
2867 getShareActions: self.getShareActions_.bind(self), | 2868 getShareActions: self.getShareActions_.bind(self), |
2868 onNameChange: function(name) { | 2869 onNameChange: function(name) { |
2869 self.document_.title = gallerySelection = name; | 2870 self.document_.title = gallerySelection = name; |
2870 self.updateLocation_(true /*replace*/, dirPath + '/' + name); | 2871 self.updateLocation_(true /*replace*/, dirPath + '/' + name); |
2871 }, | 2872 }, |
2872 onClose: function() { | 2873 onClose: function() { |
2873 if (singleSelection) | 2874 if (singleSelection) |
(...skipping 10 matching lines...) Expand all Loading... |
2884 }; | 2885 }; |
2885 | 2886 |
2886 /** | 2887 /** |
2887 * Update the breadcrumb display to reflect the current directory. | 2888 * Update the breadcrumb display to reflect the current directory. |
2888 */ | 2889 */ |
2889 FileManager.prototype.updateBreadcrumbs_ = function() { | 2890 FileManager.prototype.updateBreadcrumbs_ = function() { |
2890 var bc = this.dialogDom_.querySelector('.breadcrumbs'); | 2891 var bc = this.dialogDom_.querySelector('.breadcrumbs'); |
2891 removeChildren(bc); | 2892 removeChildren(bc); |
2892 | 2893 |
2893 var rootPath = this.directoryModel_.getCurrentRootPath(); | 2894 var rootPath = this.directoryModel_.getCurrentRootPath(); |
2894 var relativePath = this.directoryModel_.currentEntry.fullPath. | 2895 var relativePath = this.directoryModel_.getCurrentDirEntry().fullPath. |
2895 substring(rootPath.length).replace(/\/$/, ''); | 2896 substring(rootPath.length).replace(/\/$/, ''); |
2896 | 2897 |
2897 var pathNames = relativePath.replace(/\/$/, '').split('/'); | 2898 var pathNames = relativePath.replace(/\/$/, '').split('/'); |
2898 if (pathNames[0] == '') | 2899 if (pathNames[0] == '') |
2899 pathNames.splice(0, 1); | 2900 pathNames.splice(0, 1); |
2900 | 2901 |
2901 // We need a first breadcrumb for root, so placing last name from | 2902 // We need a first breadcrumb for root, so placing last name from |
2902 // rootPath as first name of relativePath. | 2903 // rootPath as first name of relativePath. |
2903 var rootPathNames = rootPath.replace(/\/$/, '').split('/'); | 2904 var rootPathNames = rootPath.replace(/\/$/, '').split('/'); |
2904 pathNames.splice(0, 0, rootPathNames[rootPathNames.length - 1]); | 2905 pathNames.splice(0, 0, rootPathNames[rootPathNames.length - 1]); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3058 this.table_.focus(); | 3059 this.table_.focus(); |
3059 else // this.listType_ == FileManager.ListType.THUMBNAIL) | 3060 else // this.listType_ == FileManager.ListType.THUMBNAIL) |
3060 this.grid_.focus(); | 3061 this.grid_.focus(); |
3061 }; | 3062 }; |
3062 | 3063 |
3063 /** | 3064 /** |
3064 * Return full path of the current directory or null. | 3065 * Return full path of the current directory or null. |
3065 */ | 3066 */ |
3066 FileManager.prototype.getCurrentDirectory = function() { | 3067 FileManager.prototype.getCurrentDirectory = function() { |
3067 return this.directoryModel_ && | 3068 return this.directoryModel_ && |
3068 this.directoryModel_.currentEntry.fullPath; | 3069 this.directoryModel_.getCurrentDirEntry().fullPath; |
3069 }; | 3070 }; |
3070 | 3071 |
3071 /** | 3072 /** |
3072 * Return URL of the current directory or null. | 3073 * Return URL of the current directory or null. |
3073 */ | 3074 */ |
3074 FileManager.prototype.getCurrentDirectoryURL = function() { | 3075 FileManager.prototype.getCurrentDirectoryURL = function() { |
3075 return this.directoryModel_ && | 3076 return this.directoryModel_ && |
3076 this.directoryModel_.currentEntry.toURL(); | 3077 this.directoryModel_.getCurrentDirEntry().toURL(); |
3077 }; | 3078 }; |
3078 | 3079 |
3079 FileManager.prototype.deleteEntries = function(entries, force, opt_callback) { | 3080 FileManager.prototype.deleteEntries = function(entries, force, opt_callback) { |
3080 if (!force) { | 3081 if (!force) { |
3081 var self = this; | 3082 var self = this; |
3082 var msg; | 3083 var msg; |
3083 if (entries.length == 1) { | 3084 if (entries.length == 1) { |
3084 msg = strf('CONFIRM_DELETE_ONE', entries[0].name); | 3085 msg = strf('CONFIRM_DELETE_ONE', entries[0].name); |
3085 } else { | 3086 } else { |
3086 msg = strf('CONFIRM_DELETE_SOME', entries.length); | 3087 msg = strf('CONFIRM_DELETE_SOME', entries.length); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3162 /** | 3163 /** |
3163 * Handle a click event on a breadcrumb element. | 3164 * Handle a click event on a breadcrumb element. |
3164 * | 3165 * |
3165 * @param {Event} event The click event. | 3166 * @param {Event} event The click event. |
3166 */ | 3167 */ |
3167 FileManager.prototype.onBreadcrumbClick_ = function(event) { | 3168 FileManager.prototype.onBreadcrumbClick_ = function(event) { |
3168 this.directoryModel_.changeDirectory(event.srcElement.path); | 3169 this.directoryModel_.changeDirectory(event.srcElement.path); |
3169 }; | 3170 }; |
3170 | 3171 |
3171 FileManager.prototype.onCheckboxClick_ = function(event) { | 3172 FileManager.prototype.onCheckboxClick_ = function(event) { |
3172 var sm = this.directoryModel_.fileListSelection; | 3173 var sm = this.directoryModel_.getFileListSelection(); |
3173 var listItem = this.findListItemForEvent_(event); | 3174 var listItem = this.findListItemForEvent_(event); |
3174 sm.setIndexSelected(listItem.listIndex, event.target.checked); | 3175 sm.setIndexSelected(listItem.listIndex, event.target.checked); |
3175 }; | 3176 }; |
3176 | 3177 |
3177 FileManager.prototype.onPinClick_ = function(checkbox, entry, event) { | 3178 FileManager.prototype.onPinClick_ = function(checkbox, entry, event) { |
3178 var self = this; | 3179 var self = this; |
3179 function callback(props) { | 3180 function callback(props) { |
3180 if (props.errorCode) { | 3181 if (props.errorCode) { |
3181 // TODO(serya): Do not show the message if unpin failed. | 3182 // TODO(serya): Do not show the message if unpin failed. |
3182 self.metadataCache_.get(entry, 'filesystem', function(filesystem) { | 3183 self.metadataCache_.get(entry, 'filesystem', function(filesystem) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3432 | 3433 |
3433 this.checkFreeSpace_(this.getCurrentDirectory()); | 3434 this.checkFreeSpace_(this.getCurrentDirectory()); |
3434 | 3435 |
3435 // TODO(dgozman): title may be better than this. | 3436 // TODO(dgozman): title may be better than this. |
3436 this.document_.title = this.getCurrentDirectory().substr(1); | 3437 this.document_.title = this.getCurrentDirectory().substr(1); |
3437 | 3438 |
3438 if (this.metadataObserverId_) | 3439 if (this.metadataObserverId_) |
3439 this.metadataCache_.removeObserver(this.metadataObserverId_); | 3440 this.metadataCache_.removeObserver(this.metadataObserverId_); |
3440 | 3441 |
3441 this.metadataObserverId_ = this.metadataCache_.addObserver( | 3442 this.metadataObserverId_ = this.metadataCache_.addObserver( |
3442 this.directoryModel_.currentEntry, | 3443 this.directoryModel_.getCurrentDirEntry(), |
3443 MetadataCache.CHILDREN, | 3444 MetadataCache.CHILDREN, |
3444 'filesystem', | 3445 'filesystem', |
3445 this.updateFilesystemPropertiesInUI_.bind(this)); | 3446 this.updateFilesystemPropertiesInUI_.bind(this)); |
3446 | 3447 |
3447 var self = this; | 3448 var self = this; |
3448 | 3449 |
3449 if (this.watchedDirectoryUrl_) { | 3450 if (this.watchedDirectoryUrl_) { |
3450 if (this.watchedDirectoryUrl_ != event.previousDirEntry.toURL()) { | 3451 if (this.watchedDirectoryUrl_ != event.previousDirEntry.toURL()) { |
3451 console.warn('event.previousDirEntry does not match File Manager state', | 3452 console.warn('event.previousDirEntry does not match File Manager state', |
3452 event, this.watchedDirectoryUrl_); | 3453 event, this.watchedDirectoryUrl_); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 | 3669 |
3669 FileManager.prototype.showSpinner_ = function(on) { | 3670 FileManager.prototype.showSpinner_ = function(on) { |
3670 this.cancelSpinnerTimeout_(); | 3671 this.cancelSpinnerTimeout_(); |
3671 this.spinner_.style.display = on ? '' : 'none'; | 3672 this.spinner_.style.display = on ? '' : 'none'; |
3672 }; | 3673 }; |
3673 | 3674 |
3674 FileManager.prototype.onNewFolderCommand_ = function(event) { | 3675 FileManager.prototype.onNewFolderCommand_ = function(event) { |
3675 var defaultName = str('DEFAULT_NEW_FOLDER_NAME'); | 3676 var defaultName = str('DEFAULT_NEW_FOLDER_NAME'); |
3676 | 3677 |
3677 // Find a name that doesn't exist in the data model. | 3678 // Find a name that doesn't exist in the data model. |
3678 var files = this.directoryModel_.fileList; | 3679 var files = this.directoryModel_.getFileList(); |
3679 var hash = {}; | 3680 var hash = {}; |
3680 for (var i = 0; i < files.length; i++) { | 3681 for (var i = 0; i < files.length; i++) { |
3681 var name = files.item(i).name; | 3682 var name = files.item(i).name; |
3682 // Filtering names prevents from conflicts with prototype's names | 3683 // Filtering names prevents from conflicts with prototype's names |
3683 // and '__proto__'. | 3684 // and '__proto__'. |
3684 if (name.substring(0, defaultName.length) == defaultName) | 3685 if (name.substring(0, defaultName.length) == defaultName) |
3685 hash[name] = 1; | 3686 hash[name] = 1; |
3686 } | 3687 } |
3687 | 3688 |
3688 var baseName = defaultName; | 3689 var baseName = defaultName; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3741 */ | 3742 */ |
3742 FileManager.prototype.onKeyDown_ = function(event) { | 3743 FileManager.prototype.onKeyDown_ = function(event) { |
3743 if (event.srcElement === this.renameInput_) { | 3744 if (event.srcElement === this.renameInput_) { |
3744 // Ignore keydown handler in the rename input box. | 3745 // Ignore keydown handler in the rename input box. |
3745 return; | 3746 return; |
3746 } | 3747 } |
3747 | 3748 |
3748 switch (util.getKeyModifiers(event) + event.keyCode) { | 3749 switch (util.getKeyModifiers(event) + event.keyCode) { |
3749 case 'Ctrl-190': // Ctrl-. => Toggle filter files. | 3750 case 'Ctrl-190': // Ctrl-. => Toggle filter files. |
3750 var dm = this.directoryModel_; | 3751 var dm = this.directoryModel_; |
3751 dm.filterHidden = !dm.filterHidden; | 3752 dm.setFilterHidden(!dm.getFilterHidden()); |
3752 event.preventDefault(); | 3753 event.preventDefault(); |
3753 return; | 3754 return; |
3754 | 3755 |
3755 case '27': // Escape => Cancel dialog. | 3756 case '27': // Escape => Cancel dialog. |
3756 if (this.copyManager_ && | 3757 if (this.copyManager_ && |
3757 this.copyManager_.getStatus().totalFiles != 0) { | 3758 this.copyManager_.getStatus().totalFiles != 0) { |
3758 // If there is a copy in progress, ESC will cancel it. | 3759 // If there is a copy in progress, ESC will cancel it. |
3759 event.preventDefault(); | 3760 event.preventDefault(); |
3760 this.copyManager_.requestCancel(); | 3761 this.copyManager_.requestCancel(); |
3761 return; | 3762 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 | 3896 |
3896 /** | 3897 /** |
3897 * Performs a 'text search' - selects a first list entry with name | 3898 * Performs a 'text search' - selects a first list entry with name |
3898 * starting with entered text (case-insensitive). | 3899 * starting with entered text (case-insensitive). |
3899 */ | 3900 */ |
3900 FileManager.prototype.doTextSearch_ = function() { | 3901 FileManager.prototype.doTextSearch_ = function() { |
3901 var text = this.textSearchState_.text; | 3902 var text = this.textSearchState_.text; |
3902 if (!text) | 3903 if (!text) |
3903 return; | 3904 return; |
3904 | 3905 |
3905 var dm = this.directoryModel_.fileList; | 3906 var dm = this.directoryModel_.getFileList(); |
3906 for (var index = 0; index < dm.length; ++index) { | 3907 for (var index = 0; index < dm.length; ++index) { |
3907 var name = dm.item(index).name; | 3908 var name = dm.item(index).name; |
3908 if (name.substring(0, text.length).toLowerCase() == text) { | 3909 if (name.substring(0, text.length).toLowerCase() == text) { |
3909 this.currentList_.selectionModel.selectedIndexes = [index]; | 3910 this.currentList_.selectionModel.selectedIndexes = [index]; |
3910 return; | 3911 return; |
3911 } | 3912 } |
3912 } | 3913 } |
3913 | 3914 |
3914 this.textSearchState_.text = ''; | 3915 this.textSearchState_.text = ''; |
3915 }; | 3916 }; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4136 | 4137 |
4137 var files = []; | 4138 var files = []; |
4138 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes; | 4139 var selectedIndexes = this.currentList_.selectionModel.selectedIndexes; |
4139 | 4140 |
4140 // All other dialog types require at least one selected list item. | 4141 // All other dialog types require at least one selected list item. |
4141 // The logic to control whether or not the ok button is enabled should | 4142 // The logic to control whether or not the ok button is enabled should |
4142 // prevent us from ever getting here, but we sanity check to be sure. | 4143 // prevent us from ever getting here, but we sanity check to be sure. |
4143 if (!selectedIndexes.length) | 4144 if (!selectedIndexes.length) |
4144 throw new Error('Nothing selected!'); | 4145 throw new Error('Nothing selected!'); |
4145 | 4146 |
4146 var dm = this.directoryModel_.fileList; | 4147 var dm = this.directoryModel_.getFileList(); |
4147 for (var i = 0; i < selectedIndexes.length; i++) { | 4148 for (var i = 0; i < selectedIndexes.length; i++) { |
4148 var entry = dm.item(selectedIndexes[i]); | 4149 var entry = dm.item(selectedIndexes[i]); |
4149 if (!entry) { | 4150 if (!entry) { |
4150 console.log('Error locating selected file at index: ' + i); | 4151 console.log('Error locating selected file at index: ' + i); |
4151 continue; | 4152 continue; |
4152 } | 4153 } |
4153 | 4154 |
4154 files.push(currentDirUrl + encodeURIComponent(entry.name)); | 4155 files.push(currentDirUrl + encodeURIComponent(entry.name)); |
4155 } | 4156 } |
4156 | 4157 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4202 FileManager.prototype.validateFileName_ = function(name, opt_onDone) { | 4203 FileManager.prototype.validateFileName_ = function(name, opt_onDone) { |
4203 var onDone = opt_onDone || function() {}; | 4204 var onDone = opt_onDone || function() {}; |
4204 var msg; | 4205 var msg; |
4205 var testResult = /[\/\\\<\>\:\?\*\"\|]/.exec(name); | 4206 var testResult = /[\/\\\<\>\:\?\*\"\|]/.exec(name); |
4206 if (testResult) { | 4207 if (testResult) { |
4207 msg = strf('ERROR_INVALID_CHARACTER', testResult[0]); | 4208 msg = strf('ERROR_INVALID_CHARACTER', testResult[0]); |
4208 } else if (/^\s*$/i.test(name)) { | 4209 } else if (/^\s*$/i.test(name)) { |
4209 msg = str('ERROR_WHITESPACE_NAME'); | 4210 msg = str('ERROR_WHITESPACE_NAME'); |
4210 } else if (/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name)) { | 4211 } else if (/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name)) { |
4211 msg = str('ERROR_RESERVED_NAME'); | 4212 msg = str('ERROR_RESERVED_NAME'); |
4212 } else if (this.directoryModel_.filterHidden && name[0] == '.') { | 4213 } else if (this.directoryModel_.getFilterHidden() && name[0] == '.') { |
4213 msg = str('ERROR_HIDDEN_NAME'); | 4214 msg = str('ERROR_HIDDEN_NAME'); |
4214 } | 4215 } |
4215 | 4216 |
4216 if (msg) { | 4217 if (msg) { |
4217 this.alert.show(msg, onDone); | 4218 this.alert.show(msg, onDone); |
4218 return false; | 4219 return false; |
4219 } | 4220 } |
4220 | 4221 |
4221 onDone(); | 4222 onDone(); |
4222 return true; | 4223 return true; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4330 | 4331 |
4331 handleSplitterDragEnd: function(e) { | 4332 handleSplitterDragEnd: function(e) { |
4332 Splitter.prototype.handleSplitterDragEnd.apply(this, arguments); | 4333 Splitter.prototype.handleSplitterDragEnd.apply(this, arguments); |
4333 this.ownerDocument.documentElement.classList.remove('col-resize'); | 4334 this.ownerDocument.documentElement.classList.remove('col-resize'); |
4334 } | 4335 } |
4335 }; | 4336 }; |
4336 | 4337 |
4337 customSplitter.decorate(splitterElement); | 4338 customSplitter.decorate(splitterElement); |
4338 }; | 4339 }; |
4339 })(); | 4340 })(); |
OLD | NEW |