aboutsummaryrefslogtreecommitdiff
path: root/docs/_static/sidebar.js
diff options
context:
space:
mode:
authorNadir Chowdhury <[email protected]>2020-08-29 04:13:20 +0100
committerRapptz <[email protected]>2020-12-18 21:18:56 -0500
commita04a410c8ac9f5f9ec31aee91e841c8bafbdec1d (patch)
treeb0b19fc2e77db4e47565c97df38792e5b98978a4 /docs/_static/sidebar.js
parentFix methods from superclass showing under "Attributes" table (diff)
downloaddiscord.py-a04a410c8ac9f5f9ec31aee91e841c8bafbdec1d.tar.xz
discord.py-a04a410c8ac9f5f9ec31aee91e841c8bafbdec1d.zip
[matrix] collapsible sidebar headings
Diffstat (limited to 'docs/_static/sidebar.js')
-rw-r--r--docs/_static/sidebar.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/_static/sidebar.js b/docs/_static/sidebar.js
new file mode 100644
index 00000000..8c45a210
--- /dev/null
+++ b/docs/_static/sidebar.js
@@ -0,0 +1,50 @@
+function collapseSection(icon) {
+ icon.classList.remove('expanded');
+ icon.classList.add('collapsed');
+ icon.innerText = 'chevron_right';
+ let children = icon.nextElementSibling.nextElementSibling;
+ // <arrow><heading>
+ // --> <square><children>
+ children.style.display = "none";
+}
+
+function expandSection(icon) {
+ icon.classList.remove('collapse');
+ icon.classList.add('expanded');
+ icon.innerText = 'expand_more';
+ let children = icon.nextElementSibling.nextElementSibling;
+ children.style.display = "block";
+}
+
+document.addEventListener('DOMContentLoaded', () => {
+ let sidebar = document.getElementById('sidebar');
+ let toc = sidebar.querySelector('ul');
+ let allReferences = toc.querySelectorAll('a.reference.internal:not([href="#"])');
+
+ for (let ref of allReferences) {
+
+ let next = ref.nextElementSibling;
+
+ if (next && next.tagName === "UL") {
+
+ let icon = document.createElement('span');
+ icon.className = 'material-icons collapsible-arrow expanded';
+ icon.innerText = 'expand_more';
+
+ if (next.parentElement.tagName == "LI") {
+ next.parentElement.classList.add('no-list-style')
+ }
+
+ icon.addEventListener('click', () => {
+ if (icon.classList.contains('expanded')) {
+ collapseSection(icon);
+ } else {
+ expandSection(icon);
+ }
+ })
+
+ ref.classList.add('ref-internal-padding')
+ ref.parentNode.insertBefore(icon, ref);
+ }
+ }
+});