import libraryLoader from "../../services/library_loader.js"; import server from "../../services/server.js"; import optionsService from "../../services/options.js"; const TPL = `

Show sidebar in new tab


Sidebar sizing

px
%

Sidebar width is calculated from the percent of the detail pane, if this is smaller than minimum width, then minimum width is used. If you want to have fixed width sidebar, set minimum width to the desired width and set percent to 0.

Widgets

Enabled widgets
Disabled widgets
`; export default class SidebarOptions { constructor() { $("#options-sidebar").html(TPL); this.$sidebarMinWidth = $("#sidebar-min-width"); this.$sidebarWidthPercent = $("#sidebar-width-percent"); this.$showSidebarInNewTab = $("#show-sidebar-in-new-tab"); this.$widgetsConfiguration = $("#widgets-configuration"); this.$widgetsEnabled = $("#widgets-enabled"); this.$widgetsDisabled = $("#widgets-disabled"); this.$sidebarMinWidth.on('change', async () => { await server.put('options/sidebarMinWidth/' + this.$sidebarMinWidth.val()); this.resizeSidebar(); }); this.$sidebarWidthPercent.on('change', async () => { await server.put('options/sidebarWidthPercent/' + this.$sidebarWidthPercent.val()); this.resizeSidebar(); }); this.$showSidebarInNewTab.on('change', async () => { const flag = this.$showSidebarInNewTab.is(":checked") ? 'true' : 'false'; await server.put('options/showSidebarInNewTab/' + flag); optionsService.reloadOptions(); }); } async optionsLoaded(options) { this.$widgetsEnabled.empty(); this.$widgetsDisabled.empty(); this.$sidebarMinWidth.val(options.sidebarMinWidth); this.$sidebarWidthPercent.val(options.sidebarWidthPercent); if (options.showSidebarInNewTab === 'true') { this.$showSidebarInNewTab.attr("checked", "checked"); } else { this.$showSidebarInNewTab.removeAttr("checked"); } const widgets = [ {name: 'attributes', title: 'Attributes'}, {name: 'linkMap', title: 'Link map'}, {name: 'noteInfo', title: 'Note info'}, {name: 'noteRevisions', title: 'Note revisions'}, {name: 'whatLinksHere', title: 'What links here'}, {name: 'similarNotes', title: 'Similar notes'}, {name: 'editedNotes', title: 'Edited notes (only on day note)'}, {name: 'calendar', title: 'Calendar (only on day note)'} ].map(widget => { widget.option = this.parseJsonSafely(options[widget.name + 'Widget']) || { enabled: true, expanded: true, position: 1000 }; return widget; }); widgets.sort((a, b) => a.option.position - b.option.position); for (const {name, title, option} of widgets) { const $widgetTitle = $('
') .attr('data-widget-name', name) .append($("").addClass("handle bx bx-move")) .append($("").text(title)); const $expandedCheckbox = $('
') .attr("title", "If checked, the widget will be by default expanded (opened)") .append($(``) .attr('id', 'widget-exp-' + name) .on('change', () => this.save())) .append(" ") .append($("