Move context pane toggle into reader toolbar

Related #3648
This commit is contained in:
Martynas Bagdonas 2024-02-01 14:48:31 +08:00
parent 3adc0ef814
commit 8a9df4a1b3
6 changed files with 26 additions and 23 deletions

View file

@ -46,6 +46,7 @@ var ZoteroContextPane = new function () {
this.update = _update; this.update = _update;
this.getActiveEditor = _getActiveEditor; this.getActiveEditor = _getActiveEditor;
this.focus = _focus; this.focus = _focus;
this.togglePane = _togglePane;
this.init = function () { this.init = function () {
if (!Zotero) { if (!Zotero) {
@ -335,7 +336,7 @@ var ZoteroContextPane = new function () {
_contextPane.classList.add('stacked'); _contextPane.classList.add('stacked');
_contextPane.classList.remove('standard'); _contextPane.classList.remove('standard');
_sidenav.classList.add('stacked'); _sidenav.classList.add('stacked');
_contextPaneInner.after(_sidenav); _contextPaneInner.append(_sidenav);
} }
else { else {
_contextPaneSplitter.setAttribute('hidden', false); _contextPaneSplitter.setAttribute('hidden', false);
@ -344,14 +345,16 @@ var ZoteroContextPane = new function () {
_contextPane.classList.add('standard'); _contextPane.classList.add('standard');
_contextPane.classList.remove('stacked'); _contextPane.classList.remove('stacked');
_sidenav.classList.remove('stacked'); _sidenav.classList.remove('stacked');
_contextPane.after(_sidenav); _contextPane.append(_sidenav);
} }
if (Zotero_Tabs.selectedIndex > 0) { if (Zotero_Tabs.selectedIndex > 0) {
var height = 0; var height = null;
if (Zotero.Prefs.get('layout') == 'stacked' if (Zotero.Prefs.get('layout') == 'stacked') {
&& _contextPane.getAttribute('collapsed') != 'true') { height = 0;
height = _contextPaneInner.getBoundingClientRect().height; if (_contextPane.getAttribute('collapsed') != 'true') {
height = _contextPaneInner.getBoundingClientRect().height;
}
} }
Zotero.Reader.setBottomPlaceholderHeight(height); Zotero.Reader.setBottomPlaceholderHeight(height);
} }
@ -361,24 +364,19 @@ var ZoteroContextPane = new function () {
_sidenav.showPendingPane(); _sidenav.showPendingPane();
} }
function _togglePane(paneIndex) { function _togglePane() {
var splitter = Zotero.Prefs.get('layout') == 'stacked' var splitter = Zotero.Prefs.get('layout') == 'stacked'
? _contextPaneSplitterStacked : _contextPaneSplitter; ? _contextPaneSplitterStacked : _contextPaneSplitter;
var isOpen = splitter.getAttribute('state') != 'collapsed'; var open = true;
var hide = false; if (splitter.getAttribute('state') != 'collapsed') {
var currentPane = _panesDeck.selectedIndex; open = false;
if (isOpen && currentPane == paneIndex) {
hide = true;
}
else {
_panesDeck.setAttribute('selectedIndex', paneIndex);
} }
splitter.setAttribute('state', hide ? 'collapsed' : 'open'); splitter.setAttribute('state', open ? 'open' : 'collapsed');
_update(); _update();
if (!hide) { if (open) {
ZoteroContextPane.focus(); ZoteroContextPane.focus();
} }
} }

View file

@ -189,8 +189,7 @@
} }
get _showCollapseButton() { get _showCollapseButton() {
// Only show in reader return false;
return !!this._contextNotesPane;
} }
get _collapsed() { get _collapsed() {

View file

@ -497,6 +497,12 @@ class ReaderInstance {
await this.reload(); await this.reload();
this._internalReader.unfreeze(); this._internalReader.unfreeze();
} }
},
onToggleContextPane: () => {
Zotero.debug('toggle context pane')
let win = Zotero.getMainWindow();
win.ZoteroContextPane.togglePane();
} }
}, this._iframeWindow, { cloneFunctions: true })); }, this._iframeWindow, { cloneFunctions: true }));

View file

@ -1325,11 +1325,10 @@
> >
<grippy/> <grippy/>
</splitter> </splitter>
<hbox id="zotero-context-pane-inner" flex="1" zotero-persist="height"/> <vbox id="zotero-context-pane-inner" flex="1" zotero-persist="height"/>
</vbox> </vbox>
<item-pane-sidenav id="zotero-context-pane-sidenav" class="zotero-view-item-sidenav" hidden="true"/>
</box> </box>
<item-pane-sidenav id="zotero-context-pane-sidenav" class="zotero-view-item-sidenav" hidden="true"/>
<popupset> <popupset>
<menupopup id="context-pane-add-child-note-button-popup"> <menupopup id="context-pane-add-child-note-button-popup">

View file

@ -110,4 +110,5 @@ $tagColorsLookup: (
$min-width-collections-pane: 200px; $min-width-collections-pane: 200px;
$min-width-items-pane: 370px; $min-width-items-pane: 370px;
$min-width-item-pane: 300px; $min-width-item-pane: 300px;
$min-width-context-pane: 340px;
$width-sidenav: 37px; $width-sidenav: 37px;

View file

@ -4,7 +4,7 @@
#zotero-context-pane { #zotero-context-pane {
display: flex; display: flex;
min-width: $min-width-item-pane; min-width: $min-width-context-pane;
.divider { .divider {
border-bottom: 1px solid var(--fill-quinary); border-bottom: 1px solid var(--fill-quinary);