Popravljen mobilni meni
Deploy to Production on Develop Push / deploy (push) Successful in 59s

This commit is contained in:
Mark Poljanšek committed 2025-09-04 16:14:35 +02:00
1 parent 6ed8073b76
commit c1094898b7
19 files changed
+130 -96

No files matched your search

+28 -13
View File
@@ -2,28 +2,43 @@ document.addEventListener('DOMContentLoaded', function() {
/**
* ===================================================================
* 1. OSNOVNA FUNKCIONALNOST MOBILNE NAVIGACIJE
* Ta koda je ključna za delovanje mobilnega menija.
* 1. OSNOVNA FUNKCIONALNOST MOBILNE NAVIGACIJE (Robustna različica)
* ===================================================================
*/
// --- Odpiranje in zapiranje glavnega mobilnega panela ---
// === MOBILNI MENI: Robusten toggle na <html> ===
try {
const mobileMenuIcon = document.querySelector('.mobile-menu-icon');
const body = document.querySelector('body');
const icon = document.querySelector('.mobile-menu-icon');
const root = document.documentElement; // Ciljamo <html>, da se izognemo konfliktom na <body>
if (mobileMenuIcon && body) {
mobileMenuIcon.addEventListener('click', () => {
body.classList.toggle('nav-open');
});
if (!icon) {
console.error('Mobile menu icon not found.');
} else {
console.error('Mobile menu icon or body not found.');
icon.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation(); // Preprečimo "bubbling" dogodka, ki bi lahko takoj zaprl meni
root.classList.toggle('nav-open');
});
// Zapri meni ob kliku izven panela ali ikone
document.addEventListener('click', (e) => {
if (root.classList.contains('nav-open') && !e.target.closest('.mobile-nav-panel') && !e.target.closest('.mobile-menu-icon')) {
root.classList.remove('nav-open');
}
});
// Zapri meni s tipko Escape
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
root.classList.remove('nav-open');
}
});
}
} catch (error) {
console.error('Error in Mobile Menu Toggle:', error);
} catch (err) {
console.error('Error in Mobile Menu Toggle:', err);
}
// --- Mobilni Accordion podmeni ---
// --- Mobilni Accordion podmeni (ostane nespremenjen) ---
try {
const mobileNav = document.querySelector('.mobile-nav-panel .mobile-nav');
if (mobileNav) {