')
.attr("title", "If checked, the widget will be by default expanded (opened)")
.append($('
')
.attr('id', 'widget-exp-' + widgetName))
.append(" ")
.append($("
")
.attr("for", 'widget-exp-' + widgetName)
.text(" expanded"));
const $el = $('')
.addClass("list-group-item")
.append($widgetTitle)
.append($expandedCheckbox);
this.$widgetsActive.append($el);
}
libraryLoader.requireLibrary(libraryLoader.SORTABLE).then(() => {
new Sortable(this.$widgetsActive[0], {
group: 'widgets',
handle: '.handle',
animation: 150
});
new Sortable(this.$widgetsInactive[0], {
group: 'widgets',
handle: '.handle',
animation: 150
});
});
this.$sidebarMinWidth.change(async () => {
await server.put('options/sidebarMinWidth/' + this.$sidebarMinWidth.val());
this.resizeSidebar();
});
this.$sidebarWidthPercent.change(async () => {
await server.put('options/sidebarWidthPercent/' + this.$sidebarWidthPercent.val());
this.resizeSidebar();
});
this.$showSidebarInNewTab.change(async () => {
const flag = this.$showSidebarInNewTab.is(":checked") ? 1 : 0;
await server.put('options/showSidebarInNewTab/' + flag);
optionsInit.loadOptions();
});
}
async optionsLoaded(options) {
this.$sidebarMinWidth.val(options.sidebarMinWidth);
this.$sidebarWidthPercent.val(options.sidebarWidthPercent);
if (parseInt(options.showSidebarInNewTab)) {
this.$showSidebarInNewTab.attr("checked", "checked");
}
else {
this.$showSidebarInNewTab.removeAttr("checked");
}
}
resizeSidebar() {
const sidebarWidthPercent = parseInt(this.$sidebarWidthPercent.val());
const sidebarMinWidth = this.$sidebarMinWidth.val();
// need to find them dynamically since they change
const $sidebar = $(".note-detail-sidebar");
$sidebar.css("width", sidebarWidthPercent + '%');
$sidebar.css("min-width", sidebarMinWidth + 'px');
}
}