-import {slideUp, slideDown} from "../services/animations";
-import {Component} from "./component";
+import {slideUp, slideDown} from '../services/animations.ts';
+import {Component} from './component';
export class ExpandToggle extends Component {
- setup(elem) {
+ setup() {
this.targetSelector = this.$opts.targetSelector;
this.isOpen = this.$opts.isOpen === 'true';
this.updateEndpoint = this.$opts.updateEndpoint;
event.preventDefault();
const matchingElems = document.querySelectorAll(this.targetSelector);
- for (let match of matchingElems) {
- this.isOpen ? this.close(match) : this.open(match);
+ for (const match of matchingElems) {
+ const action = this.isOpen ? this.close : this.open;
+ action(match);
}
this.isOpen = !this.isOpen;
updateSystemAjax(isOpen) {
window.$http.patch(this.updateEndpoint, {
- expand: isOpen ? 'true' : 'false'
+ expand: isOpen ? 'true' : 'false',
});
}
-}
\ No newline at end of file
+}