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

Unified Diff: chrome/browser/resources/file_manager/js/photo/gallery.js

Issue 10909095: Delete images in Photo Editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment, changed bg color, fixed an exception Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/file_manager/js/mock_chrome.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/photo/gallery.js
diff --git a/chrome/browser/resources/file_manager/js/photo/gallery.js b/chrome/browser/resources/file_manager/js/photo/gallery.js
index 9b9912ce11a3161a962e81fc74bbf81cd123300f..9b9e98c61a326c49713f18be31579d41668d760d 100644
--- a/chrome/browser/resources/file_manager/js/photo/gallery.js
+++ b/chrome/browser/resources/file_manager/js/photo/gallery.js
@@ -149,7 +149,8 @@ Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming';
Gallery.prototype.initListeners_ = function() {
this.document_.oncontextmenu = function(e) { e.preventDefault(); };
- this.document_.body.addEventListener('keydown', this.onKeyDown_.bind(this));
+ this.keyDownBound_ = this.onKeyDown_.bind(this);
+ this.document_.body.addEventListener('keydown', this.keyDownBound_);
this.inactivityWatcher_ = new MouseInactivityWatcher(
this.container_, Gallery.FADE_TIMEOUT, this.hasActiveTool.bind(this));
@@ -381,14 +382,52 @@ Gallery.prototype.toggleMode_ = function(opt_callback) {
*/
Gallery.prototype.onDelete_ = function() {
// Clone the sorted selected indexes array.
- var toRemove = this.selectionModel_.selectedIndexes.slice();
- this.selectionModel_.unselectAll();
+ var indexesToRemove = this.selectionModel_.selectedIndexes.slice();
+ if (!indexesToRemove.length)
+ return;
+
+ /* TODO(dgozman): Implement Undo delete, Remove the confirmation dialog. */
+
+ var itemsToRemove = this.getSelectedItems();
+ var plural = itemsToRemove.length > 1;
+ var param = plural ? itemsToRemove.length : itemsToRemove[0].getFileName();
+
+ function deleteNext() {
+ if (!itemsToRemove.length)
+ return; // All deleted.
- // Remove items starting from the highest index.
- while (toRemove.length)
- this.dataModel_.splice(toRemove.pop(), 1);
+ var url = itemsToRemove.pop().getUrl();
+ webkitResolveLocalFileSystemURL(url,
+ function(entry) {
+ entry.remove(deleteNext,
+ util.flog('Error deleting ' + url, deleteNext));
+ },
+ util.flog('Error resolving ' + url, deleteNext));
+ }
+
+ // Prevent the Gallery from handling Esc and Enter.
+ this.document_.body.removeEventListener('keydown', this.keyDownBound_);
+ var restoreListener = function() {
+ this.document_.body.addEventListener('keydown', this.keyDownBound_);
+ }.bind(this);
- // TODO: delete actual files.
+ cr.ui.dialogs.BaseDialog.OK_LABEL = this.displayStringFunction_('OK_LABEL');
+ cr.ui.dialogs.BaseDialog.CANCEL_LABEL =
+ this.displayStringFunction_('CANCEL_LABEL');
+ var confirm = new cr.ui.dialogs.ConfirmDialog(this.container_);
+ confirm.show(this.displayStringFunction_(
+ plural ? 'CONFIRM_DELETE_SOME' : 'CONFIRM_DELETE_ONE', param),
+ function() {
+ restoreListener();
+ this.selectionModel_.unselectAll();
+ this.selectionModel_.leadIndex = -1;
+ // Remove items from the data model, starting from the highest index.
+ while (indexesToRemove.length)
+ this.dataModel_.splice(indexesToRemove.pop(), 1);
+ // Delete actual files.
+ deleteNext();
+ }.bind(this),
+ restoreListener);
};
/**
« no previous file with comments | « chrome/browser/resources/file_manager/js/mock_chrome.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698