js: Don't use jquery.focus shorthand anymore, but icinga.ui.focusElement
This commit is contained in:
parent
f844094475
commit
b168c3d7db
|
@ -18,7 +18,7 @@
|
|||
if (document.activeElement === e.target
|
||||
|| document.activeElement === document.body
|
||||
) {
|
||||
$(e.target).find('.autofocus').focus();
|
||||
e.data.self.icinga.ui.focusElement($(e.target).find('.autofocus'));
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
|
|
@ -819,14 +819,6 @@
|
|||
// TODO: We do not want to wrap this twice...
|
||||
var $content = $('<div>' + content + '</div>');
|
||||
|
||||
// Disable all click events while rendering
|
||||
// (Disabling disabled, was ways too slow)
|
||||
// $('*').click(function (event) {
|
||||
// event.stopImmediatePropagation();
|
||||
// event.stopPropagation();
|
||||
// event.preventDefault();
|
||||
// });
|
||||
|
||||
$('.container', $container).each(function() {
|
||||
_this.stopPendingRequestsFor($(this));
|
||||
});
|
||||
|
@ -861,7 +853,7 @@
|
|||
}
|
||||
// Do not touch focus in case a module or component already placed it
|
||||
if ($(document.activeElement).closest('.container').attr('id') !== containerId) {
|
||||
$container.focus();
|
||||
_this.icinga.ui.focusElement($container);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
@ -873,11 +865,11 @@
|
|||
$activeElement[0].focus({preventScroll: autorefresh});
|
||||
} else if (! autorefresh) {
|
||||
if (focusFallback) {
|
||||
$(focusFallback.parent).find(focusFallback.child).focus();
|
||||
_this.icinga.ui.focusElement($(focusFallback.parent).find(focusFallback.child));
|
||||
} else if (typeof $container.attr('tabindex') === 'undefined') {
|
||||
$container.attr('tabindex', -1);
|
||||
}
|
||||
$container.focus();
|
||||
_this.icinga.ui.focusElement($container);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
|
|
@ -154,16 +154,20 @@
|
|||
* @param {object} [$container] The container containing the element
|
||||
*/
|
||||
focusElement: function(element, $container) {
|
||||
var $element = $('#' + element);
|
||||
var $element = element;
|
||||
|
||||
if (! $element.length) {
|
||||
// The name attribute is actually deprecated, on anchor tags,
|
||||
// but we'll possibly handle links from another source
|
||||
// (module etc) so that's used as a fallback
|
||||
if ($container && $container.length) {
|
||||
$element = $container.find('[name="' + element.replace(/'/, '\\\'') + '"]');
|
||||
} else {
|
||||
$element = $('[name="' + element.replace(/'/, '\\\'') + '"]');
|
||||
if (typeof element === 'string') {
|
||||
$element = $('#' + element);
|
||||
|
||||
if (! $element.length) {
|
||||
// The name attribute is actually deprecated, on anchor tags,
|
||||
// but we'll possibly handle links from another source
|
||||
// (module etc) so that's used as a fallback
|
||||
if ($container && $container.length) {
|
||||
$element = $container.find('[name="' + element.replace(/'/, '\\\'') + '"]');
|
||||
} else {
|
||||
$element = $('[name="' + element.replace(/'/, '\\\'') + '"]');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +176,7 @@
|
|||
$element.attr('tabindex', -1);
|
||||
}
|
||||
|
||||
$element.focus();
|
||||
$element[0].focus();
|
||||
|
||||
if ($container && $container.length) {
|
||||
$container.scrollTop(0);
|
||||
|
|
Loading…
Reference in New Issue