Sha256: 50b0d8740e3975264c46aa8acc82dbf8722618aee4482a1d10c666f1ddbcc780
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
import ApplicationController from "../../../../frontend/controllers/application_controller" // FIXME: Is this full path really needed? import { debounce } from "../../../../frontend/utils" import { createPopper } from "@popperjs/core" export default class extends ApplicationController { static targets = ["submenu", "toggle"] connect() { super.connect() if (this.hasSubmenuTarget) { this.popperInstance = createPopper(this.element, this.submenuTarget, { offset: [-20, 2], placement: this.submenuTarget.getAttribute("data-satis-menu-submenu-placement") || "auto", modifiers: [ { name: "flip", enabled: true, options: { boundary: this.element.closest(".satis-card"), }, }, { name: "preventOverflow", }, ], }) } } show(event) { if (this.hasSubmenuTarget && (!this.hasToggleTarget || (this.hasToggleTarget && this.toggledOn))) { this.submenuTarget.classList.remove("hidden") this.submenuTarget.setAttribute("data-show", "") this.popperInstance.update() } } hide(event) { if (this.hasSubmenuTarget) { this.submenuTarget.classList.add("hidden") this.submenuTarget.removeAttribute("data-show") } } toggle(event) { if (this.hasToggleTarget) { this.toggleTarget.classList.toggle("hidden") this.triggerEvent(this.toggleTarget, "toggle", { toggled: !this.toggleTarget.classList.contains("hidden"), id: this.toggleTarget.getAttribute("id") }) if (this.toggleTarget.classList.contains("hidden")) { this.hide(event) } else { this.show(event) } } } get toggledOn() { return !this.toggleTarget.classList.contains("hidden") } }
Version data entries
5 entries across 5 versions & 1 rubygems