a depth-first walker for manipulating an arbitrary DOM tree
bower install jquery-tree-manipulator
or download the jquery-tree-manipulator.js file
jquery-tree-manipulator works with jQuery >= 1.4.3.
After visualizing the results of running npm shrinkwrap
or
npm ls --json
on a repo with something like jQuery-JSONView, we can wire-up the tree-manipulator and some buttons to toggle the visible depth of the structure:
$(function() {
$("#jsonview").treeManipulator({
structure: "> ul > li",
opened: ".collapser:contains('-')",
closed: ".collapser:contains('+')"
});
$(".controls a").click(function(e) {
var depth = $(this).data('depth');
$("#jsonview")
.treeManipulator('close', depth + 1)
.treeManipulator('open', depth);
});
});