mirror of
https://github.com/pvlnes/homelab.git
synced 2026-06-03 18:33:49 +00:00
Добавил хуйню, шоб FAQ раскрывалось нормально на мобилках
This commit is contained in:
parent
2a04f1cfaa
commit
e1af430022
@ -599,21 +599,38 @@ window.addEventListener('scroll', () => {
|
|||||||
|
|
||||||
|
|
||||||
// ---- FAQ: аккордеон ----
|
// ---- FAQ: аккордеон ----
|
||||||
|
function setFaqAnswerHeight(answer, open) {
|
||||||
|
if (open) {
|
||||||
|
answer.classList.add('open');
|
||||||
|
answer.style.maxHeight = answer.scrollHeight + 'px';
|
||||||
|
} else {
|
||||||
|
answer.classList.remove('open');
|
||||||
|
answer.style.maxHeight = '0px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelectorAll('.faq-question').forEach(btn => {
|
document.querySelectorAll('.faq-question').forEach(btn => {
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
const expanded = btn.getAttribute('aria-expanded') === 'true';
|
const expanded = btn.getAttribute('aria-expanded') === 'true';
|
||||||
const answer = btn.nextElementSibling;
|
const answer = btn.nextElementSibling;
|
||||||
|
|
||||||
// Закрыть все остальные
|
|
||||||
document.querySelectorAll('.faq-question').forEach(b => {
|
document.querySelectorAll('.faq-question').forEach(b => {
|
||||||
b.setAttribute('aria-expanded', 'false');
|
b.setAttribute('aria-expanded', 'false');
|
||||||
b.nextElementSibling.classList.remove('open');
|
setFaqAnswerHeight(b.nextElementSibling, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Переключить текущий
|
|
||||||
if (!expanded) {
|
if (!expanded) {
|
||||||
btn.setAttribute('aria-expanded', 'true');
|
btn.setAttribute('aria-expanded', 'true');
|
||||||
answer.classList.add('open');
|
setFaqAnswerHeight(answer, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
document.querySelectorAll('.faq-question[aria-expanded="true"]').forEach(btn => {
|
||||||
|
const answer = btn.nextElementSibling;
|
||||||
|
if (answer.classList.contains('open')) {
|
||||||
|
answer.style.maxHeight = answer.scrollHeight + 'px';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user