2024-02-18 19:25:38 +00:00
|
|
|
$(function () {
|
|
|
|
$(".expandable").click(function () {
|
|
|
|
let src_link = $(this).attr("href");
|
|
|
|
|
|
|
|
let is_video = [".mpeg", ".mov", ".mp4", ".webm", ".mkv", ".ogg"].some(
|
|
|
|
(ext) => src_link.endsWith(ext)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!is_video) {
|
|
|
|
toggle_image($(this), src_link);
|
|
|
|
} else {
|
|
|
|
toggle_video($(this), src_link);
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).toggleClass("expanded");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function toggle_image(parent, src_link) {
|
|
|
|
let thumb = parent.find(".thumb");
|
|
|
|
let src = parent.find(".src");
|
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
if (src.length === 0) {
|
|
|
|
thumb.addClass("loading");
|
|
|
|
|
|
|
|
parent.append(`<img class="src" src="${src_link}">`);
|
|
|
|
|
|
|
|
let src = parent.find(".src");
|
|
|
|
|
|
|
|
src.hide();
|
|
|
|
src.on("load", function () {
|
|
|
|
thumb.removeClass("loading");
|
2024-02-18 19:25:38 +00:00
|
|
|
thumb.hide();
|
|
|
|
src.show();
|
2024-02-19 17:02:41 +00:00
|
|
|
|
|
|
|
parent.closest(".post-files").addClass("float-none-b");
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
2024-02-18 19:25:38 +00:00
|
|
|
}
|
2024-02-19 17:02:41 +00:00
|
|
|
|
|
|
|
thumb.toggle();
|
|
|
|
src.toggle();
|
|
|
|
|
|
|
|
parent.closest(".post-files").toggleClass("float-none-b");
|
2024-02-18 19:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_video(parent, src_link) {
|
|
|
|
let expanded = parent.hasClass("expanded");
|
|
|
|
let thumb = parent.find(".thumb");
|
|
|
|
let src = parent.parent().find(".src");
|
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
if (src.length === 0) {
|
|
|
|
thumb.addClass("loading");
|
2024-02-18 19:25:38 +00:00
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
parent.append('<b class="closer">[Zavřít]<br></b>');
|
|
|
|
parent
|
|
|
|
.parent()
|
|
|
|
.append(
|
2024-02-18 19:25:38 +00:00
|
|
|
`<video class="src" src="${src_link}" autoplay="" controls="" loop=""></video>`
|
|
|
|
);
|
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
let src = parent.parent().find(".src");
|
2024-02-18 19:25:38 +00:00
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
src.hide();
|
2024-02-18 19:25:38 +00:00
|
|
|
|
2024-02-19 17:02:41 +00:00
|
|
|
src.on("loadstart", function () {
|
|
|
|
thumb.removeClass("loading");
|
2024-02-18 19:25:38 +00:00
|
|
|
thumb.hide();
|
|
|
|
src.show();
|
2024-02-19 17:02:41 +00:00
|
|
|
|
|
|
|
parent.closest(".post-files").addClass("float-none-b");
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
thumb.toggle();
|
|
|
|
src.toggle();
|
|
|
|
|
|
|
|
if (expanded) {
|
2024-02-18 19:25:38 +00:00
|
|
|
src.get(0).pause();
|
2024-02-19 17:02:41 +00:00
|
|
|
src.get(0).currentTime = 0;
|
|
|
|
} else {
|
|
|
|
src.get(0).play();
|
2024-02-18 19:25:38 +00:00
|
|
|
}
|
2024-02-19 17:02:41 +00:00
|
|
|
|
|
|
|
parent.closest(".post-files").toggleClass("float-none-b");
|
|
|
|
parent.find(".closer").toggle();
|
2024-02-18 19:25:38 +00:00
|
|
|
}
|