left sidebar can now be also collapsible

This commit is contained in:
zadam
2020-02-04 20:42:40 +01:00
parent c5475765e5
commit 0cc013c13f
9 changed files with 82 additions and 67 deletions

View File

@@ -145,38 +145,33 @@ if (utils.isElectron()) {
import("./services/spell_check.js").then(spellCheckService => spellCheckService.initSpellCheck());
}
const rightPane = $("#right-pane");
optionService.waitForOptions().then(options => {
toggleSidebar('left', options.is('leftPaneVisible'));
toggleSidebar('right', options.is('rightPaneVisible'));
const $showRightPaneButton = $("#show-right-pane-button");
const $hideRightPaneButton = $("#hide-right-pane-button");
optionService.waitForOptions().then(options => toggleSidebar(options.is('rightPaneVisible')));
function toggleSidebar(show) {
rightPane.toggle(show);
$showRightPaneButton.toggle(!show);
$hideRightPaneButton.toggle(show);
if (show) {
splitService.setupSplitWithSidebar();
}
else {
splitService.setupSplitWithoutSidebar();
}
}
$hideRightPaneButton.on('click', () => {
toggleSidebar(false);
server.put('options/rightPaneVisible/false');
splitService.setupSplit(paneVisible.left, paneVisible.right);
});
$showRightPaneButton.on('click', async () => {
toggleSidebar(true);
const paneVisible = {};
await server.put('options/rightPaneVisible/true');
function toggleSidebar(side, show) {
$(`#${side}-pane`).toggle(show);
$(`#show-${side}-pane-button`).toggle(!show);
$(`#hide-${side}-pane-button`).toggle(show);
const {sidebar} = appContext.getActiveTabContext();
await sidebar.noteLoaded();
sidebar.show();
});
paneVisible[side] = show;
}
function toggleAndSave(side, show) {
toggleSidebar(side, show);
splitService.setupSplit(paneVisible.left, paneVisible.right);
server.put(`options/${side}PaneVisible/` + show.toString());
}
$("#show-right-pane-button").on('click', () => toggleAndSave('right', true));
$("#hide-right-pane-button").on('click', () => toggleAndSave('right', false));
$("#show-left-pane-button").on('click', () => toggleAndSave('left', true));
$("#hide-left-pane-button").on('click', () => toggleAndSave('left', false));