From bbf520b6ea4a90382816c39a0d6980a137b5d5de Mon Sep 17 00:00:00 2001 From: Neil Bowers Date: Mon, 23 Jan 2012 12:35:45 +0000 Subject: [PATCH] Propagated bug fix for cursor changes --- example/jquery.jOrgChart.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/example/jquery.jOrgChart.js b/example/jquery.jOrgChart.js index daec657..07dba19 100644 --- a/example/jquery.jOrgChart.js +++ b/example/jquery.jOrgChart.js @@ -149,19 +149,23 @@ $nodeDiv = $("
").addClass("node").append($nodeContent); // Expand and contract nodes - $nodeDiv.click(function() { - var $this = $(this); - var $tr = $this.closest("tr"); - $tr.nextAll("tr").fadeToggle("fast"); + if ($childNodes.length > 0) { + $nodeDiv.click(function() { + var $this = $(this); + var $tr = $this.closest("tr"); + $tr.nextAll("tr").fadeToggle("fast"); - if($tr.hasClass('contracted')){ - $this.css('cursor','n-resize'); - $tr.addClass('expanded'); - }else{ - $this.css('cursor','s-resize'); - $tr.addClass('contracted'); - } - }); + if($tr.hasClass('contracted')){ + $this.css('cursor','n-resize'); + $tr.removeClass('contracted'); + $tr.addClass('expanded'); + }else{ + $this.css('cursor','s-resize'); + $tr.removeClass('expanded'); + $tr.addClass('contracted'); + } + }); + } $nodeCell.append($nodeDiv); $nodeRow.append($nodeCell); @@ -218,6 +222,9 @@ $.each(classList, function(index,item) { if (item == 'collapsed') { $nodeRow.nextAll('tr').css('display', 'none'); + $nodeRow.removeClass('expanded'); + $nodeRow.addClass('contracted'); + $nodeDiv.css('cursor','s-resize'); } else { $nodeDiv.addClass(item); }