Sha256: 0347fffe9ce6cb4c541e62ab161d14d00b6fecfe2d853b283f0f81f4039a6a22

Contents?: true

Size: 1.26 KB

Versions: 202

Compression:

Stored size: 1.26 KB

Contents

const dialogHelper = () => {
  const openTrigger = document.querySelectorAll("[data-open-dialog]");
  const closeTrigger = document.querySelectorAll("[data-close-dialog]");

  openTrigger.forEach((open) => {
    open.addEventListener("click", () => {
      var openTriggerData = open.dataset.openDialog;
      var targetDialog = document.getElementById(openTriggerData)
      if (targetDialog.open) return;
      targetDialog.showModal();

      //the following allows you to close dialog by clicking on overlay
      targetDialog.addEventListener('click',((event) => {
        var dialogContainerData = targetDialog.parentElement.dataset
         if (dialogContainerData.overlayClick === "overlay_close") return;
          let rect = event.target.getBoundingClientRect();
                if (rect.left > event.clientX ||
              rect.right < event.clientX ||
              rect.top > event.clientY ||
              rect.bottom < event.clientY
          ) {
              targetDialog.close();
          }
        })
      );
    });
  });

  closeTrigger.forEach((close) => {
    close.addEventListener("click", () => {
      var closeTriggerData = close.dataset.closeDialog;
      document.getElementById(closeTriggerData).close();
    });
  });
};

export default dialogHelper;

Version data entries

202 entries across 202 versions & 1 rubygems

Version Path
playbook_ui-12.24.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.23.0.pre.alpha.movemarkdown712 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.23.0.pre.alpha.movemarkdown708 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.23.0.pre.alpha.play698responsivespacingglobalprop703 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.23.0.pre.alpha.play698responsivespacingglobalprop701 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.23.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.22.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown696 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.22.0.pre.alpha.play698responsivespacingglobalprop690 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.22.0.pre.alpha.PBNTR12checkingemptyfilters686 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.22.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.21.0.pre.alpha.PLAY807RTEcustomtoolbar680 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.21.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.20.0.pre.alpha.movemarkdown668 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.20.0.pre.alpha.title2667 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.20.0.pre.alpha.title2665 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.20.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.19.0.pre.alpha.PLAY699zindexresponsive650 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.19.0.pre.alpha.movemarkdown639 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.19.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown638 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.19.0.pre.alpha.movemarkdown637 app/pb_kits/playbook/pb_dialog/dialogHelper.js