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

Made refreshing the page work properly also when the current url includes a hash.

parent 2209de76
No related merge requests found
...@@ -87,8 +87,7 @@ VuFind.lightbox = (function() { ...@@ -87,8 +87,7 @@ VuFind.lightbox = (function() {
_xhr.always(function() { _xhr = false; }) _xhr.always(function() { _xhr = false; })
.done(function(html, status, jq_xhr) { .done(function(html, status, jq_xhr) {
if (jq_xhr.status == 205) { if (jq_xhr.status == 205) {
// No reload since any post params would cause a prompt _refreshPage();
window.location.href = window.location.href;
return; return;
} }
if ( // Close the lightbox after deliberate login if ( // Close the lightbox after deliberate login
...@@ -107,8 +106,7 @@ VuFind.lightbox = (function() { ...@@ -107,8 +106,7 @@ VuFind.lightbox = (function() {
cancelable: true cancelable: true
}); });
if (document.dispatchEvent(event)) { if (document.dispatchEvent(event)) {
// No reload since any post params would cause a prompt _refreshPage();
window.location.href = window.location.href;
} }
return false; return false;
} else { } else {
...@@ -209,6 +207,22 @@ VuFind.lightbox = (function() { ...@@ -209,6 +207,22 @@ VuFind.lightbox = (function() {
return false; return false;
} }
/**
* Reload the page without causing trouble with POST parameters while keeping hash
*/
var _refreshPage = function() {
var parts = window.location.href.split('#');
if (typeof parts[1] === 'undefined') {
window.location.href = window.location.href;
} else {
var href = parts[0];
// Force reload with a timestamp
href += href.indexOf('?') == -1 ? '?_=' : '&_=';
href += new Date().getTime() + '#' + parts[1];
window.location.href = href;
}
}
// Public: Attach listeners to the page // Public: Attach listeners to the page
var bind = function(target) { var bind = function(target) {
if ('undefined' === typeof target) { if ('undefined' === typeof target) {
...@@ -245,8 +259,7 @@ VuFind.lightbox = (function() { ...@@ -245,8 +259,7 @@ VuFind.lightbox = (function() {
_modalBody = _modal.find('.modal-body'); _modalBody = _modal.find('.modal-body');
_modal.on('hide.bs.modal', function() { _modal.on('hide.bs.modal', function() {
if (VuFind.lightbox.refreshOnClose) { if (VuFind.lightbox.refreshOnClose) {
// No reload since any post params would cause a prompt _refreshPage();
window.location.href = window.location.href;
} }
document.dispatchEvent(new Event('VuFind.lightbox.closing')); document.dispatchEvent(new Event('VuFind.lightbox.closing'));
}); });
......
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