From a2b5f929dddd7bea8300e29cd8674b94b9b76285 Mon Sep 17 00:00:00 2001 From: Sli Date: Sat, 10 Aug 2024 14:49:02 +0200 Subject: [PATCH] Apply review comments * Add alpine intersect * Move alpine and it's plugins to a folder * Fix spinning wheel position * Improve album title position --- .../core/js/{ => alpine}/alpinejs.min.js | 0 core/static/core/js/alpine/intersect.min.js | 1 + core/templates/core/base.jinja | 2 +- core/templates/core/user_pictures.jinja | 61 ++++++++++--------- 4 files changed, 34 insertions(+), 30 deletions(-) rename core/static/core/js/{ => alpine}/alpinejs.min.js (100%) create mode 100644 core/static/core/js/alpine/intersect.min.js diff --git a/core/static/core/js/alpinejs.min.js b/core/static/core/js/alpine/alpinejs.min.js similarity index 100% rename from core/static/core/js/alpinejs.min.js rename to core/static/core/js/alpine/alpinejs.min.js diff --git a/core/static/core/js/alpine/intersect.min.js b/core/static/core/js/alpine/intersect.min.js new file mode 100644 index 00000000..2342257f --- /dev/null +++ b/core/static/core/js/alpine/intersect.min.js @@ -0,0 +1 @@ +(()=>{function o(e){e.directive("intersect",e.skipDuringClone((t,{value:i,expression:l,modifiers:n},{evaluateLater:r,cleanup:c})=>{let s=r(l),a={rootMargin:x(n),threshold:f(n)},u=new IntersectionObserver(d=>{d.forEach(h=>{h.isIntersecting!==(i==="leave")&&(s(),n.includes("once")&&u.disconnect())})},a);u.observe(t),c(()=>{u.disconnect()})}))}function f(e){if(e.includes("full"))return .99;if(e.includes("half"))return .5;if(!e.includes("threshold"))return 0;let t=e[e.indexOf("threshold")+1];return t==="100"?1:t==="0"?0:Number(`.${t}`)}function p(e){let t=e.match(/^(-?[0-9]+)(px|%)?$/);return t?t[1]+(t[2]||"px"):void 0}function x(e){let t="margin",i="0px 0px 0px 0px",l=e.indexOf(t);if(l===-1)return i;let n=[];for(let r=1;r<5;r++)n.push(p(e[l+r]||""));return n=n.filter(r=>r!==void 0),n.length?n.join(" ").trim():i}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(o)});})(); diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 22b1ef7d..1704c08e 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -29,7 +29,7 @@ {% block additional_js %}{% endblock %} {# Alpine JS must be loaded after scripts that use it. #} - + {% endblock %} diff --git a/core/templates/core/user_pictures.jinja b/core/templates/core/user_pictures.jinja index 554604e0..bbcb4eb7 100644 --- a/core/templates/core/user_pictures.jinja +++ b/core/templates/core/user_pictures.jinja @@ -10,6 +10,7 @@ window.showSaveFilePicker = showSaveFilePicker; /* Export function to normal javascript */ + {% endblock %} {% block title %} @@ -17,48 +18,50 @@ {% endblock %} {% block content %} -
+
{% if user.id == object.id %}
- +
{% endif %} -