focus on username when opening login form

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349198 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-06-12 08:56:22 +00:00
parent 7720351a50
commit d9a2049ab4
2 changed files with 17 additions and 7 deletions

View File

@ -309,8 +309,7 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() {
* @param errorList * @param errorList
*/ */
customShowError=function(selector, validator, errorMap, errorList) { customShowError=function(selector, validator, errorMap, errorList) {
$(selector).find("div.control-group" ).removeClass( "error" ); removeValidationErrorMessages(selector);
$(selector).find("span.help-inline").remove();
for ( var i = 0; errorList[i]; i++ ) { for ( var i = 0; errorList[i]; i++ ) {
var error = errorList[i]; var error = errorList[i];
var field = $(selector).find("#"+error.element.id); 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(){ appendArchivaVersion=function(){
return "_archivaVersion="+window.archivaRuntimeInfo.version; return "_archivaVersion="+window.archivaRuntimeInfo.version;
} }

View File

@ -326,12 +326,19 @@ define("redback.user",["jquery","order!utils","i18n","jquery.validate","order!kn
} }
if (window.modalLoginWindow==null) { if (window.modalLoginWindow==null) {
window.modalLoginWindow = $("#modal-login").modal(); window.modalLoginWindow = $("#modal-login").modal();
window.modalLoginWindow.bind('hidden', function () { window.modalLoginWindow.on('hidden', function () {
$("#modal-login-err-message").hide(); $("#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) { showErrors: function(validator, errorMap, errorList) {
customShowError("#user-login-form",validator,errorMap,errorMap); customShowError("#user-login-form",validator,errorMap,errorMap);
} }
@ -347,10 +354,9 @@ define("redback.user",["jquery","order!utils","i18n","jquery.validate","order!kn
passwordReset(); passwordReset();
}); });
} }
/** /**
* callback success function on rest login call. * callback success function on rest login call.
* modal close and hide/show some links (login,logout,register...) * modal close and hide/show some links (login,logout,register...)