Files
kidsai/html/drone_bup/js/mobile-menu.js
2025-06-24 15:43:32 +02:00

46 lines
1.6 KiB
JavaScript

/**
* Mobile navigation functionality
* This script handles the mobile hamburger menu behavior
*/
document.addEventListener('DOMContentLoaded', function() {
// Mobile navigation toggle
const mobileToggle = document.getElementById('mobileToggle');
const mainNav = document.getElementById('mainNav');
if(mobileToggle && mainNav) {
mobileToggle.addEventListener('click', function() {
mainNav.classList.toggle('active');
});
}
// Close mobile menu when a link is clicked
const mobileNavLinks = document.querySelectorAll('.main-nav a');
mobileNavLinks.forEach(link => {
link.addEventListener('click', function() {
if (window.innerWidth <= 768) {
mainNav.classList.remove('active');
}
});
});
// Close menu when clicking outside
document.addEventListener('click', function(event) {
if (window.innerWidth <= 768 &&
!event.target.closest('.main-nav') &&
!event.target.closest('.mobile-toggle') &&
mainNav.classList.contains('active')) {
mainNav.classList.remove('active');
}
});
// Ensure copyright year is 2025 on mobile
const footerText = document.querySelector('footer p[data-i18n="footer_text"]');
if (footerText) {
// Force update the copyright year to 2025 for mobile and desktop
const currentText = footerText.innerHTML;
const updatedText = currentText.replace(/© \d{4}/, '© 2025');
footerText.innerHTML = updatedText;
}
});