diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 36827270a9..7e9fc287ca 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2276,8 +2276,8 @@ Zotero.ItemTreeView.prototype.onColumnPickerShowing = function (event) { var lastChild = menupopup.lastChild; - // More Columns menu try { + // More Columns menu let id = prefix + 'more-menu'; let moreMenu = doc.createElementNS(ns, 'menu'); @@ -2314,6 +2314,16 @@ Zotero.ItemTreeView.prototype.onColumnPickerShowing = function (event) { moreMenu.appendChild(moreMenuPopup); menupopup.insertBefore(moreMenu, lastChild); + + // Disable certain entries for feeds + let elems = Array.from(treecols.getElementsByAttribute('hidden-in', '*')) + let labels = Array.from(elems) + .filter(e => e.getAttribute('hidden-in').split(' ').indexOf(this.collectionTreeRow.type) != -1) + .map(e => e.getAttribute('label')); + for (let i = 0; i < menupopup.childNodes.length; i++) { + let elem = menupopup.childNodes[i]; + elem.setAttribute('disabled', labels.indexOf(elem.getAttribute('label')) != -1); + } } catch (e) { Components.utils.reportError(e); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index d4a3948702..fb3cf204c3 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1242,11 +1242,11 @@ var ZoteroPane = new function() document.getElementById('zotero-items-tree').view = this.itemsView; - // Add events to treecolpicker to update menu before showing/hiding try { let treecols = document.getElementById('zotero-items-columns-header'); let treecolpicker = treecols.boxObject.firstChild.nextSibling; let menupopup = treecolpicker.boxObject.firstChild.nextSibling; + // Add events to treecolpicker to update menu before showing/hiding let attr = menupopup.getAttribute('onpopupshowing'); if (attr.indexOf('Zotero') == -1) { menupopup.setAttribute('onpopupshowing', 'ZoteroPane.itemsView.onColumnPickerShowing(event);') @@ -1256,6 +1256,28 @@ var ZoteroPane = new function() // Keep whatever else is there + ' ' + menupopup.getAttribute('onpopuphidden'); } + + // Hide certain columns for feeds + let elems = treecols.getElementsByAttribute('hidden-in', '*'); + for (let i = 0; i < elems.length; i++) { + let shouldHide = elems[i].getAttribute('hidden-in').split(' ') + .indexOf(collectionTreeRow.type) != -1; + let userHidden = elems[i].hasAttribute('user-hidden'); + // The slightly convoluted logic here is such: + // If the current tree being displayed is in the list of types 'hidden-in' + // specifies and it's not already been hidden by another 'hidden-in' rule + // (i.e. its normal state of being displayed has not been suppressed yet), + // then hide it + if (shouldHide && !userHidden) { + // Store old value on entry to feed view + elems[i].setAttribute('user-hidden', elems[i].getAttribute('hidden')); + elems[i].setAttribute('hidden', 'true'); + } else if (!shouldHide && userHidden) { + // Restore old value on exit from feed view + elems[i].setAttribute('hidden', elems[i].getAttribute('user-hidden')); + elems[i].removeAttribute('user-hidden'); + } + } } catch (e) { Zotero.debug(e); diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index b7c7aec9f0..66dac60758 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -444,14 +444,14 @@ flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>