Sha256: bb3fd945775509ad5cf50bce4355bf41ad0a9b853bf120285d193809fd83b62f
Contents?: true
Size: 971 Bytes
Versions: 7
Compression:
Stored size: 971 Bytes
Contents
import { Turbo } from "@hotwired/turbo-rails"; import { Modal } from "./modal"; export class StreamModal extends Modal { constructor(id, action) { super(id); this.action = action; } async open() { await super.open(); window.history.pushState({ kpop: true, id: this.id }, "", window.location); } async dismiss() { await super.dismiss(); if (this.isCurrentLocation) { await this.pop("popstate", () => window.history.back()); } this.frameElement.innerHTML = ""; } beforeVisit(frame, e) { super.beforeVisit(frame, e); e.preventDefault(); frame.dismiss({ animate: false }).then(() => { Turbo.visit(e.detail.url); this.debug("before-visit-end"); }); } popstate(frame, e) { super.popstate(frame, e); frame.dismiss({ animate: true, reason: "popstate" }); } get isCurrentLocation() { return window.history.state?.kpop && window.history.state?.id === this.id; } }
Version data entries
7 entries across 7 versions & 1 rubygems