diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index 36114d6240..e33a97f1b2 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -251,8 +251,28 @@ var ZoteroItemPane = new function() { menu, target, function(event, libraryOrCollection) { - ZoteroItemPane.setTranslationTarget(libraryOrCollection); - event.stopPropagation(); + if (event.target.tagName == 'menu') { + Zotero.Promise.coroutine(function* () { + // Simulate menuitem flash on OS X + if (Zotero.isMac) { + event.target.setAttribute('_moz-menuactive', false); + yield Zotero.Promise.delay(50); + event.target.setAttribute('_moz-menuactive', true); + yield Zotero.Promise.delay(50); + event.target.setAttribute('_moz-menuactive', false); + yield Zotero.Promise.delay(50); + event.target.setAttribute('_moz-menuactive', true); + } + menu.hidePopup(); + + ZoteroItemPane.setTranslationTarget(libraryOrCollection); + event.stopPropagation(); + })(); + } + else { + ZoteroItemPane.setTranslationTarget(libraryOrCollection); + event.stopPropagation(); + } } ); } diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 55233a28bd..032c0181c3 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -955,10 +955,13 @@ Zotero.Utilities.Internal = { return menuitem } - function _createMenu(label, icon) { + function _createMenu(label, value, icon, command) { let menu = doc.createElement('menu'); menu.setAttribute("label", label); + menu.setAttribute("value", value); menu.setAttribute("image", icon); + // Allow click on menu itself to select a target + menu.addEventListener('click', command); menu.classList.add('menu-iconic'); let menupopup = doc.createElement('menupopup'); menu.appendChild(menupopup); @@ -985,12 +988,21 @@ Zotero.Utilities.Internal = { collections = Zotero.Collections.getByLibrary(libraryOrCollection.id); } + // If no subcollections, place menuitem for target directly in containing men if (collections.length == 0) { elem.appendChild(menuitem); return menuitem } - var menu = _createMenu(libraryOrCollection.name, imageSrc); + // Otherwise create a submenu for the target's subcollections + var menu = _createMenu( + libraryOrCollection.name, + libraryOrCollection.collectionTreeViewID, + imageSrc, + function (event) { + clickAction(event, libraryOrCollection); + } + ); var menupopup = menu.firstChild; menupopup.appendChild(menuitem); menupopup.appendChild(doc.createElement('menuseparator'));