From d9a2049ab40c318bd211d6522ad9d51da54b8819 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 12 Jun 2012 08:56:22 +0000 Subject: [PATCH] focus on username when opening login form git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349198 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/utils.js | 8 ++++++-- .../src/main/webapp/js/redback/user.js | 16 +++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index 4f2c10c69..688bbd949 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -309,8 +309,7 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() { * @param errorList */ customShowError=function(selector, validator, errorMap, errorList) { - $(selector).find("div.control-group" ).removeClass( "error" ); - $(selector).find("span.help-inline").remove(); + removeValidationErrorMessages(selector); for ( var i = 0; errorList[i]; i++ ) { var error = errorList[i]; var field = $(selector).find("#"+error.element.id); @@ -319,6 +318,11 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() { } } + removeValidationErrorMessages=function(selector){ + $(selector).find("div.control-group" ).removeClass( "error" ); + $(selector).find("span.help-inline").remove(); + } + appendArchivaVersion=function(){ return "_archivaVersion="+window.archivaRuntimeInfo.version; } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index 635b76e27..c3137a1f9 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -326,12 +326,19 @@ define("redback.user",["jquery","order!utils","i18n","jquery.validate","order!kn } if (window.modalLoginWindow==null) { window.modalLoginWindow = $("#modal-login").modal(); - window.modalLoginWindow.bind('hidden', function () { - $("#modal-login-err-message").hide(); + window.modalLoginWindow.on('hidden', function () { + $("#modal-login-err-message").html(""); + removeValidationErrorMessages("#user-login-form"); + }); + // focus on user name + window.modalLoginWindow.on('shown', function (e) { + $("#user-login-form-username" ).focus(); }) } - $("#user-login-form").validate({ + var userLoginForm = $("#user-login-form"); + + userLoginForm.validate({ showErrors: function(validator, errorMap, errorList) { customShowError("#user-login-form",validator,errorMap,errorMap); } @@ -347,10 +354,9 @@ define("redback.user",["jquery","order!utils","i18n","jquery.validate","order!kn passwordReset(); }); - - } + /** * callback success function on rest login call. * modal close and hide/show some links (login,logout,register...) -- 2.39.5