mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-30 00:55:25 +00:00
19 lines
540 B
JavaScript
19 lines
540 B
JavaScript
/**
|
|
* @param {Document} document
|
|
* @return {void}
|
|
*/
|
|
function initCollapsibleSections( document ) {
|
|
const headings = document.querySelectorAll( '.section-heading' ),
|
|
sections = document.querySelectorAll( '.section-collapsible' );
|
|
|
|
for ( let i = 0; i < headings.length; i++ ) {
|
|
headings[ i ].addEventListener( 'click', function () {
|
|
const j = i + 1;
|
|
this.classList.toggle( 'section-heading--collapsed' );
|
|
sections[ j ].classList.toggle( 'section-collapsible--collapsed' );
|
|
} );
|
|
}
|
|
}
|
|
|
|
initCollapsibleSections( document );
|