From d02587a261833ecfa37a8a2bfdf6e98061de2b6b Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Mon, 5 Nov 2012 18:32:14 +0000 Subject: [PATCH] Improved autofocus of login form fields --- js/functions.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index 090a72b9f4..a7dd5ca242 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3785,10 +3785,17 @@ AJAX.registerOnload('functions.js', function () { $("a._blank").prop("target", "_blank"); /** * Reveal the login form to users with JS enabled + * and focus the appropriate input field */ var $loginform = $('#loginform'); - $loginform.find('.js-show').show(); - $loginform.find('#input_username').select(); + if ($loginform.length) { + $loginform.find('.js-show').show(); + if ($('#input_username').val()) { + $('#input_password').focus(); + } else { + $('#input_username').focus(); + } + } }); /**