43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const deckHeaders = document.querySelectorAll('.deck-header');
|
|
|
|
deckHeaders.forEach(header => {
|
|
header.addEventListener('click', () => {
|
|
const words = header.nextElementSibling;
|
|
const chevron = header.querySelector('.chevron');
|
|
|
|
if (words.style.display === 'block') {
|
|
words.style.display = 'none';
|
|
chevron.classList.remove('expanded');
|
|
} else {
|
|
words.style.display = 'block';
|
|
chevron.classList.add('expanded');
|
|
}
|
|
});
|
|
});
|
|
|
|
const toggleAllButton = document.getElementById('toggle-all');
|
|
let allExpanded = true;
|
|
|
|
toggleAllButton.addEventListener('click', () => {
|
|
allExpanded = !allExpanded;
|
|
deckHeaders.forEach(header => {
|
|
const words = header.nextElementSibling;
|
|
const chevron = header.querySelector('.chevron');
|
|
|
|
if (allExpanded) {
|
|
words.style.display = 'block';
|
|
chevron.classList.add('expanded');
|
|
} else {
|
|
words.style.display = 'none';
|
|
chevron.classList.remove('expanded');
|
|
}
|
|
});
|
|
toggleAllButton.textContent = allExpanded ? 'Collapse All' : 'Expand All';
|
|
});
|
|
|
|
// Initially expand all
|
|
toggleAllButton.click();
|
|
});
|