Sha256: 49327631397a19bcee8a1d4e889885ff8b5d44c99c3822438589e929cb48e7c6

Contents?: true

Size: 767 Bytes

Versions: 22

Compression:

Stored size: 767 Bytes

Contents

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

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

22 entries across 22 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.7 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.6 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.5 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.4 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.3 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.2 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.1 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.19.0 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.18.8 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.18.7 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.18.0 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.7 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.6 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.5 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.4 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.3 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.2 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.1 app/components/coco/modals/modal_dialog/modal_dialog.js
coveragebook_components-0.17.0 app/components/coco/modals/modal_dialog/modal_dialog.js