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