From ef3022e1b3c063b3b024bd5619c75f6bbdeff05b Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 3 Aug 2022 07:20:30 +0100 Subject: [PATCH] Fix overview modals --- core/static/modal.js | 50 +++++++++++++------ .../threshold/irc/network/edit-network.html | 4 +- .../threshold/irc/overview/actions.html | 2 +- .../threshold/irc/overview/aliases.html | 2 - .../irc/overview/modals/add-network.html | 5 +- .../irc/overview/modals/edit-aliases.html | 5 +- .../threshold/irc/overview/overview.html | 3 +- 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/core/static/modal.js b/core/static/modal.js index 4bbd4d0..138c87c 100644 --- a/core/static/modal.js +++ b/core/static/modal.js @@ -1,17 +1,37 @@ var modal = document.querySelector('.modal'); // assuming you have only 1 var html = document.querySelector('html'); -modal.querySelector('.modal-background').addEventListener('click', function(e) { - e.preventDefault(); - modal.classList.remove('is-active'); - html.classList.remove('is-clipped'); -}); -modal.querySelector('.modal-close').addEventListener('click', function(e) { - e.preventDefault(); - modal.classList.remove('is-active'); - html.classList.remove('is-clipped'); -}); -modal.querySelector('.modal-close-button').addEventListener('click', function(e) { - e.preventDefault(); - modal.classList.remove('is-active'); - html.classList.remove('is-clipped'); -}); \ No newline at end of file + +var elements = document.querySelectorAll('.modal-background'); +for(var i = 0; i < elements.length; i++) { + elements[i].addEventListener('click', function(e) { + // elements[i].preventDefault(); + modal.classList.remove('is-active'); + html.classList.remove('is-clipped'); + }); +} + +var elements = document.querySelectorAll('.modal-close'); +for(var i = 0; i < elements.length; i++) { + elements[i].addEventListener('click', function(e) { + // elements[i].preventDefault(); + modal.classList.remove('is-active'); + html.classList.remove('is-clipped'); + }); +} + +function activateButtons() { + var elements = document.querySelectorAll('.modal-close-button'); + for(var i = 0; i < elements.length; i++) { + elements[i].addEventListener('click', function(e) { + // elements[i].preventDefault(); + modal.classList.remove('is-active'); + html.classList.remove('is-clipped'); + }); + } +} +activateButtons(); +// modal.querySelector('.modal-close-button').addEventListener('click', function(e) { +// e.preventDefault(); +// modal.classList.remove('is-active'); +// html.classList.remove('is-clipped'); +// }); \ No newline at end of file diff --git a/core/templates/manage/threshold/irc/network/edit-network.html b/core/templates/manage/threshold/irc/network/edit-network.html index 35ce8d2..9526182 100644 --- a/core/templates/manage/threshold/irc/network/edit-network.html +++ b/core/templates/manage/threshold/irc/network/edit-network.html @@ -64,12 +64,14 @@ - + + diff --git a/core/templates/manage/threshold/irc/overview/actions.html b/core/templates/manage/threshold/irc/overview/actions.html index 6c65a6c..1cc4e1c 100644 --- a/core/templates/manage/threshold/irc/overview/actions.html +++ b/core/templates/manage/threshold/irc/overview/actions.html @@ -5,7 +5,7 @@ hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-get="{% url 'threshold_irc_actions_add-network' %}" hx-trigger="click" - hx-target="#modals-here-actions" + hx-target="#modals-here" class="button is-info"> diff --git a/core/templates/manage/threshold/irc/overview/aliases.html b/core/templates/manage/threshold/irc/overview/aliases.html index e7b60b3..e4a12b8 100644 --- a/core/templates/manage/threshold/irc/overview/aliases.html +++ b/core/templates/manage/threshold/irc/overview/aliases.html @@ -42,6 +42,4 @@ {% endif %} -
-
\ No newline at end of file diff --git a/core/templates/manage/threshold/irc/overview/modals/add-network.html b/core/templates/manage/threshold/irc/overview/modals/add-network.html index 8117325..b3f310b 100644 --- a/core/templates/manage/threshold/irc/overview/modals/add-network.html +++ b/core/templates/manage/threshold/irc/overview/modals/add-network.html @@ -63,11 +63,12 @@ - - + + diff --git a/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html b/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html index 3a750c1..497e69d 100644 --- a/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html +++ b/core/templates/manage/threshold/irc/overview/modals/edit-aliases.html @@ -52,11 +52,12 @@ - - + + diff --git a/core/templates/manage/threshold/irc/overview/overview.html b/core/templates/manage/threshold/irc/overview/overview.html index 05d0f63..7f3110c 100644 --- a/core/templates/manage/threshold/irc/overview/overview.html +++ b/core/templates/manage/threshold/irc/overview/overview.html @@ -85,5 +85,6 @@ - +
+
{% endblock %}