mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
loader.js: Preserve scroll position also for form submits
Restores the scroll position if: * it's been a POST request * the source and target url path is the same * the target's url params do not change significantly
This commit is contained in:
parent
d2214ef0e4
commit
27569d09d8
@ -575,6 +575,20 @@
|
|||||||
rendered = true;
|
rendered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var referrer = req.referrer;
|
||||||
|
if (typeof referrer === 'undefined') {
|
||||||
|
referrer = req;
|
||||||
|
}
|
||||||
|
|
||||||
|
var autoSubmit = false;
|
||||||
|
if (referrer.method === 'POST') {
|
||||||
|
var newUrl = this.icinga.utils.parseUrl(req.url);
|
||||||
|
var currentUrl = this.icinga.utils.parseUrl(req.$target.data('icingaUrl'));
|
||||||
|
if (newUrl.path === currentUrl.path && this.icinga.utils.objectsEqual(newUrl.params, currentUrl.params)) {
|
||||||
|
autoSubmit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
req.$target.data('icingaUrl', req.url);
|
req.$target.data('icingaUrl', req.url);
|
||||||
|
|
||||||
this.icinga.ui.initializeTriStates($resp);
|
this.icinga.ui.initializeTriStates($resp);
|
||||||
@ -588,7 +602,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// .html() removes outer div we added above
|
// .html() removes outer div we added above
|
||||||
this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh, req.forceFocus);
|
this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh, req.forceFocus, autoSubmit);
|
||||||
if (oldNotifications) {
|
if (oldNotifications) {
|
||||||
oldNotifications.appendTo($('#notifications'));
|
oldNotifications.appendTo($('#notifications'));
|
||||||
}
|
}
|
||||||
@ -761,7 +775,7 @@
|
|||||||
/**
|
/**
|
||||||
* Smoothly render given HTML to given container
|
* Smoothly render given HTML to given container
|
||||||
*/
|
*/
|
||||||
renderContentToContainer: function (content, $container, action, autorefresh, forceFocus) {
|
renderContentToContainer: function (content, $container, action, autorefresh, forceFocus, autoSubmit) {
|
||||||
// Container update happens here
|
// Container update happens here
|
||||||
var scrollPos = false;
|
var scrollPos = false;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -791,7 +805,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof containerId !== 'undefined') {
|
if (typeof containerId !== 'undefined') {
|
||||||
if (autorefresh) {
|
if (autorefresh || autoSubmit) {
|
||||||
scrollPos = $container.scrollTop();
|
scrollPos = $container.scrollTop();
|
||||||
} else {
|
} else {
|
||||||
scrollPos = 0;
|
scrollPos = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user