← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4417: minor js fixes

 

------------------------------------------------------------
revno: 4417
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-23 12:07:58 +0200
message:
  minor js fixes
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js	2011-08-19 20:30:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.availability.js	2011-08-23 10:07:58 +0000
@@ -49,7 +49,7 @@
     {
         $.ajax( {
             url : "../dhis-web-commons-stream/ping.action",
-            cache: false,
+            cache : false,
             success : function( data, textStatus, jqXHR )
             {
                 dhis2.availability._isAvailable = true;
@@ -105,7 +105,7 @@
     $.ajax( {
         url : "../dhis-web-commons-stream/ping.action",
         async : false,
-        cache: false,
+        cache : false,
         success : function( data, textStatus, jqXHR )
         {
             dhis2.availability._isAvailable = true;
@@ -124,6 +124,7 @@
             if ( dhis2.availability._isAvailable )
             {
                 dhis2.availability._isAvailable = false;
+                dhis2.availability._isLoggedIn = -1;
                 $( document ).trigger( "dhis2.offline" );
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js	2011-08-18 12:01:44 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.comparator.js	2011-08-23 10:07:58 +0000
@@ -37,11 +37,12 @@
  */
 dhis2.comparator.defaultComparator = function( a, b )
 {
-    if( a === b) {
+    if ( a === b )
+    {
         return 0;
     }
 
-    return (a > b) ? 1 : -1;
+    return ( a > b ) ? 1 : -1;
 };
 
 /**
@@ -69,7 +70,7 @@
 {
     a = !!a ? a.html() : a;
     b = !!b ? b.html() : b;
-    
+
     a = !!a ? a.toLowerCase() : a;
     b = !!b ? b.toLowerCase() : b;
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js	2011-08-18 12:53:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.select.js	2011-08-23 10:07:58 +0000
@@ -41,7 +41,8 @@
     var select_ghost_id = $select.attr( 'id' ) + '_ghost';
     var $select_ghost = $( '#' + select_ghost_id );
 
-    if ($select_ghost.size() === 0) {
+    if ( $select_ghost.size() === 0 )
+    {
         $select_ghost = $( '<select id="' + select_ghost_id + '" multiple="multiple"></select>' );
         $select_ghost.hide();
         $select_ghost.appendTo( 'body' );
@@ -66,18 +67,24 @@
     $select_ghost = dhis2.select.getGhost( $select );
     caseSensitive = caseSensitive || false;
 
-    if (key.length === 0) {
+    if ( key.length === 0 )
+    {
         dhis2.select.moveSorted( $select, $select_ghost.children() );
-    } else {
+    }
+    else
+    {
         var $select_options = $select.children();
         var $select_ghost_options = $select_ghost.children();
         var $select_ghost_matched;
         var $select_not_matched;
 
-        if(caseSensitive) {
+        if ( caseSensitive )
+        {
             $select_ghost_matched = $select_ghost_options.filter( ':contains(' + key + ')' );
             $select_not_matched = $select_options.filter( ':not( :contains(' + key + ') )' );
-        } else {
+        }
+        else
+        {
             $select_ghost_matched = $select_ghost_options.filter( ':containsNC(' + key + ')' );
             $select_not_matched = $select_options.filter( ':not( :containsNC(' + key + ') )' );
         }
@@ -92,39 +99,48 @@
  * sorted fashion. Both the select and array is assumed to be sorted to start
  * with.
  * 
- * @param $select {jQuery} A select which acts as the target
- * @param $array {jQuery} An array of child elements to move
+ * @param $select {jQuery} A select which acts as the target
+ * @param $array {jQuery} An array of child elements to move
  */
-dhis2.select.moveSorted = function ($select, $array)
+dhis2.select.moveSorted = function( $select, $array )
 {
-    if ($select.children().size() === 0) {
-        $select.append($array);
-    } else {
+    if ( $select.children().size() === 0 )
+    {
+        $select.append( $array );
+    }
+    else
+    {
         var array = $array.get();
         var array_idx = 0;
         var current = array.shift();
         var $children = $select.children();
 
-        while (current !== undefined) {
-            var $current = $(current);
+        while ( current !== undefined )
+        {
+            var $current = $( current );
 
-            if ( dhis2.comparator.htmlNoCaseComparator( $children.eq(array_idx), $current) > 0) {
-                $(current).insertBefore($children.eq(array_idx));
+            if ( dhis2.comparator.htmlNoCaseComparator( $children.eq( array_idx ), $current ) > 0 )
+            {
+                $( current ).insertBefore( $children.eq( array_idx ) );
                 current = array.shift();
-            } else {
+            }
+            else
+            {
                 array_idx++;
             }
 
-            if ($children.size() < array_idx) {
+            if ( $children.size() < array_idx )
+            {
                 break;
             }
         }
 
-        if (current !== undefined) {
-            $select.append(current);
+        if ( current !== undefined )
+        {
+            $select.append( current );
         }
 
-        $select.append(array);
+        $select.append( array );
     }
 };
 
@@ -134,29 +150,29 @@
  * @param $select {jQuery} Select which acts as the target
  * @param $array An array of child elements to move
  */
-dhis2.select.move = function ($select, $array)
+dhis2.select.move = function( $select, $array )
 {
-    $select.append($array);
+    $select.append( $array );
 };
 
 /**
  * Mark all options in a select as selected.
  * 
- * @param $select {jQuery} The select
+ * @param $select {jQuery} The select
  */
-dhis2.select.selectAll = function($select)
+dhis2.select.selectAll = function( $select )
 {
-    $select.children().attr('selected', true);
+    $select.children().attr( 'selected', true );
 };
 
 /**
  * Mark all options as not selected.
  * 
- * @param $select {jQuery} The select
+ * @param $select {jQuery} The select
  */
-dhis2.select.selectNone = function($select)
+dhis2.select.selectNone = function( $select )
 {
-    $select.children().attr('selected', false);
+    $select.children().attr( 'selected', false );
 };
 
 /**
@@ -167,11 +183,12 @@
  * 
  * @return Sorted array of options
  */
-dhis2.select.sort = function($options)
+dhis2.select.sort = function( $options )
 {
-    return $.makeArray($options).sort(function(a, b) {
-        return dhis2.comparator.htmlComparator( $(a), $(b) );
-    });
+    return $.makeArray( $options ).sort( function( a, b )
+    {
+        return dhis2.comparator.htmlComparator( $( a ), $( b ) );
+    } );
 };
 
 /**
@@ -182,9 +199,10 @@
  * 
  * @return Sorted array of options
  */
-dhis2.select.sortNC = function($options)
+dhis2.select.sortNC = function( $options )
 {
-    return $($.makeArray($options).sort(function(a, b) {
-        return dhis2.comparator.htmlNoCaseComparator( $(a), $(b) );
-    }) );
+    return $( $.makeArray( $options ).sort( function( a, b )
+    {
+        return dhis2.comparator.htmlNoCaseComparator( $( a ), $( b ) );
+    } ) );
 };

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2011-08-19 21:04:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2011-08-23 10:07:58 +0000
@@ -31,7 +31,7 @@
 /**
  * Creates namespace object based on path
  * 
- * @param path {String} The path of the namespace, i.e. 'a.b.c'
+ * @param path {String} The path of the namespace, i.e. 'a.b.c'
  * 
  * @returns {object} Namespace object
  */