Sha256: ce317c96d391f21230bc77f819af01796ba4724a54ea2031113faefc72e1e9cc

Contents?: true

Size: 750 Bytes

Versions: 22

Compression:

Stored size: 750 Bytes

Contents

import { CocoComponent } from "@js/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

22 entries across 22 versions & 1 rubygems

Version Path
coveragebook_components-0.10.0 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.9.1 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.9.0 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.9 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.8 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.7 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.6 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.5 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.4 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.3 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.2 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.1 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.0 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.0.beta.3 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.0.beta.2 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.8.0.beta.1 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.7.10 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.7.9 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.7.8 app/components/coco/base/modal_dialog/modal_dialog.js
coveragebook_components-0.7.7 app/components/coco/base/modal_dialog/modal_dialog.js