2021-03-03 01:55:13 +00:00
|
|
|
function bindClick( collHeading, collSection, i, j ) {
|
2021-03-03 00:13:50 +00:00
|
|
|
return function () {
|
|
|
|
j = i + 1;
|
2021-03-03 01:55:13 +00:00
|
|
|
this.classList.toggle( 'section-heading--collapsed' );
|
2021-03-03 00:13:50 +00:00
|
|
|
collSection[ j ].classList.toggle( 'section-collapsible--collapsed' );
|
|
|
|
};
|
|
|
|
}
|
2021-03-02 22:16:24 +00:00
|
|
|
|
|
|
|
function main() {
|
2021-03-03 01:55:13 +00:00
|
|
|
var collHeading = document.getElementsByClassName( 'section-heading' ),
|
|
|
|
collSection = document.getElementsByClassName( 'section-collapsible' ),
|
2021-03-02 22:16:24 +00:00
|
|
|
i, j;
|
|
|
|
|
2021-03-03 01:55:13 +00:00
|
|
|
for ( i = 0; i < collHeading.length; i++ ) {
|
|
|
|
collHeading[ i ].addEventListener( 'click', bindClick( collHeading, collSection, i, j ) );
|
2021-03-02 22:16:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|