← Back to team overview

dhis2-devs team mailing list archive

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

 

------------------------------------------------------------
revno: 4158
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-18 14:07:17 +0200
message:
  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 10:46:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-07-18 12:07:17 +0000
@@ -45,11 +45,9 @@
 
     this.select = function( unitId )
     {
-        var unitTag = document.getElementById( getTagId( unitId ) );
-
-        var linkTags = unitTag.getElementsByTagName( 'a' );
-
-        if ( linkTags[0].className == 'selected' && unselectAllowed )
+        var linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
+
+        if ( linkTag.hasClass( "selected" ) && unselectAllowed )
         {
             $.post( organisationUnitTreePath + "removeorgunit.action", {
                 id : unitId
@@ -58,7 +56,6 @@
                 responseReceived( data.firstChild );
             }, 'xml' );
 
-            linkTags[0].className = '';
         } else
         {
             if ( multipleSelectionAllowed )
@@ -80,19 +77,9 @@
                     responseReceived( data.firstChild );
                 }, 'xml' );
 
-                // Remove all select marks
-                var treeTag = document.getElementById( 'orgUnitTree' );
-                var linkTags = treeTag.getElementsByTagName( 'a' );
-
-                for ( var i = 0, linkTag; ( linkTag = linkTags[i] ); ++i )
-                {
-                    linkTag.className = '';
-                }
-
-                // Set new select mark
-                var unitTag = document.getElementById( getTagId( unitId ) );
-                linkTags = unitTag.getElementsByTagName( 'a' );
-                linkTags[0].className = 'selected';
+                $( "#orgUnitTree" ).find( "a" ).removeClass( "selected" );
+                $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 ).addClass( "selected" );
+
             }
         }
     };
@@ -155,8 +142,7 @@
 {
     this.toggle = function( unitId )
     {
-        var parentTag = document.getElementById( getTagId( unitId ) );
-        var children = parentTag.getElementsByTagName( 'ul' );
+        var children = $( "#" + getTagId( unitId ) ).find( "ul" );
 
         var request = new Request();
         request.setResponseTypeXML( 'units' );
@@ -321,12 +307,18 @@
 
     function setVisible( tag, visible )
     {
-        tag.style.display = visible ? 'block' : 'none';
+        if ( visible )
+        {
+            $( tag ).show();
+        } else
+        {
+            $( tag ).hide();
+        }
     }
 
     function isVisible( tag )
     {
-        return tag.style.display != 'none';
+        return $( tag ).is( ":visible" );
     }
 
     function getTagId( unitId )