40 lines
1.7 KiB
JavaScript
40 lines
1.7 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
document.querySelectorAll('[data-seance-toggle]').forEach(function (header) {
|
|
header.addEventListener('click', function (e) {
|
|
// Don't toggle when clicking a link
|
|
if (e.target.closest('a')) return;
|
|
|
|
var item = header.closest('.seance-item, .membres-item, .author-posts-item, .labo-dropdown-item');
|
|
var content = item.querySelector('.seance-content, .membres-content, .author-posts-content, .labo-dropdown-content');
|
|
var isOpen = item.classList.contains('is-open');
|
|
|
|
if (isOpen) {
|
|
content.style.display = 'none';
|
|
item.classList.remove('is-open');
|
|
} else {
|
|
content.style.display = '';
|
|
item.classList.add('is-open');
|
|
if (window.fitPostCardTitles) window.fitPostCardTitles();
|
|
}
|
|
});
|
|
});
|
|
|
|
// Auto-expand and scroll to a séance targeted by URL hash (#seance-{ID})
|
|
var hash = window.location.hash;
|
|
if (hash && hash.startsWith('#seance-')) {
|
|
var target = document.querySelector(hash + '.seance-item');
|
|
if (target) {
|
|
var content = target.querySelector('.seance-content');
|
|
if (content) {
|
|
content.style.display = '';
|
|
target.classList.add('is-open');
|
|
if (window.fitPostCardTitles) window.fitPostCardTitles();
|
|
setTimeout(function () {
|
|
var top = target.getBoundingClientRect().top + window.scrollY - 150;
|
|
window.scrollTo({ top: top, behavior: 'smooth' });
|
|
}, 150);
|
|
}
|
|
}
|
|
}
|
|
});
|