diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-03 18:38:06 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-09 10:30:37 +0200 |
| commit | eef818ad99c117df2b6abb46ab8144c297887d5b (patch) | |
| tree | 596f126c3b88abf48a22f159e469c8ab2a397538 /scripts/rhizicore.js | |
| parent | 6f1ed70fa0583417cb630d8e733e856e6bfc666d (diff) | |
split highlight (search neighborhood of node) between graph & rhizicore
multiple TODOs added in code. in general, datastructure = graph,
control/view state in rhizicore.
Diffstat (limited to 'scripts/rhizicore.js')
| -rw-r--r-- | scripts/rhizicore.js | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index bf4dd46e..2e20edda 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -267,9 +267,9 @@ function update(no_relayout) { } d3.event.stopPropagation(); if(d.state!=="temp") { - showInfo(d, i); + showInfo(d, i); } else { - graph.removeHighlight(); + removeHighlight(); } update(true); }); @@ -475,9 +475,49 @@ function tick(e) { node.attr('visibility', 'visible'); } +function removeHighlight() { + // TODO: stop manipulating state + var nodes = graph.nodes(), + links = graph.links(), + k = 0, j = 0; + + while (k < nodes.length) { + if (nodes[k]['state'] === "enter" || nodes[k]['state'] === "exit" || nodes[k]['state'] === "chosen") { + nodes[k]['state'] = "perm"; + } + k++; + } + while (j < links.length) { + links[j]['state'] = "perm"; + j++; + } +} + +function highlight(n) +{ + var connected = graph.getConnectedNodesAndLinks(n, 1), + i, + data; + + n.state = 'chosen'; + + for (i in connected.nodes) { + data = connected.nodes[i]; + node = data.node; + switch (data.type) { + case 'exit': + node.state = 'exit'; + break; + case 'enter': + node.state = 'enter'; + break; + }; + } +} + function showInfo(d, i) { - if (d.state !== "chosen") { - graph.highlightNode(d.id, null); + if (d.state !== "chosen" && d.state !== 'temp') { + highlight(d); $('.info').fadeIn(300); if (d.type === "deliverable") { @@ -532,7 +572,7 @@ function showInfo(d, i) { } }); } else { - graph.removeHighlight(); + removeHighlight(); $('.info').fadeOut(300); } graph.update(true); @@ -543,7 +583,7 @@ function mousedown() { $('.editinfo').css('left', 0); $('.editlinkinfo').css('top', -100); $('.editlinkinfo').css('left', 0); - graph.removeHighlight(); + removeHighlight(); $('.info').fadeOut(300); graph.update(true); } |
