Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions books.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,8 @@
tryLoadCover(img);
});
});

// Menu dropdown toggle
function toggleMenu() {
const dropdown = document.querySelector('.menu-dropdown');
const btn = document.querySelector('.menu-button');
const willShow = !dropdown.classList.contains('show');
dropdown.classList.toggle('show');
if (btn) btn.setAttribute('aria-expanded', willShow ? 'true' : 'false');
}

// Close dropdown when clicking outside
document.addEventListener('click', function(event) {
const menuWrapper = document.querySelector('.menu-wrapper');
if (menuWrapper && !menuWrapper.contains(event.target)) {
const dropdown = document.querySelector('.menu-dropdown');
if (dropdown) {
dropdown.classList.remove('show');
const btn = document.querySelector('.menu-button');
if (btn) btn.setAttribute('aria-expanded', 'false');
}
}
});
</script>
<script src="js/menu.js"></script>
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
Expand Down
23 changes: 1 addition & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,8 @@
const icon = document.querySelector('.theme-toggle-slider i');
icon.className = theme === 'light' ? 'fas fa-moon' : 'fas fa-sun';
});

// Menu dropdown toggle
function toggleMenu() {
const dropdown = document.querySelector('.menu-dropdown');
const btn = document.querySelector('.menu-button');
const willShow = !dropdown.classList.contains('show');
dropdown.classList.toggle('show');
if (btn) btn.setAttribute('aria-expanded', willShow ? 'true' : 'false');
}

// Close dropdown when clicking outside
document.addEventListener('click', function(event) {
const menuWrapper = document.querySelector('.menu-wrapper');
if (menuWrapper && !menuWrapper.contains(event.target)) {
const dropdown = document.querySelector('.menu-dropdown');
if (dropdown) {
dropdown.classList.remove('show');
const btn = document.querySelector('.menu-button');
if (btn) btn.setAttribute('aria-expanded', 'false');
}
}
});
</script>
<script src="js/menu.js"></script>
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
Expand Down
21 changes: 21 additions & 0 deletions js/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Menu dropdown toggle
function toggleMenu() {
const dropdown = document.querySelector('.menu-dropdown');
const btn = document.querySelector('.menu-button');
const willShow = !dropdown.classList.contains('show');
dropdown.classList.toggle('show');
if (btn) btn.setAttribute('aria-expanded', willShow ? 'true' : 'false');
}

// Close dropdown when clicking outside
document.addEventListener('click', function(event) {
const menuWrapper = document.querySelector('.menu-wrapper');
if (menuWrapper && !menuWrapper.contains(event.target)) {
const dropdown = document.querySelector('.menu-dropdown');
if (dropdown) {
dropdown.classList.remove('show');
const btn = document.querySelector('.menu-button');
if (btn) btn.setAttribute('aria-expanded', 'false');
}
}
});