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

Unified Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 1058873009: Bookmark manager: Pass in explicit targets to the delete and rename commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: review Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/menu.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/bookmark_manager/js/main.js
diff --git a/chrome/browser/resources/bookmark_manager/js/main.js b/chrome/browser/resources/bookmark_manager/js/main.js
index 5bd11d1878021c2203668ef36e614a818529cd76..345757525a066030ca4f1b5e30826c06f1454f15 100644
--- a/chrome/browser/resources/bookmark_manager/js/main.js
+++ b/chrome/browser/resources/bookmark_manager/js/main.js
@@ -1018,10 +1018,12 @@ function computeParentFolderForNewItem() {
/**
* Callback for rename folder and edit command. This starts editing for
- * selected item.
+ * the passed in target, or the selected item.
+ * @param {EventTarget=} opt_target The target to start editing. If absent or
+ * null, the selected item will be edited instead.
*/
-function editSelectedItem() {
- if (document.activeElement == bmm.tree) {
+function editItem(opt_target) {
+ if ((opt_target || document.activeElement) == bmm.tree) {
bmm.tree.selectedItem.editing = true;
} else {
var li = bmm.list.getListItem(bmm.list.selectedItem);
@@ -1306,7 +1308,7 @@ function handleCommand(e) {
target = bmm.tree;
case 'delete-command':
recordUserAction('Delete');
- deleteBookmarks(target);
+ deleteBookmarks(target || assertInstanceof(e.target, HTMLElement));
break;
case 'copy-from-folders-menu-command':
@@ -1346,16 +1348,16 @@ function handleCommand(e) {
break;
case 'rename-folder-command':
- editSelectedItem();
+ editItem(assertInstanceof(e.target, HTMLElement));
break;
case 'rename-folder-from-folders-menu-command':
- bmm.tree.selectedItem.editing = true;
+ editItem(bmm.tree);
break;
case 'edit-command':
recordUserAction('Edit');
- editSelectedItem();
+ editItem();
break;
case 'new-folder-from-folders-menu-command':
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698