Skip to content

Instantly share code, notes, and snippets.

@richo
Created March 19, 2013 10:41
Show Gist options
  • Save richo/5195156 to your computer and use it in GitHub Desktop.
Save richo/5195156 to your computer and use it in GitHub Desktop.
var draw_plumbing = (function() {
var anchors = {
0: {
connector:"StateMachine",
paintStyle:{lineWidth:3,strokeStyle:"#056"},
endpoint:"Blank",
anchor:[[1, 0, 1, 0], [1, 1, 1, 0]],
overlays:[ ["PlainArrow", {location:1, width:7, length:3} ]]
},
1: {
connector:"StateMachine",
paintStyle:{lineWidth:3,strokeStyle:"#056"},
endpoint:"Blank",
anchor:[[0, 0, 1, 0], [0, 1, 1, 0]],
overlays:[ ["PlainArrow", {location:1, width:7, length:3} ]]
}
};
return function(content) {
var links = {};
var side = 0;
_.each(content, function(item) {
_.each(item.parents, function(parent_id) {
if (links[parent_id] === undefined)
links[parent_id] = [parent_id];
else {
links[parent_id].push(parent_id);
side++;
}
if ($("#" + parent_id).length > 0) {
console.log("Creating links");
item.connections.push(jsPlumb.connect({
source:item.hash,
target:parent_id
}, get_anchor(side)));
} else {
console.log("Not creating links, pretty sure it's a root node");
}
});
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment