mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
JS/loader: don't autorefresh while editing
We would loose our focus if autorefresh takes place. So we don't render the new content in case a form field in the very same container carries the focus. It would be great to have a better solution one far day, but for now it plays fine like this.
This commit is contained in:
parent
65db5c4acc
commit
bd57f8f02a
@ -437,7 +437,7 @@
|
|||||||
if (rendered) return;
|
if (rendered) return;
|
||||||
|
|
||||||
// .html() removes outer div we added above
|
// .html() removes outer div we added above
|
||||||
this.renderContentToContainer($resp.html(), req.$target, req.action);
|
this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh);
|
||||||
if (url.match(/#/)) {
|
if (url.match(/#/)) {
|
||||||
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
|
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
|
||||||
}
|
}
|
||||||
@ -519,7 +519,8 @@
|
|||||||
this.renderContentToContainer(
|
this.renderContentToContainer(
|
||||||
req.responseText,
|
req.responseText,
|
||||||
req.$target,
|
req.$target,
|
||||||
req.action
|
req.action,
|
||||||
|
req.autorefresh
|
||||||
);
|
);
|
||||||
|
|
||||||
// Header example:
|
// Header example:
|
||||||
@ -571,14 +572,7 @@
|
|||||||
/**
|
/**
|
||||||
* Smoothly render given HTML to given container
|
* Smoothly render given HTML to given container
|
||||||
*/
|
*/
|
||||||
renderContentToContainer: function (content, $container, action) {
|
renderContentToContainer: function (content, $container, action, autorefresh) {
|
||||||
// Disable all click events while rendering
|
|
||||||
$('*').click(function (event) {
|
|
||||||
event.stopImmediatePropagation();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Container update happens here
|
// Container update happens here
|
||||||
var scrollPos = false;
|
var scrollPos = false;
|
||||||
var containerId = $container.attr('id');
|
var containerId = $container.attr('id');
|
||||||
@ -587,10 +581,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var origFocus = document.activeElement;
|
var origFocus = document.activeElement;
|
||||||
|
if (typeof containerId !== 'undefined' && autorefresh && origFocus && $(origFocus).closest('form').length && $container.has($(origFocus)) && $(origFocus).closest('#' + containerId).length) {
|
||||||
|
this.icinga.logger.debug('Not changing content, form has focus');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: We do not want to wrap this twice...
|
// TODO: We do not want to wrap this twice...
|
||||||
var $content = $('<div>' + content + '</div>');
|
var $content = $('<div>' + content + '</div>');
|
||||||
|
|
||||||
|
// Disable all click events while rendering
|
||||||
|
$('*').click(function (event) {
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (false &&
|
if (false &&
|
||||||
$('.dashboard', $content).length > 0 &&
|
$('.dashboard', $content).length > 0 &&
|
||||||
$('.dashboard', $container).length === 0
|
$('.dashboard', $container).length === 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user