mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
cf5d51e7b8
- Set proper semantic tags for main parts of content. - Removed focus-trap from tag manager/autosuggest. - Set better accessibility labelling on tag manager. - Updated collapsible sections to be keyboard navigatable. - Improved input focus styling to better fit theme. - Updated custom styled file picker to be accessible via keyboard. Related to #1320
41 lines
970 B
JavaScript
41 lines
970 B
JavaScript
import {slideDown, slideUp} from "../services/animations";
|
|
|
|
/**
|
|
* Collapsible
|
|
* Provides some simple logic to allow collapsible sections.
|
|
*/
|
|
class Collapsible {
|
|
|
|
constructor(elem) {
|
|
this.elem = elem;
|
|
this.trigger = elem.querySelector('[collapsible-trigger]');
|
|
this.content = elem.querySelector('[collapsible-content]');
|
|
|
|
if (!this.trigger) return;
|
|
|
|
this.trigger.addEventListener('click', this.toggle.bind(this));
|
|
}
|
|
|
|
open() {
|
|
this.elem.classList.add('open');
|
|
this.trigger.setAttribute('aria-expanded', 'true');
|
|
slideDown(this.content, 300);
|
|
}
|
|
|
|
close() {
|
|
this.elem.classList.remove('open');
|
|
this.trigger.setAttribute('aria-expanded', 'false');
|
|
slideUp(this.content, 300);
|
|
}
|
|
|
|
toggle() {
|
|
if (this.elem.classList.contains('open')) {
|
|
this.close();
|
|
} else {
|
|
this.open();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default Collapsible; |