=== 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 )