Merge pull request #3 from neilbowers/master
Space apart sibling nodes; propagate classes from <li> to nodesmaster
commit
c1e1ee3135
|
@ -36,6 +36,7 @@
|
|||
width : 96px;
|
||||
height : 60px;
|
||||
z-index : 10;
|
||||
margin: : 0 2px;
|
||||
}
|
||||
|
||||
/* jQuery drag 'n drop */
|
||||
|
|
|
@ -133,6 +133,7 @@
|
|||
var $nodeRow = $("<tr/>").addClass("node-cells");
|
||||
var $nodeCell = $("<td/>").addClass("node-cell").attr("colspan", 2);
|
||||
var $childNodes = $node.children("ul:first").children("li");
|
||||
var $nodeDiv;
|
||||
|
||||
if($childNodes.length > 1) {
|
||||
$nodeCell.attr("colspan", $childNodes.length * 2);
|
||||
|
@ -210,8 +211,17 @@
|
|||
$tbody.append($childNodesRow);
|
||||
}
|
||||
|
||||
if ($node.hasClass('collapsed')) {
|
||||
// any classes on the LI element get copied to the relevant node in the tree
|
||||
// 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);
|
||||
|
|
|
@ -69,7 +69,7 @@ You'll need to construct a nest unordered list that represents your node nesting
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
If you want a sub-tree to start off hiden, just add `class="collapsed"` to a list item (`<li>`). That list item will appear, but everything below it won't. For example:
|
||||
If you want a sub-tree to start off hidden, just add `class="collapsed"` to a list item (`<li>`). That list item will appear, but everything below it won't. For example:
|
||||
|
||||
<ul id="org" style="display:none">
|
||||
<li>Food:
|
||||
|
@ -86,7 +86,7 @@ If you want a sub-tree to start off hiden, just add `class="collapsed"` to a lis
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
*Note that you can include any amount of HTML markup in your `<li>` **except** for other `<ul>` or `<li>` elements.*
|
||||
This plugin works by generating the tree as a series of nested tables. Each node in the tree is represented with `<div class="node">`. You can include any amount of HTML markup in your `<li>` **except** for other `<ul>` or `<li>` elements. Your markup will be used within the node's `<div>` element. Any classes you attach to the `<li>` elements will be copied to the associated node, allowing you to highlight particular parts of the tree. The special `collapsed` class described above doesn't get copied to the node.
|
||||
|
||||
|
||||
-----
|
||||
|
|
Loading…
Reference in New Issue