Update collection context menu once items have loaded

Otherwise, when right-clicking on a collection that's not currently
selected, some of the menu items appear gray at first, and a second
right-click is necessary after the items have loaded. This way the menu
items turn black once the items have loaded.
This commit is contained in:
Dan Stillman 2016-04-11 02:52:09 -04:00
parent bb4db297c4
commit aee214ed44
2 changed files with 14 additions and 5 deletions

View File

@ -37,6 +37,10 @@ Zotero.LibraryTreeView = function () {
}; };
Zotero.LibraryTreeView.prototype = { Zotero.LibraryTreeView.prototype = {
get initialized() {
return this._initialized;
},
addEventListener: function(event, listener) { addEventListener: function(event, listener) {
if (event == 'load') { if (event == 'load') {
// If already initialized run now // If already initialized run now

View File

@ -2338,14 +2338,19 @@ var ZoteroPane = new function()
m.loadReport m.loadReport
]; ];
var s = [m.exportCollection, m.createBibCollection, m.loadReport]; var s = [m.exportCollection, m.createBibCollection, m.loadReport];
if (!this.itemsView.rowCount) { if (!this.itemsView.rowCount) {
if (!this.collectionsView.isContainerEmpty(this.collectionsView.selection.currentIndex)) { // If no items, it might be because this was a right-click on a different collection
disable = [m.createBibCollection, m.loadReport]; // and the new collection's items are still loading, so update the menu after loading.
// This causes export/createBib/loadReport to appear gray in the menu at first and then
// turn black once there are items.
if (!this.itemsView.initialized) {
this.itemsView.addEventListener('load', function () {
this.buildCollectionContextMenu();
}.bind(this));
} }
else {
disable = s; disable = s;
} }
}
// Adjust labels // Adjust labels
menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.rename.collection')); menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.rename.collection'));