')
.attr("title", "If checked, the widget will be by default expanded (opened)")
.append($(`
`)
.attr('id', 'widget-exp-' + name)
.on('change', () => this.save()))
.append(" ")
.append($("
")
.attr("for", 'widget-exp-' + name)
.text(" expanded"));
const $el = $('')
.addClass("list-group-item")
.append($widgetTitle)
.append($expandedCheckbox);
(option.enabled ? this.$widgetsEnabled : this.$widgetsDisabled).append($el);
}
await libraryLoader.requireLibrary(libraryLoader.SORTABLE);
new Sortable(this.$widgetsEnabled[0], {
group: 'widgets',
handle: '.handle',
animation: 150,
onSort: evt => this.save()
});
new Sortable(this.$widgetsDisabled[0], {
group: 'widgets',
handle: '.handle',
animation: 150,
onSort: evt => this.save()
});
}
async save() {
const opts = {};
this.$widgetsConfiguration.find('.list-group-item').each((i, el) => {
const widgetName = $(el).find('div[data-widget-name]').attr('data-widget-name');
opts[widgetName + 'Widget'] = JSON.stringify({
enabled: $.contains(this.$widgetsEnabled[0], el),
expanded: $(el).find("input[type=checkbox]").is(":checked"),
position: (i + 1) * 100
});
});
await server.put('options', opts);
optionsService.reloadOptions();
}
parseJsonSafely(str) {
try {
return JSON.parse(str);
}
catch (e) {
return null;
}
}
}