blob: 99fa87190ee519f7aeeaec27dc7cd0aabc7d0937 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/**
* Settings.
*/
import { $, $$ } from './utils/dom';
import store from './utils/store';
export function setupSettings() {
if (!$('#js-setting-table')) return;
const localCheckboxes = $$('[data-tab="local"] input[type="checkbox"]');
const themeSelect = $('#user_theme');
const styleSheet = $('head link[rel="stylesheet"]');
// Local settings
localCheckboxes.forEach(checkbox => {
checkbox.checked = Boolean(store.get(checkbox.id));
checkbox.addEventListener('change', () => {
store.set(checkbox.id, checkbox.checked);
});
});
// Theme preview
themeSelect && themeSelect.addEventListener('change', () => {
styleSheet.href = themeSelect.options[themeSelect.selectedIndex].dataset.themePath;
});
}
|