Don't show item context menu until it's ready
With async generation, an incorrect menu was showing first before the correct version appeared.
This commit is contained in:
parent
014724a64a
commit
6ccfed2488
3 changed files with 23 additions and 9 deletions
|
@ -94,8 +94,9 @@ var Zotero_LocateMenu = new function() {
|
||||||
* Clear the bottom part of the context menu and add locate options
|
* Clear the bottom part of the context menu and add locate options
|
||||||
* @param {menupopup} menu The menu to add context menu items to
|
* @param {menupopup} menu The menu to add context menu items to
|
||||||
* @param {Boolean} showIcons Whether menu items should have associated icons
|
* @param {Boolean} showIcons Whether menu items should have associated icons
|
||||||
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
this.buildContextMenu = function(menu, showIcons) {
|
this.buildContextMenu = Zotero.Promise.coroutine(function* (menu, showIcons) {
|
||||||
// get selected items
|
// get selected items
|
||||||
var selectedItems = _getSelectedItems();
|
var selectedItems = _getSelectedItems();
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
if(!selectedItems.length || selectedItems.length > 20) return;
|
if(!selectedItems.length || selectedItems.length > 20) return;
|
||||||
|
|
||||||
// add view options
|
// add view options
|
||||||
_addViewOptions(menu, selectedItems, showIcons);
|
yield _addViewOptions(menu, selectedItems, showIcons);
|
||||||
|
|
||||||
/*// look for locate engines
|
/*// look for locate engines
|
||||||
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
||||||
|
@ -119,7 +120,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
submenu.appendChild(submenuPopup);
|
submenu.appendChild(submenuPopup);
|
||||||
menu.appendChild(submenu);
|
menu.appendChild(submenu);
|
||||||
}*/
|
}*/
|
||||||
}
|
});
|
||||||
|
|
||||||
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
||||||
var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
|
var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
|
||||||
|
|
|
@ -2591,7 +2591,7 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
// add locate menu options
|
// add locate menu options
|
||||||
Zotero_LocateMenu.buildContextMenu(menu, true);
|
yield Zotero_LocateMenu.buildContextMenu(menu, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -2625,12 +2625,25 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically select all equivalent items when clicking on an item
|
|
||||||
// in duplicates view
|
|
||||||
else if (tree.id == 'zotero-items-tree') {
|
else if (tree.id == 'zotero-items-tree') {
|
||||||
|
// Show context menu once it's ready
|
||||||
|
if (event.button == 2) {
|
||||||
|
// Allow item to be selected first
|
||||||
|
setTimeout(function () {
|
||||||
|
ZoteroPane_Local.buildItemContextMenu()
|
||||||
|
.then(function () {
|
||||||
|
document.getElementById('zotero-itemmenu').openPopup(
|
||||||
|
null, null, event.clientX, event.clientY, true, false, event
|
||||||
|
);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let collectionTreeRow = ZoteroPane_Local.getCollectionTreeRow();
|
let collectionTreeRow = ZoteroPane_Local.getCollectionTreeRow();
|
||||||
|
|
||||||
|
// Automatically select all equivalent items when clicking on an item
|
||||||
|
// in duplicates view
|
||||||
if (collectionTreeRow.isDuplicates()) {
|
if (collectionTreeRow.isDuplicates()) {
|
||||||
// Trigger only on primary-button single clicks without modifiers
|
// Trigger only on primary-button single clicks without modifiers
|
||||||
// (so that items can still be selected and deselected manually)
|
// (so that items can still be selected and deselected manually)
|
||||||
|
|
|
@ -258,7 +258,7 @@
|
||||||
<menuitem label="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane_Local.createCommonsBucket();"/><!--TODO localize -->
|
<menuitem label="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane_Local.createCommonsBucket();"/><!--TODO localize -->
|
||||||
<menuitem label="Refresh" oncommand="ZoteroPane_Local.refreshCommonsBucket();"/><!--TODO localize -->
|
<menuitem label="Refresh" oncommand="ZoteroPane_Local.refreshCommonsBucket();"/><!--TODO localize -->
|
||||||
</menupopup>
|
</menupopup>
|
||||||
<menupopup id="zotero-itemmenu" onpopupshowing="ZoteroPane_Local.buildItemContextMenu();">
|
<menupopup id="zotero-itemmenu">
|
||||||
<!-- Keep order in sync with buildItemContextMenu -->
|
<!-- Keep order in sync with buildItemContextMenu -->
|
||||||
<menuitem class="menuitem-iconic zotero-menuitem-show-in-library" label="&zotero.items.menu.showInLibrary;" oncommand="ZoteroPane_Local.selectItem(this.parentNode.getAttribute('itemID'), true)"/>
|
<menuitem class="menuitem-iconic zotero-menuitem-show-in-library" label="&zotero.items.menu.showInLibrary;" oncommand="ZoteroPane_Local.selectItem(this.parentNode.getAttribute('itemID'), true)"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
|
@ -340,7 +340,7 @@
|
||||||
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
|
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
|
||||||
<!-- Key navigation is handled by listener in itemTreeView.js -->
|
<!-- Key navigation is handled by listener in itemTreeView.js -->
|
||||||
<tree
|
<tree
|
||||||
id="zotero-items-tree" context="zotero-itemmenu"
|
id="zotero-items-tree"
|
||||||
enableColumnDrag="true"
|
enableColumnDrag="true"
|
||||||
disableKeyNavigation="true"
|
disableKeyNavigation="true"
|
||||||
onfocus="if (ZoteroPane_Local.itemsView.rowCount && !ZoteroPane_Local.itemsView.selection.count) { ZoteroPane_Local.itemsView.selection.select(0); }"
|
onfocus="if (ZoteroPane_Local.itemsView.rowCount && !ZoteroPane_Local.itemsView.selection.count) { ZoteroPane_Local.itemsView.selection.select(0); }"
|
||||||
|
|
Loading…
Reference in a new issue