mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-15 14:49:21 +08:00
27 lines
822 B
JavaScript
Executable File
27 lines
822 B
JavaScript
Executable File
; (function () {
|
|
'use strict'
|
|
const accordionEl = document.getElementsByClassName('accordion-header')
|
|
|
|
function openAccordion (parent, panel) {
|
|
parent.classList.add('is-active')
|
|
panel.style.maxHeight = panel.scrollHeight + 'px'
|
|
}
|
|
|
|
function closeAccordion (parent, panel) {
|
|
parent.classList.remove('is-active')
|
|
panel.style.maxHeight = null
|
|
}
|
|
|
|
if (accordionEl.length > 0) {
|
|
for (let i = 0; i < accordionEl.length; i++) {
|
|
const el = accordionEl[i]
|
|
const parent = el.parentNode
|
|
const panel = el.nextElementSibling
|
|
parent.classList.contains('is-active') && openAccordion(parent, panel)
|
|
el.addEventListener('click', function () {
|
|
parent.classList.contains('is-active') ? closeAccordion(parent, panel) : openAccordion(parent, panel)
|
|
})
|
|
}
|
|
}
|
|
}())
|