Disable mouse click on navbar for desktop

This commit is contained in:
Antoine Bartuccio 2025-06-16 09:17:40 +02:00
parent dad09deab7
commit 0f55bcc513
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -124,20 +124,30 @@
{% block script %} {% block script %}
<script> <script>
const menuItems = document.querySelectorAll(".navbar details[name='navbar'].menu"); const menuItems = document.querySelectorAll(".navbar details[name='navbar'].menu");
const isMobile = () => { const isDesktop = () => {
return window.innerWidth >= 500; return window.innerWidth >= 500;
} }
for (const item of menuItems){ for (const item of menuItems){
item.addEventListener("mouseover", () => { item.addEventListener("mouseover", () => {
if (isMobile()){ if (isDesktop()){
item.setAttribute("open", ""); item.setAttribute("open", "");
} }
}) })
item.addEventListener("mouseout", () => { item.addEventListener("mouseout", () => {
if (isMobile()){ if (isDesktop()){
item.removeAttribute("open"); item.removeAttribute("open");
} }
}) })
item.addEventListener("click", (event) => {
// Ignore keyboard clicks
if (event.detail === 0){
return;
}
if (isDesktop()){
event.preventDefault();
}
})
} }
function showMenu() { function showMenu() {