0
0
Fork 0
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:
Dan Brown 2019-09-06 23:36:16 +01:00
parent 213e9d2941
commit 6917ea088f
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
179 changed files with 829 additions and 115 deletions
resources/js/components

View 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;