This commit is contained in:
Dark Steveneq
2025-09-15 01:58:08 +02:00
parent 6c3d9648d1
commit e9e82806b9
8 changed files with 751 additions and 16 deletions

25
assets/js/akordeon.js Normal file
View File

@@ -0,0 +1,25 @@
document.addEventListener("DOMContentLoaded", () => {
const akordeony = document.getElementsByClassName("akordeon");
for (const akordeon of akordeony) {
if (akordeon.children.length < 2) {
console.warn("Na stronie jest niepoprawnie skonfigurowany akordeon!")
continue;
}
const pierworodny = akordeon.children[0];
const nowy = document.createElement("div")
nowy.className = "akordeon-header";
nowy.onclick = () => {
const otwarte = akordeon.classList.contains("open");
akordeon.classList.remove(otwarte ? "open": "closed");
akordeon.classList.add(otwarte ? "closed" : "open");
for (const dziecko of akordeon.children) {
if (dziecko != nowy) {
dziecko.style.display = otwarte ? "" : "none";
}
}
}
akordeon.replaceChild(nowy, pierworodny)
nowy.append(pierworodny)
}
})