Sha256: e0be7902251295ce76753b8666e758f3595de66f81e7d35a8c0bcb8b53e85640

Contents?: true

Size: 764 Bytes

Versions: 7

Compression:

Stored size: 764 Bytes

Contents

import { CocoComponent } from "@assets/js/shared/coco";

export default CocoComponent("modalDialog", () => {
  return {
    frame: null,

    init() {
      this.onFrameLoad = this.onFrameLoad.bind(this);
      this.frame = this.$el.closest("turbo-frame");

      if (this.frame) {
        this.frame.addEventListener("turbo:frame-load", this.onFrameLoad);
      }
    },

    close() {
      this.modal.hide();
    },

    onFrameLoad() {
      this.$focus.focus(this.firstInput);
    },

    destroy() {
      if (this.frame) {
        this.frame.removeEventListener("turbo:frame-load", this.onFrameLoad);
      }
    },

    get firstInput() {
      return this.$root.querySelector(
        "input:not([type=hidden]), textarea, select"
      );
    },
  };
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.12.1 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.12.0 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.11.0 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.10.1.beta.2 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.10.1.beta.1 app/components/coco/shared/modal_dialog/modal_dialog.js
coveragebook_components-0.10.1.beta.0 app/components/coco/shared/modal_dialog/modal_dialog.js