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.33.0.pre.alpha.revert2650closedialogonoutsideclick977 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.32.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.hoverrails951 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.hoverrails948 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.multilevelnopillsdesigns944 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.multilevelnopillsdesigns941 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.PLAY814removemomentjs935 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.PLAY814removemomentjs933 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.datepickerdisableddatefix931 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0.pre.alpha.customiconsfa928 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.31.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.play846responsivespacingglobalpropsneedsdefault924 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.PLAY906multilevelselectedidsprop917 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.PLAY906multilevelselectedidsprop916 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.hovertesting914 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.PLAY906multilevelselectedidsprop912 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1.pre.alpha.PLAY802responsivetitlekit909 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.0.pre.alpha.PLAY906multilevelselectedidsprop902 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.1 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.30.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js