From 5a2f6f2e5e692efb1007826f1ba3a0f8a31628cd Mon Sep 17 00:00:00 2001 From: Walter Berggren Date: Mon, 18 Apr 2022 21:03:02 +0200 Subject: [PATCH] Support opening links and images in new tabs and windows --- .../gallery/static/javascript/select.js | 20 +++++++++++-------- .../gallery/templates/components/folder.html | 1 + .../templates/components/thumbnail.html | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/fotogalleri/gallery/static/javascript/select.js b/fotogalleri/gallery/static/javascript/select.js index 40bc15a..6f1dd84 100644 --- a/fotogalleri/gallery/static/javascript/select.js +++ b/fotogalleri/gallery/static/javascript/select.js @@ -3,15 +3,13 @@ function selectLinkOnClick(link) { const checkboxIsHidden = checkbox.is(':hidden'); if (checkboxIsHidden) { - const linkUrl = $(link).attr('data-url'); - window.location.href = linkUrl; + return + } + const checkboxIsChecked = checkbox.is(':checked'); + if (checkboxIsChecked) { + checkbox.removeAttr('checked'); } else { - const checkboxIsChecked = checkbox.is(':checked'); - if (checkboxIsChecked) { - checkbox.removeAttr('checked'); - } else { - checkbox.attr('checked', 'checked'); - } + checkbox.attr('checked', 'checked'); } } @@ -65,6 +63,12 @@ $(function() { return className !== 'selectable'; }); + if ($(selectable).attr("href")) { + $(selectable).removeAttr("href") + } else { + $(selectable).attr("href", $(selectable).attr("data-url")) + } + filteredNames.forEach(function(className) { switch (className) { case 'img-link': diff --git a/fotogalleri/gallery/templates/components/folder.html b/fotogalleri/gallery/templates/components/folder.html index 89cf701..ace3b65 100644 --- a/fotogalleri/gallery/templates/components/folder.html +++ b/fotogalleri/gallery/templates/components/folder.html @@ -1,6 +1,7 @@ {% load static %}