X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/9135a85de4eef32a91c7a3ee0aa405ed454e5a4c..refs/pull/5429/head:/resources/js/components/expand-toggle.js diff --git a/resources/js/components/expand-toggle.js b/resources/js/components/expand-toggle.js index ab4d38ab1..29173a058 100644 --- a/resources/js/components/expand-toggle.js +++ b/resources/js/components/expand-toggle.js @@ -1,9 +1,9 @@ -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; @@ -24,8 +24,9 @@ export class ExpandToggle extends Component { 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; @@ -34,8 +35,8 @@ export class ExpandToggle extends Component { updateSystemAjax(isOpen) { window.$http.patch(this.updateEndpoint, { - expand: isOpen ? 'true' : 'false' + expand: isOpen ? 'true' : 'false', }); } -} \ No newline at end of file +}