Index: static/js/main.js |
=================================================================== |
--- a/static/js/main.js |
+++ b/static/js/main.js |
@@ -18,10 +18,52 @@ |
var toggleNavbarCollapseEls = document.getElementsByClassName("toggle-navbar-collapse"); |
for (var i = 0; i < toggleNavbarCollapseEls.length; i++) |
{ |
toggleNavbarCollapseEls[i] |
.addEventListener("click", toggleNavbarCollapse, false); |
} |
+ // Accordion menu |
+ |
+ function setupAccordionMenu(accordionEl) |
+ { |
+ var accordionButtons = accordionEl.getElementsByClassName('accordion-toggle-button'); |
+ for ( var i = 0; i < accordionButtons.length; i++ ) { |
+ accordionButtons[i].addEventListener("click", toggleAccordionSection, false); |
+ if ( i !== 0 ) { |
+ accordionButtons[i].setAttribute("aria-expanded", "false"); |
+ accordionButtons[i].setAttribute("aria-disabled", "false"); |
+ document |
+ .getElementById( accordionButtons[i].getAttribute("aria-controls") ) |
+ .setAttribute("hidden", "true"); |
ire
2017/09/18 10:08:11
See https://issues.adblockplus.org/ticket/5703 reg
juliandoucette
2017/09/18 12:53:31
Acknowledged.
|
+ } |
+ } |
+ } |
+ |
+ function toggleAccordionSection() |
+ { |
+ // Hide currently expanded section |
+ var accordion = this.parentElement.parentElement; |
+ var expandedButton = accordion.querySelector("button[aria-expanded='true']"); |
+ expandedButton.setAttribute("aria-expanded", "false"); |
+ expandedButton.setAttribute("aria-disabled", "false"); |
+ document |
+ .getElementById( expandedButton.getAttribute("aria-controls") ) |
+ .setAttribute("hidden", "true"); |
+ |
+ // Expand new section |
+ this.setAttribute("aria-expanded", "true"); |
+ this.setAttribute("aria-disabled", "true"); |
+ document |
+ .getElementById( this.getAttribute("aria-controls") ) |
+ .removeAttribute("hidden"); |
+ } |
+ |
+ var accordionMenus = document.getElementsByClassName('accordion'); |
+ for (var i = 0; i < accordionMenus.length; i++) |
+ { |
+ setupAccordionMenu( accordionMenus[i] ); |
+ } |
ire
2017/09/18 10:08:11
This will be refactored in https://issues.adblockp
juliandoucette
2017/09/18 12:53:31
Acknowledged.
|
+ |
}, false); |
}()); |