Sha256: 713bcd434d424894dfbd4aa314ab421e478697ba559e85e1c7a3b8a3f486609d

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

document.addEventListener("DOMContentLoaded", () => {
  const modalId = "LimitAmendmentsModal";
  const modalEl = document.getElementById(modalId);
  const amendButton = document.getElementById("amend-button");
  const limitAmendments = modalEl && JSON.parse(modalEl.dataset.limitAmendments);

  if (!amendButton || !limitAmendments || document.querySelector('a[href^="/users/sign_in"]')) {
    return;
  }

  modalEl.querySelectorAll("a").forEach((aEl) => {
    aEl.addEventListener("click", () => {
      window.Decidim.currentDialogs[modalId].close();
    });
  });

  /**
   * Determines if the modal should be displayed based on its current state and data attributes.
   */
  amendButton.addEventListener("click", (event) => {
    const modal = window.Decidim.currentDialogs[modalId];
    if (modal) {
      event.preventDefault();
      event.stopPropagation();
      modal.open();
    }
  });
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.11.3 app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js
decidim-decidim_awesome-0.11.2 app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js
decidim-decidim_awesome-0.11.1 app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js