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

Unified Diff: chrome/browser/resources/md_bookmarks/command_manager.js

Issue 2924253002: [MD Bookmarks] Add bookmark count to context menu for multiple items. (Closed)
Patch Set: rebase, address comments Created 3 years, 6 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/md_bookmarks/command_manager.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/command_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/command_manager.js b/chrome/browser/resources/md_bookmarks/command_manager.js
index 24c26d51c673ca4bed26f2de7693e02bdd4bce12..46bd2bb83aaa2510150bc3fdfd0a4e0f7064b6a3 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -33,7 +33,16 @@ cr.define('bookmarks', function() {
},
/** @private {Set<string>} */
- menuIds_: Object,
+ menuIds_: {
+ type: Object,
+ observer: 'onMenuIdsChanged_',
+ },
+
+ /** @private */
+ hasAnySublabel_: {
+ type: Boolean,
+ reflectToAttribute: true,
+ },
/** @private */
globalCanEdit_: Boolean,
@@ -398,7 +407,8 @@ cr.define('bookmarks', function() {
* @private
*/
onCommandClick_: function(e) {
- this.handle(e.target.getAttribute('command'), assert(this.menuIds_));
+ this.handle(
+ e.currentTarget.getAttribute('command'), assert(this.menuIds_));
this.closeCommandMenu();
},
@@ -466,6 +476,35 @@ cr.define('bookmarks', function() {
return loadTimeData.getString(assert(label));
},
+ /**
+ * @param {Command} command
+ * @return {string}
+ * @private
+ */
+ getCommandSublabel_: function(command) {
+ var multipleNodes = this.menuIds_.size > 1 ||
+ this.containsMatchingNode_(this.menuIds_, function(node) {
+ return !node.url;
+ });
+ switch (command) {
+ case Command.OPEN_NEW_TAB:
+ var urls = this.expandUrls_(this.menuIds_);
+ return multipleNodes && urls.length > 0 ? String(urls.length) : '';
+ default:
+ return '';
+ }
+ },
+
+ /** @private */
+ onMenuIdsChanged_: function() {
+ if (!this.menuIds_)
+ return;
+
+ this.hasAnySublabel_ = this.menuCommands_.some(function(command) {
+ return this.getCommandSublabel_(command) != '';
+ }.bind(this));
+ },
+
/**
* @param {Command} command
* @return {boolean}
« no previous file with comments | « chrome/browser/resources/md_bookmarks/command_manager.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698