Allow click on menu title to select feed item add target
Instead of requiring a click on the menuitem at the top of the submenu, allow a click on the menu itself. This is a hack that, among other things, replicates the flash effect on menuitems on OS X. Unfortunately, <menu> elements can't have checkboxes, so only the menuitem in the submenu will be checked. (Otherwise I'd remove the redundant menuitem in the submenu.)
This commit is contained in:
parent
4bc4acb923
commit
afaaf20c90
|
@ -251,8 +251,28 @@ var ZoteroItemPane = new function() {
|
||||||
menu,
|
menu,
|
||||||
target,
|
target,
|
||||||
function(event, libraryOrCollection) {
|
function(event, libraryOrCollection) {
|
||||||
|
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);
|
ZoteroItemPane.setTranslationTarget(libraryOrCollection);
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ZoteroItemPane.setTranslationTarget(libraryOrCollection);
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -955,10 +955,13 @@ Zotero.Utilities.Internal = {
|
||||||
return menuitem
|
return menuitem
|
||||||
}
|
}
|
||||||
|
|
||||||
function _createMenu(label, icon) {
|
function _createMenu(label, value, icon, command) {
|
||||||
let menu = doc.createElement('menu');
|
let menu = doc.createElement('menu');
|
||||||
menu.setAttribute("label", label);
|
menu.setAttribute("label", label);
|
||||||
|
menu.setAttribute("value", value);
|
||||||
menu.setAttribute("image", icon);
|
menu.setAttribute("image", icon);
|
||||||
|
// Allow click on menu itself to select a target
|
||||||
|
menu.addEventListener('click', command);
|
||||||
menu.classList.add('menu-iconic');
|
menu.classList.add('menu-iconic');
|
||||||
let menupopup = doc.createElement('menupopup');
|
let menupopup = doc.createElement('menupopup');
|
||||||
menu.appendChild(menupopup);
|
menu.appendChild(menupopup);
|
||||||
|
@ -985,12 +988,21 @@ Zotero.Utilities.Internal = {
|
||||||
collections = Zotero.Collections.getByLibrary(libraryOrCollection.id);
|
collections = Zotero.Collections.getByLibrary(libraryOrCollection.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no subcollections, place menuitem for target directly in containing men
|
||||||
if (collections.length == 0) {
|
if (collections.length == 0) {
|
||||||
elem.appendChild(menuitem);
|
elem.appendChild(menuitem);
|
||||||
return 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;
|
var menupopup = menu.firstChild;
|
||||||
menupopup.appendChild(menuitem);
|
menupopup.appendChild(menuitem);
|
||||||
menupopup.appendChild(doc.createElement('menuseparator'));
|
menupopup.appendChild(doc.createElement('menuseparator'));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user