Sha256: c671f2e8ff8fb15261755e8aa57394d85d2aaa351ab36203a76f3f409bfa897f

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 Bytes

Contents

import { Turbo } from "@hotwired/turbo-rails";

import { Modal } from "./modal";

export class ContentModal extends Modal {
  constructor(id, src = null) {
    super(id);

    if (src) this.src = src;
  }

  async dismiss() {
    await super.dismiss();

    if (this.visitStarted) {
      this.debug("skipping dismiss, visit started");
      return;
    }
    if (!this.isCurrentLocation) {
      this.debug("skipping dismiss, not current location");
      return;
    }

    return this.pop("turbo:load", () => {
      this.debug("turbo-visit", this.fallbackLocationValue);
      Turbo.visit(this.fallbackLocationValue);
    });

    // no specific close action required, this is turbo's responsibility
  }

  beforeVisit(frame, e) {
    super.beforeVisit(frame, e);

    this.visitStarted = true;

    frame.scrimOutlet.hide({ animate: false });
  }

  get src() {
    return new URL(
      this.currentLocationValue.toString(),
      document.baseURI
    ).toString();
  }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
katalyst-kpop-3.0.0.beta.7 app/javascript/kpop/modals/content_modal.js
katalyst-kpop-3.0.0.beta.6 app/javascript/kpop/modals/content_modal.js
katalyst-kpop-3.0.0.beta.5 app/javascript/kpop/modals/content_modal.js
katalyst-kpop-3.0.0.beta.4 app/javascript/kpop/modals/content_modal.js
katalyst-kpop-3.0.0.beta.3 app/javascript/kpop/modals/content_modal.js