From 34c3eb930866c9f507733fdce1b313926ca1d300 Mon Sep 17 00:00:00 2001 From: cangui Date: Sat, 21 Jun 2025 20:25:36 +0200 Subject: [PATCH] up --- templates/assets/js/index.js | 17 +++++++++++++++++ templates/dashboard.pages.tmpl | 3 +++ 2 files changed, 20 insertions(+) diff --git a/templates/assets/js/index.js b/templates/assets/js/index.js index 73e60f9..aefd6e8 100644 --- a/templates/assets/js/index.js +++ b/templates/assets/js/index.js @@ -86,3 +86,20 @@ document.addEventListener("htmx:afterOnLoad", function (event) { // console.log("Réponse du serveur :", event.detail.xhr.responseText); }); +// static/js/spinner.js +// Écoute tous les événements HTMX et affiche/masque le spinner global +document.body.addEventListener('htmx:send', () => { + const s = document.getElementById('loading-spinner'); + if (s) s.style.display = 'block'; +}); +document.body.addEventListener('htmx:afterOnLoad', () => { + const s = document.getElementById('loading-spinner'); + if (s) s.style.display = 'none'; +}); +// En cas d’erreur réseau +document.body.addEventListener('htmx:afterRequest', (evt) => { + if (evt.detail.xhr.status >= 400) { + const s = document.getElementById('loading-spinner'); + if (s) s.style.display = 'none'; + } +}); diff --git a/templates/dashboard.pages.tmpl b/templates/dashboard.pages.tmpl index 8082ed9..ee587b1 100644 --- a/templates/dashboard.pages.tmpl +++ b/templates/dashboard.pages.tmpl @@ -55,6 +55,9 @@
+