diff --git a/assets/js/main.js b/assets/js/main.js index 9ba6eaf..a4b5d8e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -5,6 +5,28 @@ document.addEventListener('DOMContentLoaded', () => { const messagesList = document.getElementById('messages-list'); const typingIndicator = document.getElementById('typing-indicator'); + // Check for event description overflow + const checkEventDescriptions = () => { + document.querySelectorAll('.event-description').forEach(el => { + // Give it a tiny delay to ensure rendering is complete + setTimeout(() => { + if (el.scrollHeight <= el.clientHeight + 2) { // +2 for potential rounding issues + const btn = el.nextElementSibling; + if (btn && btn.classList.contains('read-more-btn')) { + btn.style.display = 'none'; + } + } else { + const btn = el.nextElementSibling; + if (btn && btn.classList.contains('read-more-btn')) { + btn.style.display = 'inline-block'; + } + } + }, 100); + }); + }; + checkEventDescriptions(); + window.addEventListener('resize', checkEventDescriptions); + function scrollToBottom(force = false) { if (!messagesList) return; @@ -3580,6 +3602,18 @@ document.addEventListener('DOMContentLoaded', () => { }); document.addEventListener('click', async (e) => { + // Toggle event description + const readMoreBtn = e.target.closest('.read-more-btn'); + if (readMoreBtn) { + const cardBody = readMoreBtn.closest('.card-body'); + const desc = cardBody.querySelector('.event-description'); + if (desc) { + desc.classList.toggle('expanded'); + readMoreBtn.innerText = desc.classList.contains('expanded') ? 'Voir moins' : 'Voir plus'; + } + return; + } + // Delete event const deleteBtn = e.target.closest('.delete-event-btn'); if (deleteBtn) { diff --git a/index.php b/index.php index 8014842..3fe7b9b 100644 --- a/index.php +++ b/index.php @@ -494,6 +494,22 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; + position: relative; + } + .event-description.expanded { + -webkit-line-clamp: unset; + display: block; + } + .read-more-btn { + color: var(--blurple); + cursor: pointer; + font-weight: 500; + display: inline-block; + margin-top: -10px; + margin-bottom: 15px; + } + .read-more-btn:hover { + text-decoration: underline; } @@ -927,7 +943,6 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';