Fix sidenav button default status

This commit is contained in:
windingwind 2024-01-15 17:16:42 +08:00 committed by Dan Stillman
parent 365e97ba1e
commit b2ce3d4a5c
4 changed files with 49 additions and 22 deletions

View file

@ -36,51 +36,61 @@
<html:div class="inherit-flex highlight-notes-inactive"> <html:div class="inherit-flex highlight-notes-inactive">
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-info" data-l10n-id="sidenav-info"
data-pane="info"/> data-pane="info"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-abstract" data-l10n-id="sidenav-abstract"
data-pane="abstract"/> data-pane="abstract"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-attachment-preview" data-l10n-id="sidenav-attachment-preview"
data-pane="attachment-preview"/> data-pane="attachment-preview"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-attachments" data-l10n-id="sidenav-attachments"
data-pane="attachments"/> data-pane="attachments"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-notes" data-l10n-id="sidenav-notes"
data-pane="notes"/> data-pane="notes"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-attachment-info" data-l10n-id="sidenav-attachment-info"
data-pane="attachment-info"/> data-pane="attachment-info"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-attachment-annotations" data-l10n-id="sidenav-attachment-annotations"
data-pane="attachment-annotations"/> data-pane="attachment-annotations"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-libraries-collections" data-l10n-id="sidenav-libraries-collections"
data-pane="libraries-collections"/> data-pane="libraries-collections"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-tags" data-l10n-id="sidenav-tags"
data-pane="tags"/> data-pane="tags"/>
</html:div> </html:div>
<html:div class="pin-wrapper"> <html:div class="pin-wrapper">
<toolbarbutton <toolbarbutton
disabled="true"
data-l10n-id="sidenav-related" data-l10n-id="sidenav-related"
data-pane="related"/> data-pane="related"/>
</html:div> </html:div>
@ -416,6 +426,10 @@
let pinnedPane = this.pinnedPane; let pinnedPane = this.pinnedPane;
for (let toolbarbutton of this.querySelectorAll('toolbarbutton')) { for (let toolbarbutton of this.querySelectorAll('toolbarbutton')) {
let pane = toolbarbutton.dataset.pane; let pane = toolbarbutton.dataset.pane;
// TEMP: never disable context notes button
if (this._contextNotesPane) {
toolbarbutton.disabled = false;
}
if (pane == 'context-notes') { if (pane == 'context-notes') {
let hidden = !this._contextNotesPane; let hidden = !this._contextNotesPane;

View file

@ -1845,11 +1845,19 @@ var ZoteroPane = new function()
return false; 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 // Single item selected
if (selectedItems.length == 1) { if (selectedItems.length == 1) {
var item = selectedItems[0]; var item = selectedItems[0];
sidenav.querySelectorAll('toolbarbutton').forEach(button => button.disabled = false);
if (item.isNote()) { if (item.isNote()) {
hideSidenav = true;
ZoteroItemPane.onNoteSelected(item, this.collectionsView.editable); ZoteroItemPane.onNoteSelected(item, this.collectionsView.editable);
} }
@ -1857,7 +1865,6 @@ var ZoteroPane = new function()
else { else {
var isCommons = collectionTreeRow.isBucket(); var isCommons = collectionTreeRow.isBucket();
let deck = document.getElementById('zotero-item-pane-content');
deck.selectedIndex = 1; deck.selectedIndex = 1;
let pane = ZoteroItemPane.getPinnedPane(); let pane = ZoteroItemPane.getPinnedPane();
@ -1890,6 +1897,13 @@ var ZoteroPane = new function()
} }
// Zero or multiple items selected // Zero or multiple items selected
else { 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()) { if (collectionTreeRow.isFeedsOrFeed()) {
this.updateReadLabel(); this.updateReadLabel();
} }
@ -1908,7 +1922,7 @@ var ZoteroPane = new function()
this.setItemPaneMessage(msg); this.setItemPaneMessage(msg);
} }
else if (count) { else if (count) {
document.getElementById('zotero-item-pane-content').selectedIndex = 3; deck.selectedIndex = 3;
// Load duplicates UI code // Load duplicates UI code
if (typeof Zotero_Duplicates_Pane == 'undefined') { if (typeof Zotero_Duplicates_Pane == 'undefined') {
@ -1958,6 +1972,16 @@ var ZoteroPane = new function()
} }
} }
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; return true;
}.bind(this))() }.bind(this))()
.catch(function (e) { .catch(function (e) {

View file

@ -1180,7 +1180,7 @@
</splitter> </splitter>
<!-- itemPane.xul --> <!-- itemPane.xul -->
<vbox id="zotero-item-pane" flex="1" zotero-persist="width height" height="300"> <vbox id="zotero-item-pane" flex="0" zotero-persist="width height" height="300">
<!-- My Publications --> <!-- My Publications -->
<hbox id="zotero-item-pane-top-buttons-my-publications" class="zotero-item-pane-top-buttons" hidden="true"> <hbox id="zotero-item-pane-top-buttons-my-publications" class="zotero-item-pane-top-buttons" hidden="true">
<button id="zotero-item-collection-show-hide"/> <button id="zotero-item-collection-show-hide"/>
@ -1228,15 +1228,15 @@
<abstract-box id="zotero-editpane-abstract" class="zotero-editpane-abstract" data-pane="abstract"/> <abstract-box id="zotero-editpane-abstract" class="zotero-editpane-abstract" data-pane="abstract"/>
<attachment-preview-box id="zotero-editpane-attachment-preview" flex="1" data-pane="attachment-preview"/> <attachment-preview-box id="zotero-editpane-attachment-preview" flex="1" data-pane="attachment-preview" hidden="true"/>
<attachments-box id="zotero-editpane-attachments" data-pane="attachments"/> <attachments-box id="zotero-editpane-attachments" data-pane="attachments"/>
<notes-box id="zotero-editpane-notes" class="zotero-editpane-notes" data-pane="notes"/> <notes-box id="zotero-editpane-notes" class="zotero-editpane-notes" data-pane="notes"/>
<attachment-box id="zotero-attachment-box" flex="1" data-pane="attachment-info" data-use-preview="true"/> <attachment-box id="zotero-attachment-box" flex="1" data-pane="attachment-info" data-use-preview="true" hidden="true"/>
<attachment-annotations-box id="zotero-editpane-attachment-annotations" flex="1" data-pane="attachment-annotations"/> <attachment-annotations-box id="zotero-editpane-attachment-annotations" flex="1" data-pane="attachment-annotations" hidden="true"/>
<libraries-collections-box id="zotero-editpane-libraries-collections" class="zotero-editpane-libraries-collections" data-pane="libraries-collections"/> <libraries-collections-box id="zotero-editpane-libraries-collections" class="zotero-editpane-libraries-collections" data-pane="libraries-collections"/>

View file

@ -68,23 +68,12 @@ item-pane-sidenav {
height: 28px; height: 28px;
margin: 0; margin: 0;
padding: 4px; padding: 4px;
flex-shrink: 0;
border-radius: 5px;
-moz-context-properties: fill, fill-opacity, stroke, stroke-opacity;
pointer-events: all; pointer-events: all;
&:hover { &:disabled,
background-color: var(--fill-quinary); &[disabled="true"] {
} opacity: 60%;
pointer-events: none;
&:active {
background-color: var(--fill-quarternary);
}
&:disabled {
background-color: transparent;
fill: var(--fill-tertiary);
} }
@each $pane, $color in $item-pane-sections { @each $pane, $color in $item-pane-sections {