Copied changes wrt "copying li class to node class" from core lib to example lib.

master
Wes 2012-01-21 16:15:49 +00:00
parent c1e1ee3135
commit 7f04b1b6ee
1 changed files with 12 additions and 2 deletions

View File

@ -133,6 +133,7 @@
var $nodeRow = $("<tr/>").addClass("node-cells"); var $nodeRow = $("<tr/>").addClass("node-cells");
var $nodeCell = $("<td/>").addClass("node-cell").attr("colspan", 2); var $nodeCell = $("<td/>").addClass("node-cell").attr("colspan", 2);
var $childNodes = $node.children("ul:first").children("li"); var $childNodes = $node.children("ul:first").children("li");
var $nodeDiv;
if($childNodes.length > 1) { if($childNodes.length > 1) {
$nodeCell.attr("colspan", $childNodes.length * 2); $nodeCell.attr("colspan", $childNodes.length * 2);
@ -210,8 +211,17 @@
$tbody.append($childNodesRow); $tbody.append($childNodesRow);
} }
if ($node.hasClass('collapsed')) { // any classes on the LI element get copied to the relevant node in the tree
$nodeRow.nextAll('tr').css('display', 'none'); // apart from the special 'collapsed' class, which collapses the sub-tree at this point
if ($node.attr('class') != undefined) {
var classList = $node.attr('class').split(/\s+/);
$.each(classList, function(index,item) {
if (item == 'collapsed') {
$nodeRow.nextAll('tr').css('display', 'none');
} else {
$nodeDiv.addClass(item);
}
});
} }
$table.append($tbody); $table.append($tbody);