John2121's picture
wtf im a contractor for construcgtion and tech/web site infastructor
42d745f verified
// Mobile menu toggle
document.addEventListener('DOMContentLoaded', function() {
// Close mobile menu when clicking outside
document.addEventListener('click', function(event) {
const mobileMenus = document.querySelectorAll('.mobile-menu');
const mobileButtons = document.querySelectorAll('.mobile-menu-button');
mobileMenus.forEach(menu => {
const button = Array.from(mobileButtons).find(btn =>
btn.getRootNode() === menu.getRootNode()
);
if (menu.classList.contains('active') &&
!menu.contains(event.target) &&
button && !button.contains(event.target)) {
menu.classList.remove('active');
}
});
});
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
window.scrollTo({
top: target.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Feather icons initialization
document.addEventListener('DOMContentLoaded', function() {
if (typeof feather !== 'undefined') {
feather.replace();
}
});