From e85f40aca45c1116367fda35b2b3dbb64dd01af6 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Fri, 10 Jan 2020 14:29:26 -0500
Subject: [PATCH] Lightbox now ignores links that open in new window
 (target=new).

Used jQuery to simplify attr logic.
---
 themes/bootstrap3/js/lightbox.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js
index cb44334761d..24e5f57e6c3 100644
--- a/themes/bootstrap3/js/lightbox.js
+++ b/themes/bootstrap3/js/lightbox.js
@@ -232,10 +232,16 @@ VuFind.register('lightbox', function Lightbox() {
    * data-lightbox-title = Lightbox title (overrides any title the page provides)
    */
   _constrainLink = function constrainLink(event) {
-    if (typeof $(this).data('lightboxIgnore') != 'undefined'
-      || typeof this.attributes.href === 'undefined'
-      || this.attributes.href.value.charAt(0) === '#'
-      || this.href.match(/^[a-zA-Z]+:[^/]/) // ignore resource identifiers (mailto:, tel:, etc.)
+    var $link = $(this);
+    if (typeof $link.data("lightboxIgnore") != "undefined"
+      || typeof $link.attr("href") === "undefined"
+      || $link.attr("href").charAt(0) === "#"
+      || $link.attr("href").match(/^[a-zA-Z]+:[^/]/) // ignore resource identifiers (mailto:, tel:, etc.)
+      || (typeof $link.attr("target") !== "undefined"
+        && (
+          $link.attr("target").toLowerCase() === "_new"
+          || $link.attr("target").toLowerCase() === "new"
+        ))
     ) {
       return true;
     }
-- 
GitLab