Sha256: fb0625fbd4d57f34f67a4a4355a47b7d8bd9f49f3c6f3475d2129315bdf8a9f8
Contents?: true
Size: 1.29 KB
Versions: 7
Compression:
Stored size: 1.29 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 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 ); } debug(event, ...args) { if (DEBUG) console.debug(`${this.constructor.name}:${event}`, ...args); } }
Version data entries
7 entries across 7 versions & 1 rubygems