2022-01-14 00:46:54 +01:00
|
|
|
import panzoom from "@panzoom/panzoom";
|
2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-06-13 05:55:50 +02:00
|
|
|
import render_lightbox_overlay from "../templates/lightbox_overlay.hbs";
|
|
|
|
|
2021-03-16 23:38:59 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
2021-02-28 01:10:03 +01:00
|
|
|
import * as message_store from "./message_store";
|
2021-02-28 01:03:46 +01:00
|
|
|
import * as overlays from "./overlays";
|
2021-02-28 00:58:23 +01:00
|
|
|
import * as people from "./people";
|
2021-02-28 01:03:09 +01:00
|
|
|
import * as popovers from "./popovers";
|
2021-02-28 00:58:23 +01:00
|
|
|
import * as rows from "./rows";
|
2020-08-20 21:24:06 +02:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
let is_open = false;
|
2017-03-20 19:37:23 +01:00
|
|
|
// the asset map is a map of all retrieved images and YouTube videos that are
|
|
|
|
// memoized instead of being looked up multiple times.
|
2020-02-12 10:56:06 +01:00
|
|
|
const asset_map = new Map();
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2022-01-14 00:46:54 +01:00
|
|
|
export class PanZoomControl {
|
|
|
|
// Class for both initializing and controlling the
|
|
|
|
// the pan/zoom functionality.
|
|
|
|
constructor(container) {
|
|
|
|
this.container = container;
|
|
|
|
this.panzoom = panzoom(this.container, {
|
|
|
|
disablePan: true,
|
|
|
|
disableZoom: true,
|
|
|
|
cursor: "auto",
|
|
|
|
});
|
|
|
|
|
|
|
|
// keybinds
|
|
|
|
document.addEventListener("keydown", (e) => {
|
|
|
|
if (!overlays.lightbox_open()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (e.key) {
|
|
|
|
case "Z":
|
|
|
|
case "+":
|
|
|
|
this.zoomIn();
|
|
|
|
break;
|
|
|
|
case "z":
|
|
|
|
case "-":
|
|
|
|
this.zoomOut();
|
|
|
|
break;
|
|
|
|
case "v":
|
|
|
|
overlays.close_overlay("lightbox");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
this.panzoom.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
disablePanZoom() {
|
|
|
|
this.container.removeEventListener("wheel", this.panzoom.zoomWithWheel);
|
|
|
|
this.panzoom.setOptions({disableZoom: true, disablePan: true, cursor: "auto"});
|
|
|
|
this.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
enablePanZoom() {
|
|
|
|
this.panzoom.setOptions({disableZoom: false, disablePan: false, cursor: "move"});
|
|
|
|
this.container.addEventListener("wheel", this.panzoom.zoomWithWheel);
|
|
|
|
}
|
|
|
|
|
|
|
|
zoomIn() {
|
|
|
|
this.panzoom.zoomIn();
|
|
|
|
}
|
|
|
|
|
|
|
|
zoomOut() {
|
|
|
|
this.panzoom.zoomOut();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-14 13:26:24 +01:00
|
|
|
export function clear_for_testing() {
|
|
|
|
is_open = false;
|
|
|
|
asset_map.clear();
|
|
|
|
}
|
|
|
|
|
2021-02-28 00:58:23 +01:00
|
|
|
export function render_lightbox_list_images(preview_source) {
|
2017-03-19 01:51:20 +01:00
|
|
|
if (!is_open) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));
|
|
|
|
const $image_list = $("#lightbox_overlay .image-list").html("");
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2021-01-22 22:29:08 +01:00
|
|
|
for (const img of images) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const src = img.getAttribute("src");
|
|
|
|
const className = preview_source === src ? "image selected" : "image";
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const node = $("<div></div>", {
|
2017-03-19 01:51:20 +01:00
|
|
|
class: className,
|
|
|
|
"data-src": src,
|
2020-07-16 22:40:18 +02:00
|
|
|
}).css({backgroundImage: "url(" + src + ")"});
|
2017-03-19 01:51:20 +01:00
|
|
|
|
|
|
|
$image_list.append(node);
|
2020-04-02 15:52:33 +02:00
|
|
|
|
|
|
|
// We parse the data for each image to show in the list,
|
|
|
|
// while we still have its original DOM element handy, so
|
|
|
|
// that navigating within the list only needs the `src`
|
|
|
|
// attribute used to construct the node object above.
|
2021-02-28 00:58:23 +01:00
|
|
|
parse_image_data(img);
|
2021-01-22 22:29:08 +01:00
|
|
|
}
|
2017-03-19 01:51:20 +01:00
|
|
|
}
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2020-04-02 16:37:21 +02:00
|
|
|
function display_image(payload) {
|
2021-02-28 00:58:23 +01:00
|
|
|
render_lightbox_list_images(payload.preview);
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2017-03-20 19:37:23 +01:00
|
|
|
$(".player-container").hide();
|
2017-06-08 22:58:15 +02:00
|
|
|
$(".image-actions, .image-description, .download, .lightbox-canvas-trigger").show();
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2022-01-14 00:46:54 +01:00
|
|
|
const img_container = $("#lightbox_overlay .image-preview > .zoom-element");
|
|
|
|
const img = new Image();
|
|
|
|
img.src = payload.source;
|
|
|
|
img_container.html(img).show();
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2017-03-20 19:37:23 +01:00
|
|
|
$(".image-description .title").text(payload.title || "N/A");
|
|
|
|
$(".image-description .user").text(payload.user);
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2017-03-20 19:37:23 +01:00
|
|
|
$(".image-actions .open, .image-actions .download").attr("href", payload.source);
|
2017-03-18 00:50:39 +01:00
|
|
|
}
|
|
|
|
|
2017-12-14 22:17:00 +01:00
|
|
|
function display_video(payload) {
|
2021-02-28 00:58:23 +01:00
|
|
|
render_lightbox_list_images(payload.preview);
|
2017-03-20 19:37:23 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
$(
|
|
|
|
"#lightbox_overlay .image-preview, .image-description, .download, .lightbox-canvas-trigger",
|
|
|
|
).hide();
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
let source;
|
2021-05-09 23:36:58 +02:00
|
|
|
switch (payload.type) {
|
|
|
|
case "youtube-video":
|
|
|
|
source = "https://www.youtube.com/embed/" + payload.source;
|
|
|
|
break;
|
|
|
|
case "vimeo-video":
|
|
|
|
source = "https://player.vimeo.com/video/" + payload.source;
|
|
|
|
break;
|
|
|
|
case "embed-video":
|
|
|
|
// Use data: to load the player in a unique origin for security.
|
|
|
|
source =
|
|
|
|
"data:text/html," +
|
|
|
|
window.encodeURIComponent(
|
|
|
|
"<!DOCTYPE html><style>iframe{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box}</style>" +
|
|
|
|
payload.source,
|
|
|
|
);
|
|
|
|
break;
|
2017-12-14 22:17:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-12 08:30:12 +01:00
|
|
|
const iframe = $("<iframe></iframe>");
|
2020-07-15 00:34:28 +02:00
|
|
|
iframe.attr(
|
|
|
|
"sandbox",
|
|
|
|
"allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",
|
|
|
|
);
|
2019-05-22 01:16:46 +02:00
|
|
|
iframe.attr("src", source);
|
|
|
|
iframe.attr("frameborder", 0);
|
|
|
|
iframe.attr("allowfullscreen", true);
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2017-03-20 19:37:23 +01:00
|
|
|
$("#lightbox_overlay .player-container").html(iframe).show();
|
2019-05-21 17:36:39 +02:00
|
|
|
$(".image-actions .open").attr("href", payload.url);
|
2017-03-18 00:50:39 +01:00
|
|
|
}
|
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
export function build_open_image_function(on_close) {
|
|
|
|
if (on_close === undefined) {
|
|
|
|
on_close = function () {
|
|
|
|
$(".player-container iframe").remove();
|
|
|
|
is_open = false;
|
|
|
|
document.activeElement.blur();
|
|
|
|
};
|
2017-09-10 08:56:29 +02:00
|
|
|
}
|
2017-03-20 19:37:23 +01:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
return function ($image) {
|
|
|
|
// if the asset_map already contains the metadata required to display the
|
|
|
|
// asset, just recall that metadata.
|
|
|
|
let $preview_src = $image.attr("src");
|
|
|
|
let payload = asset_map.get($preview_src);
|
|
|
|
if (payload === undefined) {
|
|
|
|
if ($preview_src.endsWith("&size=full")) {
|
|
|
|
// while fetching an image for canvas, `src` attribute supplies
|
|
|
|
// full-sized image instead of thumbnail, so we have to replace
|
|
|
|
// `size=full` with `size=thumbnail`.
|
|
|
|
//
|
|
|
|
// TODO: This is a hack to work around the fact that for
|
|
|
|
// the lightbox canvas, the `src` is the data-fullsize-src
|
|
|
|
// for the image, not the original thumbnail used to open
|
|
|
|
// the lightbox. A better fix will be to check a
|
|
|
|
// `data-thumbnail-src` attribute that we add to the
|
|
|
|
// canvas elements.
|
|
|
|
$preview_src = $preview_src.replace(/.{4}$/, "thumbnail");
|
|
|
|
payload = asset_map.get($preview_src);
|
|
|
|
}
|
|
|
|
if (payload === undefined) {
|
|
|
|
payload = parse_image_data($image);
|
|
|
|
}
|
|
|
|
}
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
if (payload.type.match("-video")) {
|
|
|
|
display_video(payload);
|
|
|
|
} else if (payload.type === "image") {
|
|
|
|
display_image(payload);
|
|
|
|
}
|
2017-05-10 15:27:31 +02:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
if (is_open) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-06 00:57:14 +02:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
overlays.open_overlay({
|
|
|
|
name: "lightbox",
|
|
|
|
overlay: $("#lightbox_overlay"),
|
|
|
|
on_close,
|
|
|
|
});
|
2017-05-06 00:57:14 +02:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
popovers.hide_all();
|
|
|
|
is_open = true;
|
|
|
|
};
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2017-03-18 00:50:39 +01:00
|
|
|
|
2021-02-28 00:58:23 +01:00
|
|
|
export function show_from_selected_message() {
|
2019-11-02 00:06:25 +01:00
|
|
|
const $message_selected = $(".selected_message");
|
|
|
|
let $message = $message_selected;
|
|
|
|
let $image = $message.find(".message_inline_image img");
|
|
|
|
let $prev_traverse = false;
|
2017-05-22 19:44:53 +02:00
|
|
|
|
|
|
|
while ($image.length === 0) {
|
2017-12-10 20:47:38 +01:00
|
|
|
if ($message.prev().length === 0) {
|
|
|
|
$message = $message.parent().prev();
|
|
|
|
if ($message.length === 0) {
|
|
|
|
$prev_traverse = true;
|
|
|
|
$message = $message_selected;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
$message = $message.find(".last_message");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 19:44:53 +02:00
|
|
|
$message = $message.prev();
|
2017-12-10 20:47:38 +01:00
|
|
|
$image = $message.find(".message_inline_image img");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($prev_traverse) {
|
|
|
|
while ($image.length === 0) {
|
|
|
|
if ($message.next().length === 0) {
|
|
|
|
$message = $message.parent().next();
|
|
|
|
if ($message.length === 0) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
$message = $message.children().first();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$message = $message.next();
|
|
|
|
$image = $message.find(".message_inline_image img");
|
2017-05-22 19:44:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($image.length !== 0) {
|
2022-01-23 21:29:09 +01:00
|
|
|
const open_image = build_open_image_function();
|
|
|
|
open_image($image);
|
2017-03-18 21:01:16 +01:00
|
|
|
}
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2017-03-18 21:01:16 +01:00
|
|
|
|
2020-04-02 13:17:18 +02:00
|
|
|
// retrieve the metadata from the DOM and store into the asset_map.
|
2021-02-28 00:58:23 +01:00
|
|
|
export function parse_image_data(image) {
|
2020-04-02 15:52:33 +02:00
|
|
|
const $image = $(image);
|
2020-04-02 15:07:30 +02:00
|
|
|
const $preview_src = $image.attr("src");
|
2020-04-02 15:52:33 +02:00
|
|
|
|
|
|
|
if (asset_map.has($preview_src)) {
|
|
|
|
// check if image's data is already present in asset_map.
|
2020-09-24 07:50:36 +02:00
|
|
|
return asset_map.get($preview_src);
|
2020-04-02 15:52:33 +02:00
|
|
|
}
|
|
|
|
|
2020-04-02 13:17:18 +02:00
|
|
|
// if wrapped in the .youtube-video class, it will be length = 1, and therefore
|
|
|
|
// cast to true.
|
2020-10-07 12:54:16 +02:00
|
|
|
const is_youtube_video = Boolean($image.closest(".youtube-video").length);
|
|
|
|
const is_vimeo_video = Boolean($image.closest(".vimeo-video").length);
|
|
|
|
const is_embed_video = Boolean($image.closest(".embed-video").length);
|
2020-04-02 13:17:18 +02:00
|
|
|
|
2021-04-20 19:50:01 +02:00
|
|
|
// check if image is descendent of #compose .preview_content
|
|
|
|
const is_compose_preview_image = $image.closest("#compose .preview_content").length === 1;
|
2020-04-02 13:17:18 +02:00
|
|
|
|
|
|
|
const $parent = $image.parent();
|
|
|
|
let $type;
|
|
|
|
let $source;
|
|
|
|
const $url = $parent.attr("href");
|
|
|
|
if (is_youtube_video) {
|
|
|
|
$type = "youtube-video";
|
|
|
|
$source = $parent.attr("data-id");
|
|
|
|
} else if (is_vimeo_video) {
|
|
|
|
$type = "vimeo-video";
|
|
|
|
$source = $parent.attr("data-id");
|
|
|
|
} else if (is_embed_video) {
|
|
|
|
$type = "embed-video";
|
|
|
|
$source = $parent.attr("data-id");
|
|
|
|
} else {
|
|
|
|
$type = "image";
|
|
|
|
if ($image.attr("data-src-fullsize")) {
|
|
|
|
$source = $image.attr("data-src-fullsize");
|
|
|
|
} else {
|
2020-04-02 15:07:30 +02:00
|
|
|
$source = $preview_src;
|
2020-04-02 13:17:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
let sender_full_name;
|
|
|
|
if (is_compose_preview_image) {
|
|
|
|
sender_full_name = people.my_full_name();
|
|
|
|
} else {
|
|
|
|
const $message = $parent.closest("[zid]");
|
|
|
|
const zid = rows.id($message);
|
|
|
|
const message = message_store.get(zid);
|
|
|
|
if (message === undefined) {
|
|
|
|
blueslip.error("Lightbox for unknown message " + zid);
|
|
|
|
} else {
|
|
|
|
sender_full_name = message.sender_full_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const payload = {
|
|
|
|
user: sender_full_name,
|
|
|
|
title: $parent.attr("title"),
|
|
|
|
type: $type,
|
2020-04-02 15:07:30 +02:00
|
|
|
preview: $preview_src,
|
2020-04-02 13:17:18 +02:00
|
|
|
source: $source,
|
|
|
|
url: $url,
|
|
|
|
};
|
|
|
|
|
2020-04-02 15:07:30 +02:00
|
|
|
asset_map.set($preview_src, payload);
|
2020-04-02 13:17:18 +02:00
|
|
|
return payload;
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2020-04-02 13:17:18 +02:00
|
|
|
|
2021-02-28 00:58:23 +01:00
|
|
|
export function prev() {
|
2020-07-20 21:24:26 +02:00
|
|
|
$(".image-list .image.selected").prev().trigger("click");
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2021-02-28 00:58:23 +01:00
|
|
|
export function next() {
|
2020-07-20 21:24:26 +02:00
|
|
|
$(".image-list .image.selected").next().trigger("click");
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|
2017-03-19 01:51:20 +01:00
|
|
|
|
2017-03-20 19:36:32 +01:00
|
|
|
// this is a block of events that are required for the lightbox to work.
|
2021-02-28 00:58:23 +01:00
|
|
|
export function initialize() {
|
2022-01-14 00:46:54 +01:00
|
|
|
// Renders the DOM for the lightbox.
|
2021-06-13 05:55:50 +02:00
|
|
|
const rendered_lightbox_overlay = render_lightbox_overlay();
|
|
|
|
$("body").append(rendered_lightbox_overlay);
|
|
|
|
|
2022-01-14 00:46:54 +01:00
|
|
|
// Bind the pan/zoom control the newly created element.
|
|
|
|
const pan_zoom_control = new PanZoomControl(
|
|
|
|
$("#lightbox_overlay .image-preview > .zoom-element")[0],
|
|
|
|
);
|
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
const reset_lightbox_state = function () {
|
|
|
|
$(".player-container iframe").remove();
|
|
|
|
is_open = false;
|
|
|
|
document.activeElement.blur();
|
|
|
|
pan_zoom_control.disablePanZoom();
|
|
|
|
$(".lightbox-canvas-trigger").removeClass("enabled");
|
|
|
|
};
|
|
|
|
|
|
|
|
const open_image = build_open_image_function(reset_lightbox_state);
|
|
|
|
|
2021-04-20 19:50:01 +02:00
|
|
|
$("#main_div, #compose .preview_content").on("click", ".message_inline_image a", function (e) {
|
2017-03-20 19:36:32 +01:00
|
|
|
// prevent the link from opening in a new page.
|
|
|
|
e.preventDefault();
|
|
|
|
// prevent the message compose dialog from happening.
|
|
|
|
e.stopPropagation();
|
2019-11-02 00:06:25 +01:00
|
|
|
const $img = $(this).find("img");
|
2022-01-23 21:29:09 +01:00
|
|
|
open_image($img);
|
2017-03-20 19:36:32 +01:00
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#lightbox_overlay .download").on("click", function () {
|
2018-05-06 21:43:17 +02:00
|
|
|
this.blur();
|
2017-03-20 19:36:32 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#lightbox_overlay").on("click", ".image-list .image", function () {
|
2019-11-02 00:06:25 +01:00
|
|
|
const $image_list = $(this).parent();
|
2021-02-03 23:23:32 +01:00
|
|
|
const $original_image = $(
|
|
|
|
`.message_row img[src='${CSS.escape($(this).attr("data-src"))}']`,
|
|
|
|
);
|
2017-03-20 19:36:32 +01:00
|
|
|
|
2022-01-23 21:29:09 +01:00
|
|
|
open_image($original_image);
|
2017-03-20 19:36:32 +01:00
|
|
|
|
|
|
|
$(".image-list .image.selected").removeClass("selected");
|
|
|
|
$(this).addClass("selected");
|
2022-01-14 00:46:54 +01:00
|
|
|
pan_zoom_control.reset();
|
2017-03-20 19:36:32 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const parentOffset = this.parentNode.clientWidth + this.parentNode.scrollLeft;
|
2017-03-20 19:36:32 +01:00
|
|
|
// this is the left and right of the image compared to its parent.
|
2019-11-02 00:06:25 +01:00
|
|
|
const coords = {
|
2017-03-20 19:36:32 +01:00
|
|
|
left: this.offsetLeft,
|
|
|
|
right: this.offsetLeft + this.clientWidth,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (coords.right > parentOffset) {
|
|
|
|
// add 2px margin
|
2020-07-15 00:34:28 +02:00
|
|
|
$image_list.animate(
|
|
|
|
{
|
|
|
|
scrollLeft: coords.right - this.parentNode.clientWidth + 2,
|
|
|
|
},
|
|
|
|
100,
|
|
|
|
);
|
2017-03-20 19:36:32 +01:00
|
|
|
} else if (coords.left < this.parentNode.scrollLeft) {
|
|
|
|
// subtract 2px margin
|
2020-07-16 22:40:18 +02:00
|
|
|
$image_list.animate({scrollLeft: coords.left - 2}, 100);
|
2017-03-20 19:36:32 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#lightbox_overlay").on("click", ".center .arrow", function () {
|
2019-11-02 00:06:25 +01:00
|
|
|
const direction = $(this).attr("data-direction");
|
2017-03-20 19:36:32 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
if (direction === "next") {
|
2021-02-28 00:58:23 +01:00
|
|
|
next();
|
2020-07-15 01:29:15 +02:00
|
|
|
} else if (direction === "prev") {
|
2021-02-28 00:58:23 +01:00
|
|
|
prev();
|
2017-03-20 19:36:32 +01:00
|
|
|
}
|
|
|
|
});
|
2017-03-18 22:47:13 +01:00
|
|
|
|
2017-06-08 22:58:15 +02:00
|
|
|
$("#lightbox_overlay").on("click", ".lightbox-canvas-trigger", function () {
|
2022-01-14 00:46:54 +01:00
|
|
|
const $img = $("#lightbox_overlay").find(".image-preview img");
|
2022-01-23 21:29:09 +01:00
|
|
|
open_image($img);
|
2017-06-08 22:58:15 +02:00
|
|
|
|
2022-01-14 00:46:54 +01:00
|
|
|
if ($(this).hasClass("enabled")) {
|
|
|
|
pan_zoom_control.disablePanZoom();
|
2017-06-08 22:58:15 +02:00
|
|
|
$(this).removeClass("enabled");
|
2022-01-14 00:46:54 +01:00
|
|
|
} else {
|
|
|
|
pan_zoom_control.enablePanZoom();
|
|
|
|
$(this).addClass("enabled");
|
2017-06-08 22:58:15 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$("#lightbox_overlay .image-preview").on("dblclick", "img, canvas", (e) => {
|
2020-07-20 21:24:26 +02:00
|
|
|
$("#lightbox_overlay .lightbox-canvas-trigger").trigger("click");
|
2017-06-08 22:58:15 +02:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
2017-08-01 18:21:55 +02:00
|
|
|
|
|
|
|
$("#lightbox_overlay .player-container").on("click", function () {
|
|
|
|
if ($(this).is(".player-container")) {
|
2022-01-23 21:29:09 +01:00
|
|
|
reset_lightbox_state();
|
2017-08-01 18:21:55 +02:00
|
|
|
overlays.close_active();
|
|
|
|
}
|
|
|
|
});
|
2017-11-29 19:19:44 +01:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$("#lightbox_overlay").on("click", ".image-info-wrapper, .center", (e) => {
|
2017-11-29 19:19:44 +01:00
|
|
|
if ($(e.target).is(".image-info-wrapper, .center")) {
|
2022-01-23 21:29:09 +01:00
|
|
|
reset_lightbox_state();
|
2017-11-29 19:19:44 +01:00
|
|
|
overlays.close_overlay("lightbox");
|
|
|
|
}
|
|
|
|
});
|
2021-02-28 00:58:23 +01:00
|
|
|
}
|