history.js: Don't load location bar as if it's an autorefresh

This commit is contained in:
Johannes Meyer 2020-02-28 14:29:59 +01:00
parent 928611fe1e
commit 969c1615c7
2 changed files with 23 additions and 7 deletions

View File

@ -264,7 +264,7 @@
$('#col2') $('#col2')
); );
req.addToHistory = false; req.addToHistory = false;
req.autorefresh = onload; req.scripted = onload;
} }
} }

View File

@ -285,6 +285,7 @@
req.fail(this.onFailure); req.fail(this.onFailure);
req.always(this.onComplete); req.always(this.onComplete);
req.autorefresh = autorefresh; req.autorefresh = autorefresh;
req.scripted = false;
req.method = method; req.method = method;
req.action = action; req.action = action;
req.addToHistory = true; req.addToHistory = true;
@ -761,7 +762,14 @@
var $target = $('#' + match[1]); var $target = $('#' + match[1]);
if ($target.length) { if ($target.length) {
_this.renderContentToContainer( _this.renderContentToContainer(
match[2], $target, 'replace', req.autorefresh, req.forceFocus, autoSubmit); match[2],
$target,
'replace',
req.autorefresh,
req.forceFocus,
autoSubmit,
req.scripted
);
} else { } else {
_this.icinga.logger.warn( _this.icinga.logger.warn(
'Invalid target ID. Cannot render multipart to #' + match[1]); 'Invalid target ID. Cannot render multipart to #' + match[1]);
@ -772,7 +780,14 @@
}) })
} else { } else {
this.renderContentToContainer( this.renderContentToContainer(
req.responseText, req.$target, req.action, req.autorefresh, req.forceFocus, autoSubmit); req.responseText,
req.$target,
req.action,
req.autorefresh,
req.forceFocus,
autoSubmit,
req.scripted
);
} }
if (oldNotifications) { if (oldNotifications) {
@ -930,7 +945,8 @@
req.responseText, req.responseText,
req.$target, req.$target,
req.action, req.action,
req.autorefresh req.autorefresh,
req.scripted
); );
} else { } else {
if (errorThrown === 'abort') { if (errorThrown === 'abort') {
@ -1042,7 +1058,7 @@
/** /**
* Smoothly render given HTML to given container * Smoothly render given HTML to given container
*/ */
renderContentToContainer: function (content, $container, action, autorefresh, forceFocus, autoSubmit) { renderContentToContainer: function (content, $container, action, autorefresh, forceFocus, autoSubmit, scripted) {
// Container update happens here // Container update happens here
var scrollPos = false; var scrollPos = false;
var _this = this; var _this = this;
@ -1138,7 +1154,7 @@
setTimeout(this.icinga.ui.focusElement.bind(this.icinga.ui), 0, navigationAnchor, $container); setTimeout(this.icinga.ui.focusElement.bind(this.icinga.ui), 0, navigationAnchor, $container);
} else if (! activeElementPath) { } else if (! activeElementPath) {
// Active element was not in this container // Active element was not in this container
if (! autorefresh) { if (! autorefresh && ! scripted) {
setTimeout(function() { setTimeout(function() {
if (typeof $container.attr('tabindex') === 'undefined') { if (typeof $container.attr('tabindex') === 'undefined') {
$container.attr('tabindex', -1); $container.attr('tabindex', -1);
@ -1155,7 +1171,7 @@
if ($activeElement.length && $activeElement.is(':visible')) { if ($activeElement.length && $activeElement.is(':visible')) {
$activeElement[0].focus({preventScroll: autorefresh}); $activeElement[0].focus({preventScroll: autorefresh});
} else if (! autorefresh) { } else if (! autorefresh && ! scripted) {
if (focusFallback) { if (focusFallback) {
_this.icinga.ui.focusElement($(focusFallback.parent).find(focusFallback.child)); _this.icinga.ui.focusElement($(focusFallback.parent).find(focusFallback.child));
} else if (typeof $container.attr('tabindex') === 'undefined') { } else if (typeof $container.attr('tabindex') === 'undefined') {