]> source.dussan.org Git - archiva.git/commitdiff
focus on username when opening login form
authorOlivier Lamy <olamy@apache.org>
Tue, 12 Jun 2012 08:56:22 +0000 (08:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 12 Jun 2012 08:56:22 +0000 (08:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1349198 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js

index 4f2c10c6909b54100a0219af87eefdfe42f56c75..688bbd94979d3df28af15f7e306f33d251b5e69b 100644 (file)
@@ -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;
   }
index 635b76e274f4973cd3a016ad7ac9bbb41b9055e9..c3137a1f9fb5fff892f8dd09562ce7e1867bff56 100644 (file)
@@ -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...)