update from sparkleup

This commit is contained in:
Madison Scott-Clary 2020-04-15 19:50:07 -07:00
parent b7a10730ee
commit 1ca2905ec9
2 changed files with 17 additions and 0 deletions

View File

@ -233,6 +233,7 @@
</ul>
</li>
</ol>
<span class="control">Expand all</span>
</article>
<footer>
<p>Page generated on 2020-04-08 16:11</p>
@ -261,6 +262,22 @@ document.querySelectorAll('li.has-nested').forEach(el => {
el.querySelector('.toggle').addEventListener('click', () => {
el.classList.toggle('closed');
});
});
let expanded = false;
document.querySelector('.control').addEventListener('click', (e) => {
expanded = !expanded;
if (expanded) {
e.target.innerText = 'Collapse all';
} else {
e.target.innerText = 'Expand all';
}
document.querySelectorAll('.has-nested').forEach((el) => {
if (expanded) {
el.classList.remove('closed');
} else {
el.classList.add('closed')
}
});
});
</script>
</body>