Pagination: Focus active after next or prev exceeded
I'd like to see behaviors for components instead of patching loader/events all the time.
This commit is contained in:
parent
d2e4664dce
commit
7ede8124cb
|
@ -14,9 +14,11 @@
|
|||
Autofocus.prototype = new Icinga.EventListener();
|
||||
|
||||
Autofocus.prototype.onRendered = function(e) {
|
||||
if (document.activeElement === document.body) {
|
||||
setTimeout(function() {
|
||||
if (document.activeElement === e.target) {
|
||||
$(e.target).find('.autofocus').focus();
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
Icinga.Behaviors.Autofocus = Autofocus;
|
||||
|
|
|
@ -729,6 +729,7 @@
|
|||
var containerId = $container.attr('id');
|
||||
|
||||
var activeElementPath = false;
|
||||
var focusFallback = false;
|
||||
if (forceFocus && forceFocus.length) {
|
||||
activeElementPath = this.icinga.utils.getCSSPath($(forceFocus));
|
||||
} else if (document.activeElement
|
||||
|
@ -736,7 +737,15 @@
|
|||
&& $.contains($container[0], document.activeElement)
|
||||
) {
|
||||
// Active element in container
|
||||
activeElementPath = this.icinga.utils.getCSSPath($(document.activeElement));
|
||||
var $activeElement = $(document.activeElement);
|
||||
var $pagination = $activeElement.closest('.pagination-control');
|
||||
if ($pagination.length) {
|
||||
focusFallback = {
|
||||
'parent': this.icinga.utils.getCSSPath($pagination),
|
||||
'child': '.active > a'
|
||||
};
|
||||
}
|
||||
activeElementPath = this.icinga.utils.getCSSPath($activeElement);
|
||||
}
|
||||
|
||||
if (typeof containerId !== 'undefined') {
|
||||
|
@ -815,7 +824,9 @@
|
|||
if ($activeElement.length && $activeElement.is(':visible')) {
|
||||
$activeElement.focus();
|
||||
} else if (! autorefresh) {
|
||||
if (typeof $container.attr('tabindex') === 'undefined') {
|
||||
if (focusFallback) {
|
||||
$(focusFallback.parent).find(focusFallback.child).focus();
|
||||
} else if (typeof $container.attr('tabindex') === 'undefined') {
|
||||
$container.attr('tabindex', -1);
|
||||
}
|
||||
$container.focus();
|
||||
|
|
Loading…
Reference in New Issue