Joywork/promo/js/lw-script.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-05-22 20:21:54 +02:00
document.addEventListener("DOMContentLoaded", function () {
const accordeonHeaders = document.querySelectorAll(".accordeon__item-header");
if (accordeonHeaders) {
accordeonHeaders.forEach((accHeader) => {
accHeader.addEventListener("click", function () {
const accordeonItemBody = this.nextElementSibling;
const img = this.querySelector(".accordeon__item-header-img");
if (accordeonItemBody.classList.contains("collapsed")) {
accordeonItemBody.classList.remove("collapsed");
img.style.transform = "rotate(0deg)";
} else {
accordeonItemBody.classList.add("collapsed");
img.style.transform = "rotate(-180deg)";
}
});
});
}
});
document.addEventListener("DOMContentLoaded", function () {
const accordeonItems = document.querySelectorAll(
".lw-accordeon__catalog-header",
);
if (accordeonItems.length) {
accordeonItems.forEach((item) => {
item.addEventListener("click", function (evt) {
const target = evt.currentTarget;
const parent = target.parentNode;
if (parent.classList.contains("expanded")) return;
const prev = document.querySelector(
".lw-catalog-accordeon .accordeon__item.expanded",
);
if (prev) {
prev.classList.remove("expanded");
}
parent.classList.add("expanded");
});
});
}
});
function openTab(tabId, button) {
const tabs = document.querySelectorAll(".tab-content");
tabs.forEach((tab) => tab.classList.remove("active"));
const buttons = document.querySelectorAll(".tab-button");
buttons.forEach((btn) => btn.classList.remove("active"));
const selectedTab = document.getElementById(tabId);
if (selectedTab) {
selectedTab.classList.add("active");
}
button.classList.add("active");
}