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

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

Issue 2467007: Bookmarks: Disable the sort command when there are no items to sort.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/bookmark_manager/main.html
===================================================================
--- chrome/browser/resources/bookmark_manager/main.html (revision 48743)
+++ chrome/browser/resources/bookmark_manager/main.html (working copy)
@@ -1135,6 +1135,49 @@
}
});
+/**
+ * Helper function for handling canExecute for the list and the tree.
+ * @param {!Event} e Can exectue event object.
+ * @param {boolean} isRecentOrSearch Whether the user is trying to do a command
+ * on recent or search.
+ */
+function canExcuteShared(e, isRecentOrSearch) {
+ var command = e.command;
+ var commandId = command.id;
+ switch (commandId) {
+ case 'paste-command':
+ updatePasteCommand();
+ break;
+
+ case 'sort-command':
+ if (isRecentOrSearch) {
+ e.canExecute = false;
+ } else {
+ e.canExecute = list.items.length > 0;
+
+ // The list might be loading
+ var f = function() {
+ list.removeEventListener('load', f);
+ command.disabled = list.items.length == 0;
+ };
+ list.addEventListener('load', f);
+ }
+ break;
+
+ case 'add-new-bookmark-command':
+ case 'new-folder-command':
+ e.canExecute = !isRecentOrSearch;
+ break;
+
+ case 'open-in-new-tab-command':
+ case 'open-in-background-tab-command':
+ case 'open-in-new-window-command':
+ case 'open-incognito-window-command':
+ updateOpenCommands(e, command);
+ break;
+ }
+}
+
// Update canExecute for the commands when the list is the active element.
list.addEventListener('canExecute', function(e) {
if (e.target != list) return;
@@ -1191,26 +1234,12 @@
e.canExecute = hasSelected();
break;
- case 'paste-command':
- updatePasteCommand();
- break;
-
- case 'sort-command':
- case 'add-new-bookmark-command':
- case 'new-folder-command':
- e.canExecute = !isRecentOrSearch();
- break;
-
- case 'open-in-new-tab-command':
- case 'open-in-background-tab-command':
- case 'open-in-new-window-command':
- case 'open-incognito-window-command':
- updateOpenCommands(e, command);
- break;
-
case 'open-in-same-window-command':
e.canExecute = hasSelected();
break;
+
+ default:
+ canExcuteShared(e, isRecentOrSearch());
}
});
@@ -1251,22 +1280,8 @@
e.canExecute = hasSelected() && !isTopLevelItem();
break;
- case 'paste-command':
- updatePasteCommand();
- break;
-
- case 'sort-command':
- case 'add-new-bookmark-command':
- case 'new-folder-command':
- e.canExecute = !isRecentOrSearch();
- break;
-
- case 'open-in-new-tab-command':
- case 'open-in-background-tab-command':
- case 'open-in-new-window-command':
- case 'open-incognito-window-command':
- updateOpenCommands(e, command);
- break;
+ default:
+ canExcuteShared(e, isRecentOrSearch());
}
});
« 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