diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index 190fd06f5..fa8e56b6e 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -3,10 +3,13 @@ namespace Icinga\Forms\Authentication; +use Icinga\Application\Config; +use Icinga\Application\Icinga; use Icinga\Authentication\Auth; use Icinga\Authentication\User\ExternalBackend; use Icinga\User; use Icinga\Web\Form; +use Icinga\Web\StyleSheet; use Icinga\Web\Url; /** @@ -53,6 +56,24 @@ class LoginForm extends Form 'class' => isset($formData['username']) ? 'autofocus' : '' ) ); + if (! (bool) Config::app()->get('themes', 'disabled', false)) { + $themes = Icinga::app()->getThemes(); + if (count($themes) > 1) { + $defaultTheme = Config::app()->get('themes', 'default', StyleSheet::DEFAULT_THEME); + if (isset($themes[$defaultTheme])) { + $themes[$defaultTheme] .= ' (' . $this->translate('default') . ')'; + } + $this->addElement( + 'select', + 'theme', + array( + 'label' => $this->translate('Theme', 'Form element label'), + 'multiOptions' => $themes, + //'value' => null + ) + ); + } + } $this->addElement( 'hidden', 'redirect', diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 42eba1b72..9ce20adb0 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -386,7 +386,9 @@ } } - icinga.loader.loadUrl(url, $target, data, method).progressTimer = progressTimer; + var req = icinga.loader.loadUrl(url, $target, data, method); + req.forceFocus = autosubmit ? $(event.currentTarget) : null; + req.progressTimer = progressTimer; event.stopPropagation(); event.preventDefault(); diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 733c94d20..fd934764f 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -554,7 +554,7 @@ } // .html() removes outer div we added above - this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh); + this.renderContentToContainer($resp.html(), req.$target, req.action, req.autorefresh, req.forceFocus); if (oldNotifications) { oldNotifications.appendTo($('#notifications')); } @@ -721,14 +721,16 @@ /** * Smoothly render given HTML to given container */ - renderContentToContainer: function (content, $container, action, autorefresh) { + renderContentToContainer: function (content, $container, action, autorefresh, forceFocus) { // Container update happens here var scrollPos = false; var self = this; var containerId = $container.attr('id'); var activeElementPath = false; - if (document.activeElement + if (forceFocus && forceFocus.length) { + activeElementPath = this.icinga.utils.getCSSPath($(forceFocus)); + } else if (document.activeElement && document.activeElement !== document.body && $.contains($container[0], document.activeElement) ) {