mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
b27a5c7fb8
- Changed default focus styles - Updated dropdowns with keyboard navigation - Updated modals with esc exiting - Added accessibility attirbutes where needed - Made many more elements focusable - Updated hover effects of many items to also apply when focused within Related to #1320 and #1198
34 lines
879 B
JavaScript
34 lines
879 B
JavaScript
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;
|