From 8e12a61e855b5959ff24146a518193175cd1b06f Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 9 May 2018 15:43:15 +0300 Subject: [PATCH] Emit VuFind.lightbox.login event even if processing is short-circuited (#1175) --- themes/bootstrap3/js/lightbox.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index 01eade748b9..a063b48f4b0 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -136,20 +136,19 @@ VuFind.register('lightbox', function Lightbox() { _xhr = $.ajax(obj); _xhr.always(function lbAjaxAlways() { _xhr = false; }) .done(function lbAjaxDone(content, status, jq_xhr) { - if (jq_xhr.status === 205) { - VuFind.refreshPage(); - return; - } - var testDiv = $('<div/>').html(content); - var errorMsgs = testDiv.find('.flash-message.alert-danger:not([data-lightbox-ignore])'); - // Place Hold error isolation - if (obj.url.match(/\/Record\/.*(Hold|Request)\?/)) { - if (errorMsgs.length && testDiv.find('.record').length) { - var msgs = errorMsgs.toArray().map(function getAlertHtml(el) { - return el.innerHTML; - }).join('<br/>'); - showAlert(msgs, 'danger'); - return false; + var errorMsgs = []; + if (jq_xhr.status !== 205) { + var testDiv = $('<div/>').html(content); + errorMsgs = testDiv.find('.flash-message.alert-danger:not([data-lightbox-ignore])'); + // Place Hold error isolation + if (obj.url.match(/\/Record\/.*(Hold|Request)\?/)) { + if (errorMsgs.length && testDiv.find('.record').length) { + var msgs = errorMsgs.toArray().map(function getAlertHtml(el) { + return el.innerHTML; + }).join('<br/>'); + showAlert(msgs, 'danger'); + return false; + } } } if ( // Close the lightbox after deliberate login @@ -173,6 +172,10 @@ VuFind.register('lightbox', function Lightbox() { } _currentUrl = _originalUrl; // Now that we're logged in, where were we? } + if (jq_xhr.status === 205) { + VuFind.refreshPage(); + return; + } render(content); }) .fail(function lbAjaxFail(deferred, errorType, msg) { -- GitLab