diff --git a/src/agenda_culturel/static/js/modal.js b/src/agenda_culturel/static/js/modal.js index 2837481..7122530 100644 --- a/src/agenda_culturel/static/js/modal.js +++ b/src/agenda_culturel/static/js/modal.js @@ -1,8 +1,16 @@ let visibleModal = null; +var escapeOk = true; + +const toggleModalNoEscape = (event) => { + toggleModal(event, true); + escapeOk = false; +} // Toggle modal -const toggleModal = (event) => { - event.preventDefault(); +const toggleModal = (event, avoidPrevent=false) => { + escapeOk = true; + if (!avoidPrevent) + event.preventDefault(); const modal = document.getElementById(event.currentTarget.getAttribute("data-target")); typeof modal != "undefined" && modal != null && isModalOpen(modal) ? closeModal(modal) @@ -28,15 +36,16 @@ const openModal = (modal) => { // Close modal const closeModal = (modal) => { - visibleModal = null; - document.documentElement.style.removeProperty("--scrollbar-width"); - modal.removeAttribute("open"); + if (escapeOk) { + visibleModal = null; + document.documentElement.style.removeProperty("--scrollbar-width"); + modal.removeAttribute("open"); + } }; // Close with a click outside document.addEventListener("click", (event) => { if (visibleModal != null) { - console.log("bordel"); const modalContent = visibleModal.querySelector("article"); const isClickInside = modalContent.contains(event.target); !isClickInside && closeModal(visibleModal); diff --git a/src/agenda_culturel/templates/agenda_culturel/event_form.html b/src/agenda_culturel/templates/agenda_culturel/event_form.html index a7a139a..a44b5ad 100644 --- a/src/agenda_culturel/templates/agenda_culturel/event_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/event_form.html @@ -18,7 +18,11 @@ {% load static_content_extra %} +{% if object %}