From b2ce3d4a5c54b6fe8e96634faf6f7354e39eef61 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:16:42 +0800 Subject: [PATCH] Fix sidenav button default status --- .../zotero/elements/itemPaneSidenav.js | 14 +++++++++ chrome/content/zotero/zoteroPane.js | 30 +++++++++++++++++-- chrome/content/zotero/zoteroPane.xhtml | 8 ++--- scss/elements/_itemPaneSidenav.scss | 19 +++--------- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/chrome/content/zotero/elements/itemPaneSidenav.js b/chrome/content/zotero/elements/itemPaneSidenav.js index bdf23495eb..95fb20e331 100644 --- a/chrome/content/zotero/elements/itemPaneSidenav.js +++ b/chrome/content/zotero/elements/itemPaneSidenav.js @@ -36,51 +36,61 @@ @@ -416,6 +426,10 @@ let pinnedPane = this.pinnedPane; for (let toolbarbutton of this.querySelectorAll('toolbarbutton')) { let pane = toolbarbutton.dataset.pane; + // TEMP: never disable context notes button + if (this._contextNotesPane) { + toolbarbutton.disabled = false; + } if (pane == 'context-notes') { let hidden = !this._contextNotesPane; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index ae219fbbbe..6a00b56d60 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1844,12 +1844,20 @@ var ZoteroPane = new function() if (!collectionTreeRow) { return false; } - + + let pane = document.getElementById('zotero-item-pane'); + let deck = document.getElementById('zotero-item-pane-content'); + let sidenav = document.getElementById('zotero-view-item-sidenav'); + + let hideSidenav = false; + // Single item selected if (selectedItems.length == 1) { var item = selectedItems[0]; + sidenav.querySelectorAll('toolbarbutton').forEach(button => button.disabled = false); if (item.isNote()) { + hideSidenav = true; ZoteroItemPane.onNoteSelected(item, this.collectionsView.editable); } @@ -1857,7 +1865,6 @@ var ZoteroPane = new function() else { var isCommons = collectionTreeRow.isBucket(); - let deck = document.getElementById('zotero-item-pane-content'); deck.selectedIndex = 1; let pane = ZoteroItemPane.getPinnedPane(); @@ -1890,6 +1897,13 @@ var ZoteroPane = new function() } // Zero or multiple items selected else { + let defaultSidenavButtons = [ + "info", "abstract", "attachments", "notes", "libraries-collections", "tags", "related" + ]; + sidenav.querySelectorAll('toolbarbutton').forEach((button) => { + button.disabled = true; + button.parentElement.hidden = !defaultSidenavButtons.includes(button.dataset.pane); + }); if (collectionTreeRow.isFeedsOrFeed()) { this.updateReadLabel(); } @@ -1908,7 +1922,7 @@ var ZoteroPane = new function() this.setItemPaneMessage(msg); } else if (count) { - document.getElementById('zotero-item-pane-content').selectedIndex = 3; + deck.selectedIndex = 3; // Load duplicates UI code if (typeof Zotero_Duplicates_Pane == 'undefined') { @@ -1957,6 +1971,16 @@ var ZoteroPane = new function() return false; } } + + const sidenavWidth = 37; + if (hideSidenav && !sidenav.hidden) { + sidenav.hidden = true; + pane.width = `${(pane.clientWidth) + sidenavWidth}`; + } + else if (!hideSidenav && sidenav.hidden) { + sidenav.hidden = false; + pane.width = `${pane.clientWidth - sidenavWidth}`; + } return true; }.bind(this))() diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index bb34d9d30a..503bf05386 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -1180,7 +1180,7 @@ - +