mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-17 05:42:06 +00:00
Upgraded app to Laravel 5.7
This commit is contained in:
parent
213e9d2941
commit
6917ea088f
179 changed files with 829 additions and 115 deletions
resources/js/components
34
resources/js/components/custom-checkbox.js
Normal file
34
resources/js/components/custom-checkbox.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
class CustomCheckbox {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.checkbox = elem.querySelector('input[type=checkbox]');
|
||||
this.display = elem.querySelector('[role="checkbox"]');
|
||||
|
||||
this.checkbox.addEventListener('change', this.stateChange.bind(this));
|
||||
this.elem.addEventListener('keydown', this.onKeyDown.bind(this));
|
||||
}
|
||||
|
||||
onKeyDown(event) {
|
||||
const isEnterOrPress = event.keyCode === 32 || event.keyCode === 13;
|
||||
if (isEnterOrPress) {
|
||||
event.preventDefault();
|
||||
this.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.checkbox.checked = !this.checkbox.checked;
|
||||
this.checkbox.dispatchEvent(new Event('change'));
|
||||
this.stateChange();
|
||||
}
|
||||
|
||||
stateChange() {
|
||||
const checked = this.checkbox.checked ? 'true' : 'false';
|
||||
this.display.setAttribute('aria-checked', checked);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CustomCheckbox;
|
Loading…
Add table
Add a link
Reference in a new issue