From 34d24bfdac6e3ebca718e12c0068ce33ecf3d2f2 Mon Sep 17 00:00:00 2001 From: Hashir Sarwar Date: Thu, 2 Apr 2020 14:37:21 +0000 Subject: [PATCH] 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. --- static/js/lightbox.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/static/js/lightbox.js b/static/js/lightbox.js index e2f46d52f9..fe3c908d86 100644 --- a/static/js/lightbox.js +++ b/static/js/lightbox.js @@ -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); $(".player-container").hide(); $(".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"); 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. // this will likely be passed in every time but just ignored if the result is already // stored in the `asset_map`. -exports.open = function ($image, options) { - if (!options) { - options = { - // default to showing standard images. - lightbox_canvas: $(".lightbox-canvas-trigger").hasClass("enabled"), - }; - } - +exports.open = 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"); @@ -120,7 +115,7 @@ exports.open = function ($image, options) { if (payload.type.match("-video")) { display_video(payload); } else if (payload.type === "image") { - display_image(payload, options); + display_image(payload); } if (is_open) {