mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
a9f983f156
Closes #1476
18 lines
420 B
JavaScript
18 lines
420 B
JavaScript
|
|
class ToggleSwitch {
|
|
|
|
constructor(elem) {
|
|
this.elem = elem;
|
|
this.input = elem.querySelector('input[type=hidden]');
|
|
this.checkbox = elem.querySelector('input[type=checkbox]');
|
|
|
|
this.checkbox.addEventListener('change', this.stateChange.bind(this));
|
|
}
|
|
|
|
stateChange() {
|
|
this.input.value = (this.checkbox.checked ? 'true' : 'false');
|
|
}
|
|
|
|
}
|
|
|
|
export default ToggleSwitch; |