← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12479: minor optimization in $.trimArray

 

------------------------------------------------------------
revno: 12479
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-10-07 17:11:57 +0200
message:
  minor optimization in $.trimArray
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-10-07 14:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-10-07 15:11:57 +0000
@@ -157,69 +157,62 @@
     var str = e.target.id;
 	
     var match = /.*\[(.*)\]/.exec( str ); //value[-dataElementUid-]
-	
-    if ( ! match )
-    {
+
+    if( !match ) {
         return;
     }
 
     var deId = match[1];
-	
+
     //Get the data element name
     var nameContainer = document.getElementById('value[' + deId + '].name');
-	
-    if ( ! nameContainer )
-    {
+
+    if( !nameContainer ) {
         return;
     }
 
     var name = '';
-	
+
     var as = nameContainer.getElementsByTagName('a');
 
-    if ( as.length > 0 )	//Admin rights: Name is in a link
+    if( as.length > 0 )	//Admin rights: Name is in a link
     {
         name = as[0].firstChild.nodeValue;
     }
-    else
-    {
+    else {
         name = nameContainer.firstChild.nodeValue;
     }
-	
 }
 
 function keyPress( event, field )
 {
     var key = 0;
-    if ( event.charCode )
-    {
-        key = event.charCode; /* Safari2 (Mac) (and probably Konqueror on Linux, untested) */
+
+    if( event.charCode ) {
+        key = event.charCode;
+        /* Safari2 (Mac) (and probably Konqueror on Linux, untested) */
     }
-    else
-    {
-        if ( event.keyCode )
-        {
-            key = event.keyCode; /* Firefox1.5 (Mac/Win), Opera9 (Mac/Win), IE6, IE7Beta2, Netscape7.2 (Mac) */
+    else {
+        if( event.keyCode ) {
+            key = event.keyCode;
+            /* Firefox1.5 (Mac/Win), Opera9 (Mac/Win), IE6, IE7Beta2, Netscape7.2 (Mac) */
         }
-        else
-        {
-            if ( event.which )
-            {
-                key = event.which; /* Older Netscape? (No browsers triggered yet) */
+        else {
+            if( event.which ) {
+                key = event.which;
+                /* Older Netscape? (No browsers triggered yet) */
             }
         }
     }
-	
-    if ( key == 13 )
-    { 
-        nextField = getNextEntryField( field );
-        if ( nextField )
-        {
+
+    if( key == 13 ) {
+        nextField = getNextEntryField(field);
+        if( nextField ) {
             nextField.focus();
         }
         return true;
     }
-    
+
     return true;
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js	2013-10-07 14:43:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js	2013-10-07 15:11:57 +0000
@@ -9,11 +9,7 @@
             throw new Error('requires an array as argument')
         }
 
-        for( var i = 0, len = arr.length; i < len; i++ ) {
-            arr[i] = $.trim(arr[i]);
-        }
-
-        return arr;
+        return $.map(arr, $.trim);
     }
 
 })(jQuery, window, document);