function init() { // Wait for DOM to be ready setTimeout(() => { // DESKTOP DROPDOWN FIX: Make dropdowns disappear when clicking links const desktopDropdownLinks = document.querySelectorAll('#navigation-menu .group div[class*="absolute"] a'); desktopDropdownLinks.forEach(link => { link.addEventListener('click', function(e) { // Only apply on desktop (>= 1024px) if (window.innerWidth >= 1024) { const parentDropdown = link.closest('div[class*="absolute"]'); if (parentDropdown) { setTimeout(() => { parentDropdown.classList.add('hidden'); document.activeElement.blur(); }, 50); } } }); }); // MOBILE ONLY: Add click functionality to "About Us" and "Solutions" dropdown buttons const dropdownButtons = document.querySelectorAll('#navigation-menu .group button'); console.log('Found dropdown buttons:', dropdownButtons.length); // Debug log dropdownButtons.forEach(button => { const buttonText = button.querySelector('span').textContent; console.log('Setting up button:', buttonText); // Debug log button.addEventListener('click', function(e) { // Only work on mobile/tablet screens if (window.innerWidth < 1024) { e.preventDefault(); e.stopPropagation(); console.log('Mobile dropdown clicked:', buttonText); // Debug log // Find the dropdown for this button const group = this.closest('.group'); if (group) { const dropdown = group.querySelector('div[class*="absolute"]'); if (dropdown) { console.log('Found dropdown for:', buttonText); // Debug log // Check if this dropdown is currently visible const isCurrentlyHidden = dropdown.classList.contains('hidden'); // First, close ALL dropdowns const allDropdowns = document.querySelectorAll('#navigation-menu .group div[class*="absolute"]'); allDropdowns.forEach(dd => { dd.classList.add('hidden'); dd.style.position = ''; dd.style.width = ''; dd.style.display = ''; }); // If this dropdown was hidden, show it now if (isCurrentlyHidden) { console.log('Opening dropdown for:', buttonText); // Debug log dropdown.classList.remove('hidden'); dropdown.style.position = 'static'; dropdown.style.width = '100%'; dropdown.style.display = 'block'; dropdown.style.transform = 'none'; dropdown.style.opacity = '1'; } } else { console.log('No dropdown found for:', buttonText); // Debug log } } } }); }); // MOBILE: Close burger menu when dropdown links are clicked const dropdownLinks = document.querySelectorAll('#navigation-menu a'); dropdownLinks.forEach(link => { link.addEventListener('click', function() { if (window.innerWidth < 1024) { const mobileMenu = document.getElementById('navigation-menu'); const burgerButton = document.querySelector('[data-landingsite-mobile-menu-toggle]'); if (mobileMenu && burgerButton) { setTimeout(() => { mobileMenu.classList.add('hidden'); burgerButton.setAttribute('aria-expanded', 'false'); }, 100); } } }); }); }, 300); } function teardown() { // Clean up if needed } export { init, teardown };