Code

Updated focus
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 9 Jul 2007 08:33:05 +0000 (08:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 9 Jul 2007 08:33:05 +0000 (08:33 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6775 594d385d-05f5-0310-b6e9-bd551577e9d8

html/include/focus.js
ihtml/themes/default/login.tpl

index 281f0be89a0a689bdcc88bdff5673857f7c84774..edc7cda7faeee68a6c093812f09de228a14194d9 100644 (file)
@@ -403,36 +403,35 @@ function adjust_width(e) {
 }
 
 
-
-/* Set focus to first valid input field 
-               avoid IExplorer warning about hidding or disabled fields 
+/* Set focus to first valid input field
+    avoid IExplorer warning about hidding or disabled fields
 */
 function focus_field()
-{      
-               var i = 0;
-               while(focus_field.arguments[i] && document.getElementById(focus_field.arguments[i]).disabled == true) {
-                       i++;
-               }
-               if(focus_field.arguments[i]){
-
-                               var name                = focus_field.arguments[i];
-                               var element = document.getElementsByName(name);
-
-                               for(i = 0; i < element.length; i++) {
-                                               if(element[i].id == name && (
-                                                               element[i].type != 'none' || 
-                                                               element[i].type != 'hidden')
-                                               ) {
-                                                       element[i].blur();              
-                                                       element[i].focus();             
-                                                       break;
-                                               }
-                               }
-               }
-}
+{
+    var i     = 0;
+    var e     = 0;
+    var found = false;
+    var element_name = "";
+    var element =null;
 
+    while(focus_field.arguments[i] && !found){
 
+        var tmp = document.getElementsByName(focus_field.arguments[i]);
+        for(e = 0 ; e < tmp.length ; e ++ ){
 
+            if(tmp[e].disabled != true &&  tmp[e].type != "none" && tmp[e].type != "hidden" ){
+                found = true;
+                element = tmp[e];
+            }
+        }
+        i++;
+    }
+
+    if(element && found){
+        element.blur();
+        element.focus();
+    }
+}
 
 
 // vim:ts=2:syntax
index 1c6b44e6ffdd61ba1667e9de832af870c19dbfd1..1b5b79afdea947b29e5b3ae55713cf2dc294f174 100644 (file)
@@ -89,7 +89,7 @@
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page
   nextfield= "{$nextfield}";
-  focus_field({$nextfield});
+  focus_field("{$nextfield}");
   -->
 </script>