]> BookStack Code Mirror - bookstack/blob - resources/assets/js/components/toggle-switch.js
Update maintenance.php
[bookstack] / resources / assets / js / components / toggle-switch.js
1
2 class ToggleSwitch {
3
4     constructor(elem) {
5         this.elem = elem;
6         this.input = elem.querySelector('input[type=hidden]');
7         this.checkbox = elem.querySelector('input[type=checkbox]');
8
9         this.checkbox.addEventListener('change', this.onClick.bind(this));
10     }
11
12     onClick(event) {
13         let checked = this.checkbox.checked;
14         this.input.value = checked ? 'true' : 'false';
15     }
16
17 }
18
19 export default ToggleSwitch;