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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/file_manager_commands.js

Issue 1243273003: Fix Closure Compiler error which is introduced by crrev.com/1233913010 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Sets 'hidden' property of a cr.ui.Command instance and dispatches 6 * Sets 'hidden' property of a cr.ui.Command instance and dispatches
7 * 'hiddenChange' event manually so that associated cr.ui.MenuItem can handle 7 * 'hiddenChange' event manually so that associated cr.ui.MenuItem can handle
8 * the event. 8 * the event.
9 * TODO(fukino): Remove this workaround when crbug.com/481941 is fixed. 9 * TODO(fukino): Remove this workaround when crbug.com/481941 is fixed.
10 * 10 *
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 canExecute: function(event, fileManager) { 650 canExecute: function(event, fileManager) {
651 event.canExecute = fileManager.shouldShowDriveSettings(); 651 event.canExecute = fileManager.shouldShowDriveSettings();
652 event.command.setHidden(!event.canExecute); 652 event.command.setHidden(!event.canExecute);
653 } 653 }
654 }); 654 });
655 655
656 /** 656 /**
657 * Deletes selected files. 657 * Deletes selected files.
658 * @type {Command} 658 * @type {Command}
659 */ 659 */
660 CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ 660 CommandHandler.COMMANDS_['delete'] = (function() {
661 /** 661 /**
662 * @param {!Event} event Command event. 662 * @constructor
663 * @param {!FileManager} fileManager FileManager to use. 663 * @implements {Command}
664 */ 664 */
665 execute: function(event, fileManager) { 665 var DeleteCommand = function() {};
666 var entries = CommandUtil.getCommandEntries(event.target);
667 666
668 // Execute might be called without a call of canExecute method, e.g. called 667 DeleteCommand.prototype = {
669 // directly from code. Double check here not to delete undeletable entries. 668 /**
670 if (this.containsFakeOrRootEntry_(entries, fileManager) || 669 * @param {!Event} event Command event.
671 this.containsReadOnlyEntry_(entries, fileManager)) 670 * @param {!FileManager} fileManager FileManager to use.
672 return; 671 */
672 execute: function(event, fileManager) {
673 var entries = CommandUtil.getCommandEntries(event.target);
673 674
674 var message = entries.length === 1 ? 675 // Execute might be called without a call of canExecute method,
675 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) : 676 // e.g. called directly from code. Double check here not to delete
676 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length); 677 // undeletable entries.
678 if (this.containsFakeOrRootEntry_(entries, fileManager) ||
679 this.containsReadOnlyEntry_(entries, fileManager))
680 return;
677 681
678 fileManager.ui.deleteConfirmDialog.show(message, function() { 682 var message = entries.length === 1 ?
679 fileManager.fileOperationManager.deleteEntries(entries); 683 strf('GALLERY_CONFIRM_DELETE_ONE', entries[0].name) :
680 }, null, null); 684 strf('GALLERY_CONFIRM_DELETE_SOME', entries.length);
681 },
682 /**
683 * @param {!Event} event Command event.
684 * @param {!FileManager} fileManager FileManager to use.
685 */
686 canExecute: function(event, fileManager) {
687 var entries = CommandUtil.getCommandEntries(event.target);
688 685
689 // If entries contain fake or root entry, hide delete option. 686 fileManager.ui.deleteConfirmDialog.show(message, function() {
690 if (this.containsFakeOrRootEntry_(entries, fileManager)) { 687 fileManager.fileOperationManager.deleteEntries(entries);
691 event.canExecute = false; 688 }, null, null);
692 event.command.setHidden(true); 689 },
693 return; 690
691 /**
692 * @param {!Event} event Command event.
693 * @param {!FileManager} fileManager FileManager to use.
694 */
695 canExecute: function(event, fileManager) {
696 var entries = CommandUtil.getCommandEntries(event.target);
697
698 // If entries contain fake or root entry, hide delete option.
699 if (this.containsFakeOrRootEntry_(entries, fileManager)) {
700 event.canExecute = false;
701 event.command.setHidden(true);
702 return;
703 }
704
705 event.canExecute = entries.length > 0 &&
706 !this.containsReadOnlyEntry_(entries, fileManager);
707 event.command.setHidden(false);
708 },
709
710 /**
711 * @param {!Array<!Entry>} entries
712 * @param {!FileManager} fileManager
713 * @return {boolean} True if entries contain fake or root entry.
714 */
715 containsFakeOrRootEntry_: function(entries, fileManager) {
716 return entries.some(function(entry) {
717 if (util.isFakeEntry(entry))
718 return true;
719
720 var volumeInfo = fileManager.volumeManager.getVolumeInfo(entry);
721 if (!volumeInfo)
722 return true;
723
724 return volumeInfo.displayRoot === entry;
725 });
726 },
727
728 /**
729 * @param {!Array<!Entry>} entries
730 * @param {!FileManager} fileManager
731 * @return {boolean} True if entries contain read only entry.
732 */
733 containsReadOnlyEntry_: function(entries, fileManager) {
734 return entries.some(function(entry) {
735 var locationInfo = fileManager.volumeManager.getLocationInfo(entry);
736 return locationInfo && locationInfo.isReadOnly;
737 });
694 } 738 }
739 };
695 740
696 event.canExecute = entries.length > 0 && 741 return new DeleteCommand();
697 !this.containsReadOnlyEntry_(entries, fileManager); 742 })();
698 event.command.setHidden(false);
699 },
700 /**
701 * @param {!Array<!Entry>} entries
702 * @param {!FileManager} fileManager
703 * @return {boolean} True if entries contain fake or root entry.
704 */
705 containsFakeOrRootEntry_: function(entries, fileManager) {
706 return entries.some(function(entry) {
707 if (util.isFakeEntry(entry))
708 return true;
709
710 var volumeInfo = fileManager.volumeManager.getVolumeInfo(entry);
711 if (!volumeInfo)
712 return true;
713
714 return volumeInfo.displayRoot === entry;
715 });
716 },
717 /**
718 * @param {!Array<!Entry>} entries
719 * @param {!FileManager} fileManager
720 * @return {boolean} True if entries contain read only entry.
721 */
722 containsReadOnlyEntry_: function(entries, fileManager) {
723 return entries.some(function(entry) {
724 var locationInfo = fileManager.volumeManager.getLocationInfo(entry);
725 return locationInfo && locationInfo.isReadOnly;
726 });
727 }
728 });
729 743
730 /** 744 /**
731 * Pastes files from clipboard. 745 * Pastes files from clipboard.
732 * @type {Command} 746 * @type {Command}
733 */ 747 */
734 CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({ 748 CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({
735 /** 749 /**
736 * @param {!Event} event Command event. 750 * @param {!Event} event Command event.
737 * @param {!FileManager} fileManager FileManager to use. 751 * @param {!FileManager} fileManager FileManager to use.
738 */ 752 */
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 */ 1401 */
1388 CommandHandler.COMMANDS_['configure'] = (function() { 1402 CommandHandler.COMMANDS_['configure'] = (function() {
1389 /** 1403 /**
1390 * @constructor 1404 * @constructor
1391 * @implements {Command} 1405 * @implements {Command}
1392 */ 1406 */
1393 var ConfigureCommand = function() { 1407 var ConfigureCommand = function() {
1394 }; 1408 };
1395 1409
1396 ConfigureCommand.prototype = { 1410 ConfigureCommand.prototype = {
1397 __proto__: Command.prototype,
1398
1399 /** 1411 /**
1400 * @param {EventTarget} element 1412 * @param {EventTarget} element
1401 * @param {!FileManager} fileManager 1413 * @param {!FileManager} fileManager
1402 * @return {VolumeInfo} 1414 * @return {VolumeInfo}
1403 * @private 1415 * @private
1404 */ 1416 */
1405 getElementVolumeInfo_: function(element, fileManager) { 1417 getElementVolumeInfo_: function(element, fileManager) {
1406 if (element instanceof VolumeItem) 1418 if (element instanceof VolumeItem)
1407 return element.volumeInfo; 1419 return element.volumeInfo;
1408 if (element instanceof ShortcutItem) { 1420 if (element instanceof ShortcutItem) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 }, 1475 },
1464 canExecute: function(event, fileManager) { 1476 canExecute: function(event, fileManager) {
1465 var currentDirEntry = fileManager.directoryModel.getCurrentDirEntry(); 1477 var currentDirEntry = fileManager.directoryModel.getCurrentDirEntry();
1466 var volumeInfo = currentDirEntry && 1478 var volumeInfo = currentDirEntry &&
1467 fileManager.volumeManager.getVolumeInfo(currentDirEntry); 1479 fileManager.volumeManager.getVolumeInfo(currentDirEntry);
1468 event.canExecute = volumeInfo && !volumeInfo.watchable; 1480 event.canExecute = volumeInfo && !volumeInfo.watchable;
1469 event.command.setHidden(!event.canExecute || 1481 event.command.setHidden(!event.canExecute ||
1470 fileManager.directoryModel.getFileListSelection().getCheckSelectMode()); 1482 fileManager.directoryModel.getFileListSelection().getCheckSelectMode());
1471 } 1483 }
1472 }); 1484 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698