Initial commit
This commit is contained in:
39
js/seanceToggle.js
Normal file
39
js/seanceToggle.js
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user