From fb5052d43dcf89dabc291107aab25c0ccf426b70 Mon Sep 17 00:00:00 2001 From: Tim Aldinger Date: Mon, 19 Oct 2026 09:40:08 +0200 Subject: [PATCH] =?UTF-8?q?click=20auf=20dropdown=20=C3=B6ffnet=20es=20(f?= =?UTF-8?q?=C3=BCr=20mobile)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/js/pages/index/index.js | 16 +++++++++++++++- .../resources/static/js/pages/list/list.js | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/resources/static/js/pages/index/index.js b/src/main/resources/static/js/pages/index/index.js index ba85aa1..3b4cbf3 100644 --- a/src/main/resources/static/js/pages/index/index.js +++ b/src/main/resources/static/js/pages/index/index.js @@ -60,11 +60,25 @@ function init() { , errmsg: `liste konnte nicht aktualsiiert werden` }) - } else if (event.target.matches(".list__deleteButton")) { deleteList(event.target.closest("li")); } }); + + document.querySelector(".nav").addEventListener("click", (event) => { + + if (event.target.matches(".nav__dropdown")) { + event.target.closest("li").classList.add("is-open"); + event.stopPropagation(); + } + }); + + + document.querySelector("body").addEventListener("click", (event) => { + if (!event.target.matches(".nav__dropdown")) { + document.querySelector(".is-open")?.classList.remove("is-open"); + } + }); } document.addEventListener('DOMContentLoaded', init); diff --git a/src/main/resources/static/js/pages/list/list.js b/src/main/resources/static/js/pages/list/list.js index 2e03750..5bf0c00 100644 --- a/src/main/resources/static/js/pages/list/list.js +++ b/src/main/resources/static/js/pages/list/list.js @@ -151,6 +151,16 @@ function init() { }); } + + + }); + + document.querySelector(".nav").addEventListener("click", (event) => { + + if (event.target.matches(".nav__dropdown")) { + event.target.closest("li").classList.add("is-open"); + event.stopPropagation(); + } }); document.querySelector(".displayedList").addEventListener("change", (e) => { @@ -161,6 +171,14 @@ function init() { } }); + + + document.querySelector("body").addEventListener("click", (event) => { + if (!event.target.matches(".nav__dropdown")) { + document.querySelector(".is-open")?.classList.remove("is-open"); + } + }); + console.log("javascript initialized!"); }