| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Called from the main frame when unloading. | 8 * Called from the main frame when unloading. |
| 9 * @return {string?} User-visible message on null if it is OK to close. | 9 * @return {string?} User-visible message on null if it is OK to close. |
| 10 */ | 10 */ |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 var plural = itemsToRemove.length > 1; | 492 var plural = itemsToRemove.length > 1; |
| 493 var param = plural ? itemsToRemove.length : itemsToRemove[0].getFileName(); | 493 var param = plural ? itemsToRemove.length : itemsToRemove[0].getFileName(); |
| 494 | 494 |
| 495 function deleteNext() { | 495 function deleteNext() { |
| 496 if (!itemsToRemove.length) | 496 if (!itemsToRemove.length) |
| 497 return; // All deleted. | 497 return; // All deleted. |
| 498 | 498 |
| 499 // TODO(hirono): Use fileOperationManager. | 499 // TODO(hirono): Use fileOperationManager. |
| 500 var entry = itemsToRemove.pop().getEntry(); | 500 var entry = itemsToRemove.pop().getEntry(); |
| 501 entry.remove(deleteNext, function() { | 501 entry.remove(deleteNext, function() { |
| 502 util.flog('Error deleting: ' + entry.fullPath, deleteNext); | 502 util.flog('Error deleting: ' + entry.name, deleteNext); |
| 503 }); | 503 }); |
| 504 } | 504 } |
| 505 | 505 |
| 506 // Prevent the Gallery from handling Esc and Enter. | 506 // Prevent the Gallery from handling Esc and Enter. |
| 507 this.document_.body.removeEventListener('keydown', this.keyDownBound_); | 507 this.document_.body.removeEventListener('keydown', this.keyDownBound_); |
| 508 var restoreListener = function() { | 508 var restoreListener = function() { |
| 509 this.document_.body.addEventListener('keydown', this.keyDownBound_); | 509 this.document_.body.addEventListener('keydown', this.keyDownBound_); |
| 510 }.bind(this); | 510 }.bind(this); |
| 511 | 511 |
| 512 cr.ui.dialogs.BaseDialog.OK_LABEL = this.displayStringFunction_( | 512 cr.ui.dialogs.BaseDialog.OK_LABEL = this.displayStringFunction_( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 }; | 630 }; |
| 631 | 631 |
| 632 // Name box and rename support. | 632 // Name box and rename support. |
| 633 | 633 |
| 634 /** | 634 /** |
| 635 * Updates the UI related to the selected item and the persistent state. | 635 * Updates the UI related to the selected item and the persistent state. |
| 636 * | 636 * |
| 637 * @private | 637 * @private |
| 638 */ | 638 */ |
| 639 Gallery.prototype.updateSelectionAndState_ = function() { | 639 Gallery.prototype.updateSelectionAndState_ = function() { |
| 640 var path; | |
| 641 var displayName = ''; | 640 var displayName = ''; |
| 642 | 641 |
| 643 // TODO(mtomasz): Migrate fullPath to toURL(). | |
| 644 var selectedItems = this.getSelectedItems(); | 642 var selectedItems = this.getSelectedItems(); |
| 645 if (selectedItems.length === 1) { | 643 if (selectedItems.length === 1) { |
| 646 var item = selectedItems[0]; | 644 var item = selectedItems[0]; |
| 647 var entry = item.getEntry(); | 645 var entry = item.getEntry(); |
| 648 path = entry.fullPath; | |
| 649 window.top.document.title = entry.name; | 646 window.top.document.title = entry.name; |
| 650 displayName = ImageUtil.getDisplayNameFromName(entry.name); | 647 displayName = ImageUtil.getDisplayNameFromName(entry.name); |
| 651 } else if (selectedItems.length > 1 && this.context_.curDirEntry) { | 648 } else if (selectedItems.length > 1 && this.context_.curDirEntry) { |
| 652 // If the Gallery was opened on search results the search query will not be | 649 // If the Gallery was opened on search results the search query will not be |
| 653 // recorded in the app state and the relaunch will just open the gallery | 650 // recorded in the app state and the relaunch will just open the gallery |
| 654 // in the curDirEntry directory. | 651 // in the curDirEntry directory. |
| 655 path = this.context_.curDirEntry.fullPath; | |
| 656 window.top.document.title = this.context_.curDirEntry.name; | 652 window.top.document.title = this.context_.curDirEntry.name; |
| 657 displayName = | 653 displayName = |
| 658 this.displayStringFunction_('GALLERY_ITEMS_SELECTED', | 654 this.displayStringFunction_('GALLERY_ITEMS_SELECTED', |
| 659 selectedItems.length); | 655 selectedItems.length); |
| 660 } | 656 } |
| 661 | 657 |
| 662 window.top.util.updateAppState( | 658 window.top.util.updateAppState( |
| 663 null, // Keep the current directory. | 659 null, // Keep the current directory. |
| 664 path, // Update the selection. | 660 entry.toURL(), // Update the selection. |
| 665 {gallery: (this.currentMode_ === this.mosaicMode_ ? 'mosaic' : 'slide')}); | 661 {gallery: (this.currentMode_ === this.mosaicMode_ ? 'mosaic' : 'slide')}); |
| 666 | 662 |
| 667 // We can't rename files in readonly directory. | 663 // We can't rename files in readonly directory. |
| 668 // We can only rename a single file. | 664 // We can only rename a single file. |
| 669 this.filenameEdit_.disabled = selectedItems.length !== 1 || | 665 this.filenameEdit_.disabled = selectedItems.length !== 1 || |
| 670 this.context_.readonlyDirName; | 666 this.context_.readonlyDirName; |
| 671 | 667 |
| 672 this.filenameEdit_.value = displayName; | 668 this.filenameEdit_.value = displayName; |
| 673 | 669 |
| 674 // Resolve real filesystem path of the current file. | |
| 675 if (this.selectionModel_.selectedIndexes.length) { | 670 if (this.selectionModel_.selectedIndexes.length) { |
| 676 var selectedIndex = this.selectionModel_.selectedIndex; | 671 var selectedIndex = this.selectionModel_.selectedIndex; |
| 677 var selectedItem = | 672 var selectedItem = |
| 678 this.dataModel_.item(this.selectionModel_.selectedIndex); | 673 this.dataModel_.item(this.selectionModel_.selectedIndex); |
| 679 this.selectedEntry_ = selectedItem.getEntry(); | 674 this.selectedEntry_ = selectedItem.getEntry(); |
| 680 } | 675 } |
| 681 }; | 676 }; |
| 682 | 677 |
| 683 /** | 678 /** |
| 684 * Click event handler on filename edit box | 679 * Click event handler on filename edit box |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 */ | 863 */ |
| 869 Gallery.prototype.updateButtons_ = function() { | 864 Gallery.prototype.updateButtons_ = function() { |
| 870 if (this.modeButton_) { | 865 if (this.modeButton_) { |
| 871 var oppositeMode = | 866 var oppositeMode = |
| 872 this.currentMode_ === this.slideMode_ ? this.mosaicMode_ : | 867 this.currentMode_ === this.slideMode_ ? this.mosaicMode_ : |
| 873 this.slideMode_; | 868 this.slideMode_; |
| 874 this.modeButton_.title = | 869 this.modeButton_.title = |
| 875 this.displayStringFunction_(oppositeMode.getTitle()); | 870 this.displayStringFunction_(oppositeMode.getTitle()); |
| 876 } | 871 } |
| 877 }; | 872 }; |
| OLD | NEW |