Sha256: 56e8d1ad81ee16d4feb5a528624adce07ca1c1af3f21e180ffce338e54a90af4

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

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

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

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

  // Close dialog box on outside click
  dialogs.forEach((dialogElement) => {
    dialogElement.addEventListener("click", (event) => {
      const dialogParentDataset = dialogElement.parentElement.dataset
      if (dialogParentDataset.overlayClick === "overlay_close") return

      const clickedOutsideDialogBox = event.target.classList.contains("pb_dialog_rails")

      if (clickedOutsideDialogBox) {
        dialogElement.close()
        event.stopPropagation()
      }
    })
  })
};

export default dialogHelper;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
playbook_ui-12.35.0.pre.alpha.iconpocwebfonts1023 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.35.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.34.0.pre.alpha.play716popoverkitcloseonclickissue998 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.34.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.33.1.pre.alpha.PLAY933navkitcollapsible994 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.33.1 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.33.0.pre.alpha.PLAY905reactionbuttons982 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.33.0.pre.alpha.PLAY905reactionbuttons979 app/pb_kits/playbook/pb_dialog/dialogHelper.js
playbook_ui-12.33.0 app/pb_kits/playbook/pb_dialog/dialogHelper.js