2021-03-15 15:46:59 -04:00
|
|
|
// Hook for custom liveview bootstrap collapse handling
|
|
|
|
import Collapse from "bootstrap/js/dist/collapse";
|
|
|
|
|
|
|
|
export const BsCollapse = {
|
|
|
|
mounted() {
|
|
|
|
// when the liveview mounts, create the BS collapse object
|
|
|
|
const collapse = new Collapse(this.el, { toggle: false });
|
|
|
|
|
|
|
|
this.handleEvent("toggle-template-details", ({ targetId }) => {
|
|
|
|
if (this.el.id == targetId) {
|
|
|
|
collapse.toggle();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-03-16 11:03:44 -04:00
|
|
|
// when showing completes, send event to liveview
|
2021-03-15 15:46:59 -04:00
|
|
|
this.el.addEventListener("shown.bs.collapse", (event) => {
|
|
|
|
this.pushEvent("collapse-shown", { target_id: event.target.id });
|
|
|
|
});
|
|
|
|
|
2021-03-16 11:03:44 -04:00
|
|
|
// when hiding completes, send event to liveview
|
2021-03-15 15:46:59 -04:00
|
|
|
this.el.addEventListener("hidden.bs.collapse", (event) => {
|
|
|
|
this.pushEvent("collapse-hidden", { target_id: event.target.id });
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|