mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-17 16:45:22 +00:00
Merge pull request #1125 from ae-utbm/navbar-keyboard-navigation
Disable mouse click on navbar for desktop
This commit is contained in:
commit
1c14bb22a0
@ -108,20 +108,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() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user