Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

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

Powered by Google App Engine
This is Rietveld 408576698