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;
|
||||
|
||||
// .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(/#/)) {
|
||||
this.icinga.ui.scrollContainerToAnchor(req.$target, url.split(/#/)[1]);
|
||||
}
|
||||
|
@ -519,7 +519,8 @@
|
|||
this.renderContentToContainer(
|
||||
req.responseText,
|
||||
req.$target,
|
||||
req.action
|
||||
req.action,
|
||||
req.autorefresh
|
||||
);
|
||||
|
||||
// Header example:
|
||||
|
@ -571,14 +572,7 @@
|
|||
/**
|
||||
* Smoothly render given HTML to given container
|
||||
*/
|
||||
renderContentToContainer: function (content, $container, action) {
|
||||
// Disable all click events while rendering
|
||||
$('*').click(function (event) {
|
||||
event.stopImmediatePropagation();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
renderContentToContainer: function (content, $container, action, autorefresh) {
|
||||
// Container update happens here
|
||||
var scrollPos = false;
|
||||
var containerId = $container.attr('id');
|
||||
|
@ -587,10 +581,22 @@
|
|||
}
|
||||
|
||||
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...
|
||||
var $content = $('<div>' + content + '</div>');
|
||||
|
||||
// Disable all click events while rendering
|
||||
$('*').click(function (event) {
|
||||
event.stopImmediatePropagation();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
if (false &&
|
||||
$('.dashboard', $content).length > 0 &&
|
||||
$('.dashboard', $container).length === 0
|
||||
|
|
Loading…
Reference in New Issue