Created
March 19, 2013 10:41
-
-
Save richo/5195156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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