19 lines
667 B
JavaScript
19 lines
667 B
JavaScript
// Shared hamburger menu toggle
|
|
(function () {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const btn = document.getElementById('hamburger-btn')
|
|
const menu = document.getElementById('hamburger-menu')
|
|
if (!btn || !menu) return
|
|
btn.addEventListener('click', (e) => {
|
|
e.stopPropagation()
|
|
menu.classList.toggle('open')
|
|
})
|
|
document.addEventListener('click', () => menu.classList.remove('open'))
|
|
// mark active link
|
|
const current = location.pathname.split('/').pop() || 'index.html'
|
|
menu.querySelectorAll('a').forEach(a => {
|
|
if (a.getAttribute('href') === current) a.classList.add('active')
|
|
})
|
|
})
|
|
})()
|