mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-19 22:51:30 +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
33
resources/js/components/chapter-toggle.js
Normal file
33
resources/js/components/chapter-toggle.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import {slideUp, slideDown} from "../services/animations";
|
||||
|
||||
class ChapterToggle {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.isOpen = elem.classList.contains('open');
|
||||
elem.addEventListener('click', this.click.bind(this));
|
||||
}
|
||||
|
||||
open() {
|
||||
const list = this.elem.parentNode.querySelector('.inset-list');
|
||||
this.elem.classList.add('open');
|
||||
this.elem.setAttribute('aria-expanded', 'true');
|
||||
slideDown(list, 240);
|
||||
}
|
||||
|
||||
close() {
|
||||
const list = this.elem.parentNode.querySelector('.inset-list');
|
||||
this.elem.classList.remove('open');
|
||||
this.elem.setAttribute('aria-expanded', 'false');
|
||||
slideUp(list, 240);
|
||||
}
|
||||
|
||||
click(event) {
|
||||
event.preventDefault();
|
||||
this.isOpen ? this.close() : this.open();
|
||||
this.isOpen = !this.isOpen;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ChapterToggle;
|
Loading…
Add table
Add a link
Reference in a new issue