lightbox: Remove redundant parameter `options` from lightbox.open().

The `options` parameter is not being passed in any call
of `lightbox.open()` and it uses the same option i.e.
`lightbox_canvas` everytime which is now computed inside
`display_image()` directly.
This commit is contained in:
Hashir Sarwar 2020-04-02 14:37:21 +00:00 committed by Tim Abbott
parent 74ec668e65
commit 34d24bfdac
1 changed files with 6 additions and 11 deletions

View File

@ -28,13 +28,15 @@ function render_lightbox_list_images(preview_source) {
} }
} }
function display_image(payload, options) { function display_image(payload) {
render_lightbox_list_images(payload.preview); render_lightbox_list_images(payload.preview);
$(".player-container").hide(); $(".player-container").hide();
$(".image-actions, .image-description, .download, .lightbox-canvas-trigger").show(); $(".image-actions, .image-description, .download, .lightbox-canvas-trigger").show();
if (options.lightbox_canvas === true) { const lightbox_canvas = $(".lightbox-canvas-trigger").hasClass("enabled");
if (lightbox_canvas === true) {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
canvas.setAttribute("data-src", payload.source); canvas.setAttribute("data-src", payload.source);
@ -85,14 +87,7 @@ function display_video(payload) {
// the image param is optional, but required on the first preview of an image. // the image param is optional, but required on the first preview of an image.
// this will likely be passed in every time but just ignored if the result is already // this will likely be passed in every time but just ignored if the result is already
// stored in the `asset_map`. // stored in the `asset_map`.
exports.open = function ($image, options) { exports.open = function ($image) {
if (!options) {
options = {
// default to showing standard images.
lightbox_canvas: $(".lightbox-canvas-trigger").hasClass("enabled"),
};
}
// if the asset_map already contains the metadata required to display the // if the asset_map already contains the metadata required to display the
// asset, just recall that metadata. // asset, just recall that metadata.
let $preview_src = $image.attr("src"); let $preview_src = $image.attr("src");
@ -120,7 +115,7 @@ exports.open = function ($image, options) {
if (payload.type.match("-video")) { if (payload.type.match("-video")) {
display_video(payload); display_video(payload);
} else if (payload.type === "image") { } else if (payload.type === "image") {
display_image(payload, options); display_image(payload);
} }
if (is_open) { if (is_open) {