2018-03-18 15:13:46 +00:00
|
|
|
|
|
|
|
class ToggleSwitch {
|
|
|
|
|
|
|
|
constructor(elem) {
|
|
|
|
this.elem = elem;
|
2019-02-02 15:49:57 +00:00
|
|
|
this.input = elem.querySelector('input[type=hidden]');
|
|
|
|
this.checkbox = elem.querySelector('input[type=checkbox]');
|
2018-03-18 15:13:46 +00:00
|
|
|
|
2019-02-02 15:49:57 +00:00
|
|
|
this.checkbox.addEventListener('change', this.onClick.bind(this));
|
2018-03-18 15:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onClick(event) {
|
2019-02-02 15:49:57 +00:00
|
|
|
let checked = this.checkbox.checked;
|
2018-03-18 15:13:46 +00:00
|
|
|
this.input.value = checked ? 'true' : 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:17:35 +00:00
|
|
|
export default ToggleSwitch;
|