Sha256: b4fb3f36cadc85be88e3d57b2d854637a5d30aae7aef3b1d4493d37ba75673fe
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
import { Turbo } from "@hotwired/turbo-rails"; import DEBUG from "../debug"; export class Modal { constructor(id) { this.id = id; } async open() { this.debug("open"); } async dismiss() { this.debug(`dismiss`); } beforeVisit(frame, e) { this.debug(`before-visit`, e.detail.url); } popstate(frame, e) { this.debug(`popstate`, e.state); } async pop(event, callback) { this.debug(`pop`); const promise = new Promise((resolve) => { window.addEventListener( event, () => { resolve(); }, { once: true } ); }); callback(); return promise; } get frameElement() { return document.getElementById(this.id); } get controller() { return this.frameElement?.kpop; } get modalElement() { return this.frameElement?.querySelector("[data-controller*='kpop--modal']"); } get currentLocationValue() { return this.modalElement?.dataset["kpop-ModalCurrentLocationValue"] || "/"; } get fallbackLocationValue() { return this.modalElement?.dataset["kpop-ModalFallbackLocationValue"]; } get isCurrentLocation() { return ( window.history.state?.turbo && Turbo.session.location.href === this.src ); } static debug(event, ...args) { if (DEBUG) console.debug(`${this.name}:${event}`, ...args); } debug(event, ...args) { if (DEBUG) console.debug(`${this.constructor.name}:${event}`, ...args); } }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
katalyst-kpop-3.0.1 | app/javascript/kpop/modals/modal.js |
katalyst-kpop-3.0.0 | app/javascript/kpop/modals/modal.js |
katalyst-kpop-3.0.0.beta.8 | app/javascript/kpop/modals/modal.js |