Chromium Code Reviews| 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 | 604 |
| 605 CommandUtil.registerCommand(doc, 'gdata-go-to-drive', | 605 CommandUtil.registerCommand(doc, 'gdata-go-to-drive', |
| 606 Commands.gdataGoToDriveCommand, this); | 606 Commands.gdataGoToDriveCommand, this); |
| 607 | 607 |
| 608 CommandUtil.registerCommand(doc, 'paste', | 608 CommandUtil.registerCommand(doc, 'paste', |
| 609 Commands.pasteFileCommand, doc, this.fileTransferController_); | 609 Commands.pasteFileCommand, doc, this.fileTransferController_); |
| 610 | 610 |
| 611 CommandUtil.registerCommand(doc, 'open-with', | 611 CommandUtil.registerCommand(doc, 'open-with', |
| 612 Commands.openWithCommand, this); | 612 Commands.openWithCommand, this); |
| 613 | 613 |
| 614 CommandUtil.registerCommand(doc, 'available-offline', | |
|
Dmitry Zvorygin
2012/11/23 13:09:13
Consider using verbs, like "toggle-pinned".
dgozman
2012/11/23 13:13:38
Done.
| |
| 615 Commands.availableOfflineCommand, this); | |
| 616 | |
| 614 CommandUtil.registerCommand(doc, 'zip-selection', | 617 CommandUtil.registerCommand(doc, 'zip-selection', |
| 615 Commands.zipSelectionCommand, this); | 618 Commands.zipSelectionCommand, this); |
| 616 | 619 |
| 617 CommandUtil.registerCommand(doc, 'search', Commands.searchCommand, this, | 620 CommandUtil.registerCommand(doc, 'search', Commands.searchCommand, this, |
| 618 this.dialogDom_.querySelector('#search-box')); | 621 this.dialogDom_.querySelector('#search-box')); |
| 619 | 622 |
| 620 CommandUtil.registerCommand(doc, 'cut', Commands.defaultCommand, doc); | 623 CommandUtil.registerCommand(doc, 'cut', Commands.defaultCommand, doc); |
| 621 CommandUtil.registerCommand(doc, 'copy', Commands.defaultCommand, doc); | 624 CommandUtil.registerCommand(doc, 'copy', Commands.defaultCommand, doc); |
| 622 | 625 |
| 623 var inputs = this.dialogDom_.querySelectorAll( | 626 var inputs = this.dialogDom_.querySelectorAll( |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1899 div.className = 'offline'; | 1902 div.className = 'offline'; |
| 1900 | 1903 |
| 1901 if (entry.isDirectory) | 1904 if (entry.isDirectory) |
| 1902 return div; | 1905 return div; |
| 1903 | 1906 |
| 1904 var checkbox = this.renderCheckbox_(); | 1907 var checkbox = this.renderCheckbox_(); |
| 1905 checkbox.classList.add('pin'); | 1908 checkbox.classList.add('pin'); |
| 1906 checkbox.addEventListener('click', | 1909 checkbox.addEventListener('click', |
| 1907 this.onPinClick_.bind(this, checkbox, entry)); | 1910 this.onPinClick_.bind(this, checkbox, entry)); |
| 1908 checkbox.style.display = 'none'; | 1911 checkbox.style.display = 'none'; |
| 1912 checkbox.entry = entry; | |
| 1909 div.appendChild(checkbox); | 1913 div.appendChild(checkbox); |
| 1910 | 1914 |
| 1911 if (this.isOnGData()) { | 1915 if (this.isOnGData()) { |
| 1912 this.updateOffline_( | 1916 this.updateOffline_( |
| 1913 div, this.metadataCache_.getCached(entry, 'gdata')); | 1917 div, this.metadataCache_.getCached(entry, 'gdata')); |
| 1914 } | 1918 } |
| 1915 return div; | 1919 return div; |
| 1916 }; | 1920 }; |
| 1917 | 1921 |
| 1918 FileManager.prototype.updateOffline_ = function(div, gdata) { | 1922 FileManager.prototype.updateOffline_ = function(div, gdata) { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2298 FileManager.prototype.onCheckboxClick_ = function(event) { | 2302 FileManager.prototype.onCheckboxClick_ = function(event) { |
| 2299 var sm = this.directoryModel_.getFileListSelection(); | 2303 var sm = this.directoryModel_.getFileListSelection(); |
| 2300 var listIndex = this.findListItemForEvent_(event).listIndex; | 2304 var listIndex = this.findListItemForEvent_(event).listIndex; |
| 2301 sm.setIndexSelected(listIndex, event.target.checked); | 2305 sm.setIndexSelected(listIndex, event.target.checked); |
| 2302 sm.leadIndex = listIndex; | 2306 sm.leadIndex = listIndex; |
| 2303 if (sm.anchorIndex == -1) | 2307 if (sm.anchorIndex == -1) |
| 2304 sm.anchorIndex = listIndex; | 2308 sm.anchorIndex = listIndex; |
| 2305 }; | 2309 }; |
| 2306 | 2310 |
| 2307 FileManager.prototype.onPinClick_ = function(checkbox, entry, event) { | 2311 FileManager.prototype.onPinClick_ = function(checkbox, entry, event) { |
| 2308 // TODO(dgozman): revisit this method when gdata properties updated event | 2312 var command = this.document_.querySelector('command#available-offline'); |
| 2309 // will be available. | 2313 command.canExecuteChange(checkbox); |
| 2310 var self = this; | 2314 command.execute(checkbox); |
| 2311 var pin = checkbox.checked; | |
| 2312 function callback(props) { | |
| 2313 var fileProps = props[0]; | |
| 2314 if (fileProps.errorCode && pin) { | |
| 2315 self.metadataCache_.get(entry, 'filesystem', function(filesystem) { | |
| 2316 self.alert.showHtml(str('GDATA_OUT_OF_SPACE_HEADER'), | |
| 2317 strf('GDATA_OUT_OF_SPACE_MESSAGE', | |
| 2318 unescape(entry.name), | |
| 2319 util.bytesToSi(filesystem.size))); | |
| 2320 }); | |
| 2321 } | |
| 2322 // We don't have update events yet, so clear the cached data. | |
| 2323 self.metadataCache_.clear(entry, 'gdata'); | |
| 2324 checkbox.checked = fileProps.isPinned; | |
| 2325 } | |
| 2326 chrome.fileBrowserPrivate.pinGDataFile([entry.toURL()], pin, callback); | |
| 2327 event.preventDefault(); | 2315 event.preventDefault(); |
| 2328 }; | 2316 }; |
| 2329 | 2317 |
| 2330 FileManager.prototype.selectDefaultPathInFilenameInput_ = function() { | 2318 FileManager.prototype.selectDefaultPathInFilenameInput_ = function() { |
| 2331 var input = this.filenameInput_; | 2319 var input = this.filenameInput_; |
| 2332 input.focus(); | 2320 input.focus(); |
| 2333 var selectionEnd = input.value.lastIndexOf('.'); | 2321 var selectionEnd = input.value.lastIndexOf('.'); |
| 2334 if (selectionEnd == -1) { | 2322 if (selectionEnd == -1) { |
| 2335 input.select(); | 2323 input.select(); |
| 2336 } else { | 2324 } else { |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3396 return this.directoryModel_.getFileList(); | 3384 return this.directoryModel_.getFileList(); |
| 3397 }; | 3385 }; |
| 3398 | 3386 |
| 3399 /** | 3387 /** |
| 3400 * @return {cr.ui.List} Current list object. | 3388 * @return {cr.ui.List} Current list object. |
| 3401 */ | 3389 */ |
| 3402 FileManager.prototype.getCurrentList = function() { | 3390 FileManager.prototype.getCurrentList = function() { |
| 3403 return this.currentList_; | 3391 return this.currentList_; |
| 3404 }; | 3392 }; |
| 3405 })(); | 3393 })(); |
| OLD | NEW |