diff options
author | 2022-01-30 14:29:48 +0100 | |
---|---|---|
committer | 2022-01-30 14:29:48 +0100 | |
commit | dda3e355ac31dc4b9629f2e9e63474bbba69d740 (patch) | |
tree | fd73941134e394abc8bddd71c5fb9bed9b91f816 /pydis_site/static/js/collapsibles.js | |
parent | Remove italics from resource cards. (diff) |
Refactor: collapsibles as a stand-alone component
Diffstat (limited to 'pydis_site/static/js/collapsibles.js')
-rw-r--r-- | pydis_site/static/js/collapsibles.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pydis_site/static/js/collapsibles.js b/pydis_site/static/js/collapsibles.js new file mode 100644 index 00000000..366a033c --- /dev/null +++ b/pydis_site/static/js/collapsibles.js @@ -0,0 +1,13 @@ +document.addEventListener("DOMContentLoaded", () => { + const headers = document.getElementsByClassName("collapsible"); + for (const header of headers) { + header.addEventListener("click", () => { + var content = header.nextElementSibling; + if (content.style.maxHeight){ + content.style.maxHeight = null; + } else { + content.style.maxHeight = content.scrollHeight + "px"; + } + }); + } +}); |