Merge branch 'bugfix/autofocus-10671'

fixes #10671
This commit is contained in:
Eric Lippmann 2015-12-21 13:06:19 +01:00
commit 772ea1026b
4 changed files with 31 additions and 1 deletions

View File

@ -23,6 +23,7 @@ class JavaScript
'js/icinga/module.js',
'js/icinga/timezone.js',
'js/icinga/behavior/application-state.js',
'js/icinga/behavior/autofocus.js',
'js/icinga/behavior/tooltip.js',
'js/icinga/behavior/sparkline.js',
'js/icinga/behavior/tristate.js',

View File

@ -31,6 +31,7 @@ class WelcomePage extends Form
'text',
'token',
array(
'class' => 'autofocus',
'required' => true,
'label' => $this->translate('Setup Token'),
'description' => $this->translate(

View File

@ -16,7 +16,11 @@
ApplicationState.prototype = new Icinga.EventListener();
ApplicationState.prototype.onRendered = function(e) {
if (! $('#application-state').length && ! $('#login').length && ! $('#guest-error').length) {
if (! $('#application-state').length
&& ! $('#login').length
&& ! $('#guest-error').length
&& ! $('#setup').length
) {
var _this = e.data.self;
$('#layout').append(

View File

@ -0,0 +1,24 @@
/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
(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) {
if (document.activeElement === document.body) {
$(e.target).find('.autofocus').focus();
}
};
Icinga.Behaviors.Autofocus = Autofocus;
})(Icinga, jQuery);