Fixed cursor bug, where you'd end up getting the wrong expand/close cursor on parent nodes.

Also stopped the click handler being installed on nodes which don't have any children.
And cursor set correctly if you start a sub-tree collapsed, with <li class=collapsed>
master
Neil Bowers 2012-01-23 12:28:58 +00:00
parent 7f04b1b6ee
commit 7a3ea355aa
1 changed files with 19 additions and 12 deletions

View File

@ -149,6 +149,7 @@
$nodeDiv = $("<div>").addClass("node").append($nodeContent); $nodeDiv = $("<div>").addClass("node").append($nodeContent);
// Expand and contract nodes // Expand and contract nodes
if ($childNodes.length > 0) {
$nodeDiv.click(function() { $nodeDiv.click(function() {
var $this = $(this); var $this = $(this);
var $tr = $this.closest("tr"); var $tr = $this.closest("tr");
@ -156,12 +157,15 @@
if($tr.hasClass('contracted')){ if($tr.hasClass('contracted')){
$this.css('cursor','n-resize'); $this.css('cursor','n-resize');
$tr.removeClass('contracted');
$tr.addClass('expanded'); $tr.addClass('expanded');
}else{ }else{
$this.css('cursor','s-resize'); $this.css('cursor','s-resize');
$tr.removeClass('expanded');
$tr.addClass('contracted'); $tr.addClass('contracted');
} }
}); });
}
$nodeCell.append($nodeDiv); $nodeCell.append($nodeDiv);
$nodeRow.append($nodeCell); $nodeRow.append($nodeCell);
@ -218,6 +222,9 @@
$.each(classList, function(index,item) { $.each(classList, function(index,item) {
if (item == 'collapsed') { if (item == 'collapsed') {
$nodeRow.nextAll('tr').css('display', 'none'); $nodeRow.nextAll('tr').css('display', 'none');
$nodeRow.removeClass('expanded');
$nodeRow.addClass('contracted');
$nodeDiv.css('cursor','s-resize');
} else { } else {
$nodeDiv.addClass(item); $nodeDiv.addClass(item);
} }