diff --git a/public/js/app.js b/public/js/app.js index e46c00e..5b2c2e4 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -388,7 +388,7 @@ function styleLinePolygon(feature) { // Block 9: Feature Popups for Read, Edit, Delete and Vote // ===================================================================== -// Builds Popup HTML for Features +// Builds Popup HTML for Features called every Time the Popup opens function buildPopupHtml(feature) { const props = feature.properties; const cat = CATEGORIES[props.category] || CATEGORIES.other; @@ -405,18 +405,26 @@ function buildPopupHtml(feature) { '' + (props.description ? '' : ''); - // Shows Photo if available + // Photo Toggle Button including hidden Photo if (props.photo_path) { - html += ''; return html; } @@ -775,6 +785,7 @@ function updateContributionsList() { '' + ' ' + props.likes_count + '' + ' ' + props.dislikes_count + '' + + ' ' + (props.comment_count || 0) + '' + '' + '' + ''; @@ -1133,6 +1144,40 @@ function deleteComment(commentId, contributionId) { }); } +// Toggles Photo Visibility in Popup +function togglePhoto(contributionId) { + const container = document.getElementById('photo-container-' + contributionId); + const label = document.getElementById('photo-label-' + contributionId); + if (!container) return; + + if (container.style.display === 'none') { + container.style.display = 'block'; + label.textContent = 'Foto verbergen'; + } else { + container.style.display = 'none'; + label.textContent = 'Foto anzeigen'; + } +} + +// Toggles Comments Section Visibility in Popup +function toggleComments(contributionId) { + const section = document.getElementById('comments-section-' + contributionId); + const toggle = document.getElementById('comments-toggle-' + contributionId); + if (!section) return; + + if (section.style.display === 'none') { + section.style.display = 'block'; + toggle.classList.remove('fa-chevron-down'); + toggle.classList.add('fa-chevron-up'); + // Loads Comments + loadComments(contributionId); + } else { + section.style.display = 'none'; + toggle.classList.remove('fa-chevron-up'); + toggle.classList.add('fa-chevron-down'); + } +} + // ===================================================================== // Block 16: Application Startup diff --git a/public/styles.css b/public/styles.css index 16b4e44..c65704b 100644 --- a/public/styles.css +++ b/public/styles.css @@ -630,8 +630,47 @@ select.form-input { cursor: pointer; } /* ----------------------------------------------------------------- - 4.8 Popup Comments + 4.8 Popup Photo and Comments ----------------------------------------------------------------- */ + +/* Photo Toggle Button */ +.popup-photo-toggle { + margin: var(--space-sm) 0; +} + +.popup-photo-btn { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 4px 12px; + border: 1px solid var(--color-border); + border-radius: 16px; + background: var(--color-surface); + cursor: pointer; + font-size: 0.78rem; + color: var(--color-text-secondary); + font-family: var(--font-body); + transition: all var(--transition-fast); +} + +.popup-photo-btn:hover { + border-color: var(--color-primary); + color: var(--color-primary); +} + +/* Photo Container */ +.popup-photo-container { margin-bottom: var(--space-sm); } + +.popup-photo-img { + max-width: 100%; + max-height: 180px; + object-fit: cover; + border-radius: 6px; + cursor: pointer; + border: 1px solid var(--color-border); +} + +/* Comments Section */ .popup-comments { margin-top: var(--space-sm); padding-top: var(--space-sm); @@ -642,12 +681,26 @@ select.form-input { cursor: pointer; } font-size: 0.8rem; font-weight: 600; color: var(--color-text-secondary); - margin-bottom: var(--space-sm); + cursor: pointer; + display: flex; + align-items: center; + gap: 4px; + padding: 4px 0; + transition: color var(--transition-fast); +} + +.popup-comments-header:hover { color: var(--color-primary); } + +.popup-comments-toggle { + font-size: 0.65rem; + margin-left: auto; + transition: transform 200ms ease; } .popup-comments-list { max-height: 150px; overflow-y: auto; + margin-top: var(--space-sm); } .popup-comment { @@ -669,10 +722,7 @@ select.form-input { cursor: pointer; } line-height: 1.4; } -.popup-comment-delete { - color: var(--color-error); - font-size: 0.7rem; -} +.popup-comment-delete { color: var(--color-error); font-size: 0.7rem; } .popup-comment-empty { font-size: 0.8rem; @@ -697,9 +747,7 @@ select.form-input { cursor: pointer; } outline: none; } -.popup-comment-input:focus { - border-color: var(--color-primary); -} +.popup-comment-input:focus { border-color: var(--color-primary); } .popup-comment-submit { border: none;