← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4163: more jquerification in ouwt

 

------------------------------------------------------------
revno: 4163
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-07-19 09:38:53 +0200
message:
  more jquerification in ouwt
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.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/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-07-18 15:04:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-07-19 07:38:53 +0000
@@ -45,9 +45,9 @@
 
     this.select = function( unitId )
     {
-        var linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
+        var $linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
 
-        if ( linkTag.hasClass( "selected" ) && unselectAllowed )
+        if ( $linkTag.hasClass( "selected" ) && unselectAllowed )
         {
             $.post( organisationUnitTreePath + "removeorgunit.action", {
                 id : unitId
@@ -56,6 +56,7 @@
                 responseReceived( data.firstChild );
             }, 'xml' );
 
+            $linkTag.removeClass( "selected" );
         } else
         {
             if ( multipleSelectionAllowed )
@@ -67,7 +68,7 @@
                     responseReceived( data.firstChild );
                 }, 'xml' );
 
-                linkTags[0].className = 'selected';
+                $linkTag.addClass( "selected" );
             } else
             {
                 $.post( organisationUnitTreePath + "setorgunit.action", {
@@ -78,8 +79,7 @@
                 }, 'xml' );
 
                 $( "#orgUnitTree" ).find( "a" ).removeClass( "selected" );
-                $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 ).addClass( "selected" );
-
+                $linkTag.addClass( "selected" );
             }
         }
     };
@@ -289,15 +289,15 @@
 
     function setToggle( unitTag, expanded )
     {
-        var toggleTag = $( unitTag ).find( "span" ).get( 0 );
+        var $toggleTag = $( unitTag ).find( "span" );
         var toggleImg = expanded ? getToggleCollapse() : getToggleExpand();
 
-        if ( toggleTag.firstChild )
+        if ( $toggleTag.children().eq( 0 ) )
         {
-            toggleTag.replaceChild( toggleImg, toggleTag.firstChild );
+            $toggleTag.children().eq( 0 ).replaceWith( toggleImg );
         } else
         {
-            toggleTag.appendChild( toggleImg );
+            $toggleTag.append( toggleImg );
         }
     }