mediawiki-skins-Citizen/resources/skins.citizen.scripts.sections/sections.js
2021-03-02 20:55:13 -05:00

20 lines
554 B
JavaScript

function bindClick( collHeading, collSection, i, j ) {
return function () {
j = i + 1;
this.classList.toggle( 'section-heading--collapsed' );
collSection[ j ].classList.toggle( 'section-collapsible--collapsed' );
};
}
function main() {
var collHeading = document.getElementsByClassName( 'section-heading' ),
collSection = document.getElementsByClassName( 'section-collapsible' ),
i, j;
for ( i = 0; i < collHeading.length; i++ ) {
collHeading[ i ].addEventListener( 'click', bindClick( collHeading, collSection, i, j ) );
}
}
main();