diff --git a/app/static/js/scripts.js b/app/static/js/scripts.js index bf37ada2..5b209193 100644 --- a/app/static/js/scripts.js +++ b/app/static/js/scripts.js @@ -3,6 +3,7 @@ document.addEventListener("DOMContentLoaded", function () { setupCommunityNameInput(); setupShowMoreLinks(); setupConfirmFirst(); + setupImageExpander(); setupSubmitOnInputChange(); setupTimeTracking(); setupMobileNav(); @@ -52,6 +53,38 @@ function setupAutoResize(element) { } +function setupImageExpander() { + // Get all elements with the class "preview_image" + var imageLinks = document.querySelectorAll('.preview_image'); + + // Loop through each element and attach a click event listener + imageLinks.forEach(function(link) { + link.addEventListener('click', function(event) { + event.preventDefault(); // Prevent the default behavior of the anchor link + + // Check if the image is already visible + var image = this.nextElementSibling; // Assumes the image is always the next sibling + var isImageVisible = image && image.style.display !== 'none'; + + // Toggle the visibility of the image + if (isImageVisible) { + image.remove(); // Remove the image from the DOM + } else { + image = document.createElement('img'); + image.src = this.href; // Set the image source to the href of the anchor link + image.alt = 'Image'; // Set the alt attribute for accessibility + image.className = 'preview_image_shown'; + + // Insert the image after the anchor link + this.parentNode.insertBefore(image, this.nextSibling); + } + + // Toggle a class on the anchor to indicate whether the image is being shown or not + this.classList.toggle('imageVisible', !isImageVisible); + }); + }); +} + function collapseReply(comment_id) { const reply = document.getElementById('comment_' + comment_id); let isHidden = false; diff --git a/app/static/scss/_typography.scss b/app/static/scss/_typography.scss index e10639e2..8ec6a69c 100644 --- a/app/static/scss/_typography.scss +++ b/app/static/scss/_typography.scss @@ -206,6 +206,21 @@ content: "\e91e"; } +.fe-magnify { + position: relative; + top: 1px; +} + +.fe-magnify::before { + content: "\ea08"; +} + +.imageVisible { + .fe-magnify::before { + content: "\ea09"; + } +} + .fe-rss::before { content: "\e9be"; } diff --git a/app/static/structure.css b/app/static/structure.css index 794a9148..cec44fe9 100644 --- a/app/static/structure.css +++ b/app/static/structure.css @@ -234,6 +234,19 @@ nav, etc which are used site-wide */ content: "\e91e"; } +.fe-magnify { + position: relative; + top: 1px; +} + +.fe-magnify::before { + content: "\ea08"; +} + +.imageVisible .fe-magnify::before { + content: "\ea09"; +} + .fe-rss::before { content: "\e9be"; } @@ -731,4 +744,11 @@ fieldset legend { float: right; } +.preview_image_shown { + z-index: 1; + position: relative; + max-width: 92vw; + height: auto; +} + /*# sourceMappingURL=structure.css.map */ diff --git a/app/static/structure.scss b/app/static/structure.scss index a3dbfdb4..7baaff45 100644 --- a/app/static/structure.scss +++ b/app/static/structure.scss @@ -436,4 +436,11 @@ fieldset { .profile_action_buttons { float: right; -} \ No newline at end of file +} + +.preview_image_shown { + z-index: 1; + position: relative; + max-width: 92vw; + height: auto; +} diff --git a/app/static/styles.css b/app/static/styles.css index 78ebafbd..a1fa418a 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -233,6 +233,19 @@ content: "\e91e"; } +.fe-magnify { + position: relative; + top: 1px; +} + +.fe-magnify::before { + content: "\ea08"; +} + +.imageVisible .fe-magnify::before { + content: "\ea09"; +} + .fe-rss::before { content: "\e9be"; } diff --git a/app/templates/admin/site.html b/app/templates/admin/site.html index c8f484ef..c12dcd50 100644 --- a/app/templates/admin/site.html +++ b/app/templates/admin/site.html @@ -17,7 +17,9 @@ {{ render_field(form.description) }} {{ render_field(form.icon) }} {{ render_field(form.sidebar) }} +
HTML is allowed in this field.
{{ render_field(form.legal_information) }} +HTML is allowed in this field.
{{ render_field(form.submit) }} diff --git a/app/templates/base.html b/app/templates/base.html index 894c9089..1cd778e7 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -44,7 +44,7 @@ {% endif %} {% endblock %} -