import options from "../services/options.js"; import splitService from "../services/split.js"; import BasicWidget from "./basic_widget.js"; const TPL = `
`; export default class SidePaneToggles extends BasicWidget { constructor(appContext) { super(appContext); this.paneVisible = {}; } doRender() { this.$widget = $(TPL); this.toggleSidebar('left', options.is('leftPaneVisible')); this.toggleSidebar('right', options.is('rightPaneVisible')); this.$widget.find(".show-right-pane-button").on('click', () => this.toggleAndSave('right', true)); this.$widget.find(".hide-right-pane-button").on('click', () => this.toggleAndSave('right', false)); this.$widget.find(".show-left-pane-button").on('click', () => this.toggleAndSave('left', true)); this.$widget.find(".hide-left-pane-button").on('click', () => this.toggleAndSave('left', false)); return this.$widget; } toggleSidebar(side, show) { $(`#${side}-pane`).toggle(show); this.$widget.find(`.show-${side}-pane-button`).toggle(!show); this.$widget.find(`.hide-${side}-pane-button`).toggle(show); this.paneVisible[side] = show; } async toggleAndSave(side, show) { this.toggleSidebar(side, show); await options.save(`${side}PaneVisible`, show.toString()); splitService.setupSplit(this.paneVisible.left, this.paneVisible.right); this.trigger('sidebarVisibilityChanged', {side, show}); } initialRenderCompleteListener() { splitService.setupSplit(this.paneVisible.left, this.paneVisible.right); } }