2016-02-08 15:41:00 +01:00
|
|
|
/*! Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */
|
2015-12-21 13:03:08 +01:00
|
|
|
|
|
|
|
(function(Icinga, $) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Icinga.Behaviors = Icinga.Behaviors || {};
|
|
|
|
|
|
|
|
var Autofocus = function (icinga) {
|
|
|
|
Icinga.EventListener.call(this, icinga);
|
|
|
|
this.on('rendered', this.onRendered, this);
|
|
|
|
};
|
|
|
|
|
|
|
|
Autofocus.prototype = new Icinga.EventListener();
|
|
|
|
|
|
|
|
Autofocus.prototype.onRendered = function(e) {
|
2016-01-25 07:09:15 +01:00
|
|
|
setTimeout(function() {
|
2016-01-28 12:29:42 +01:00
|
|
|
if (document.activeElement === e.target
|
|
|
|
|| document.activeElement === document.body
|
|
|
|
) {
|
2016-01-25 07:09:15 +01:00
|
|
|
$(e.target).find('.autofocus').focus();
|
|
|
|
}
|
|
|
|
}, 0);
|
2015-12-21 13:03:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Icinga.Behaviors.Autofocus = Autofocus;
|
|
|
|
|
|
|
|
})(Icinga, jQuery);
|