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 = {
get initialized() {
return this._initialized;
},
addEventListener: function(event, listener) {
if (event == 'load') {
// If already initialized run now

View File

@ -2338,13 +2338,18 @@ var ZoteroPane = new function()
m.loadReport
];
var s = [m.exportCollection, m.createBibCollection, m.loadReport];
if (!this.itemsView.rowCount) {
if (!this.collectionsView.isContainerEmpty(this.collectionsView.selection.currentIndex)) {
disable = [m.createBibCollection, m.loadReport];
}
else {
disable = s;
// If no items, it might be because this was a right-click on a different collection
// 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));
}
disable = s;
}
// Adjust labels