Skip to content
Snippets Groups Projects
Commit bb285a0c authored by Ere Maijala's avatar Ere Maijala
Browse files

Use a more specific selector when checking for flash messages in lightbox so...

Use a more specific selector when checking for flash messages in lightbox so that other markup using the classes doesn't confuse lightbox. Also always use jQuery selectors to find the flash messages to be more tolerant of markup changes (e.g. whitespace, class ordering etc.).
parent 3f12bbf0
Branches
Tags
No related merge requests found
...@@ -50,6 +50,6 @@ class Flashmessages extends \VuFind\View\Helper\Root\Flashmessages ...@@ -50,6 +50,6 @@ class Flashmessages extends \VuFind\View\Helper\Root\Flashmessages
if ($ns == 'error') { if ($ns == 'error') {
$ns = 'danger'; $ns = 'danger';
} }
return 'alert alert-' . $ns; return 'flash-message alert alert-' . $ns;
} }
} }
...@@ -68,8 +68,8 @@ VuFind.lightbox = (function() { ...@@ -68,8 +68,8 @@ VuFind.lightbox = (function() {
return; return;
} }
// Isolate successes // Isolate successes
var htmlDiv = $('<div>'+html+'</div>'); var htmlDiv = $('<div/>').html(html);
var alerts = htmlDiv.find('.alert-success'); var alerts = htmlDiv.find('.flash-message.alert-success');
if (alerts.length > 0) { if (alerts.length > 0) {
showAlert(alerts[0].innerHTML, 'success'); showAlert(alerts[0].innerHTML, 'success');
return; return;
...@@ -127,10 +127,10 @@ VuFind.lightbox = (function() { ...@@ -127,10 +127,10 @@ VuFind.lightbox = (function() {
return; return;
} }
if ( // Close the lightbox after deliberate login if ( // Close the lightbox after deliberate login
obj.method // is a form obj.method // is a form
&& !html.match(/alert alert-danger/) // skip failed logins && ((obj.url.match(/MyResearch/) && !obj.url.match(/Bulk/)) // that matches login/create account
&& ((obj.url.match(/MyResearch/) && !obj.url.match(/Bulk/)) // that matches login/create account || obj.url.match(/catalogLogin/)) // or catalog login for holds
|| obj.url.match(/catalogLogin/)) // or catalog login for holds && $('<div/>').html(html).find('.flash-message.alert-danger').length == 0 // skip failed logins
) { ) {
if (_originalUrl.match(/UserLogin/) || obj.url.match(/catalogLogin/)) { if (_originalUrl.match(/UserLogin/) || obj.url.match(/catalogLogin/)) {
_refreshPage(); _refreshPage();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment