From dc07e1f650f962b826491d052f993f9617e6129a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sn=C3=ADda=C5=88ov=C3=BD=20Mistr?= Date: Mon, 19 Feb 2024 18:02:41 +0100 Subject: [PATCH] =?UTF-8?q?Vylep=C5=A1en=C3=AD=20JS=20na=20otv=C3=ADr?= =?UTF-8?q?=C3=A1n=C3=AD=20obr=C3=A1zk=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/expand-image.js | 88 +++++++++++++++++-------------- static/style.css | 16 ++++-- templates/base.html | 1 + templates/macros/post-form.html | 8 ++- templates/macros/post.html | 4 +- templates/staff/board-config.html | 16 +++--- templates/staff/permissions.html | 34 ++++++------ templates/thread.html | 1 + 8 files changed, 95 insertions(+), 73 deletions(-) diff --git a/static/js/expand-image.js b/static/js/expand-image.js index 677265c..3463ec0 100644 --- a/static/js/expand-image.js +++ b/static/js/expand-image.js @@ -19,32 +19,32 @@ $(function () { }); function toggle_image(parent, src_link) { - let expanded = parent.hasClass("expanded"); let thumb = parent.find(".thumb"); let src = parent.find(".src"); - if (!expanded) { - if (src.length === 0) { - thumb.css("opacity", 0.5); - parent.append(``); - - let src = parent.find(".src"); - - src.hide(); + if (src.length === 0) { + thumb.addClass("loading"); - src.on("load", function () { - thumb.hide(); - thumb.css("opacity", ""); - src.show(); - }); - } else { + parent.append(``); + + let src = parent.find(".src"); + + src.hide(); + src.on("load", function () { + thumb.removeClass("loading"); thumb.hide(); src.show(); - } - } else { - src.hide(); - thumb.show(); + + parent.closest(".post-files").addClass("float-none-b"); + }); + + return; } + + thumb.toggle(); + src.toggle(); + + parent.closest(".post-files").toggleClass("float-none-b"); } function toggle_video(parent, src_link) { @@ -52,35 +52,41 @@ function toggle_video(parent, src_link) { let thumb = parent.find(".thumb"); let src = parent.parent().find(".src"); - if (!expanded) { - if (src.length === 0) { - thumb.css("opacity", 0.5); + if (src.length === 0) { + thumb.addClass("loading"); - parent.append('[Zavřít]
') - - parent.parent().append( + parent.append('[Zavřít]
'); + parent + .parent() + .append( `` ); - let src = parent.parent().find(".src"); + let src = parent.parent().find(".src"); - src.hide(); + src.hide(); - src.on("loadstart", function () { - thumb.hide(); - thumb.css("opacity", ""); - src.show(); - }); - } else { + src.on("loadstart", function () { + thumb.removeClass("loading"); thumb.hide(); src.show(); - src.get(0).play(); - parent.find(".closer").show(); - } - } else { - src.get(0).pause(); - src.hide(); - thumb.show(); - parent.find(".closer").hide(); + + parent.closest(".post-files").addClass("float-none-b"); + }); + + return; } + + thumb.toggle(); + src.toggle(); + + if (expanded) { + src.get(0).pause(); + src.get(0).currentTime = 0; + } else { + src.get(0).play(); + } + + parent.closest(".post-files").toggleClass("float-none-b"); + parent.find(".closer").toggle(); } diff --git a/static/style.css b/static/style.css index e4f6dc0..949f00d 100755 --- a/static/style.css +++ b/static/style.css @@ -208,6 +208,11 @@ summary { float: right; } +.float-none-a, +.float-none-b { + float: none !important; +} + .fixed-table { table-layout: fixed; } @@ -301,6 +306,7 @@ summary { } .post-header input[type="checkbox"] { + height: 1em; vertical-align: middle; margin: 0; } @@ -354,10 +360,6 @@ summary { margin: 0 8px 8px 8px; } -.multi-files { - float: none; -} - .post-file { display: inline-block; vertical-align: top; @@ -472,3 +474,9 @@ summary { height: 220px; } } + +/* Only in JS */ + +.loading { + opacity: 0.5; +} diff --git a/templates/base.html b/templates/base.html index f07728c..a6a7bd4 100755 --- a/templates/base.html +++ b/templates/base.html @@ -11,6 +11,7 @@ + {% block scripts %}{% endblock %}