added selectNode and deselectNode functions

This commit is contained in:
Devin Howard 2013-02-22 18:33:18 -05:00
parent 88522be80c
commit b336af1d53

View file

@ -53,6 +53,24 @@ function nodeWasDoubleClicked() {
} }
}//nodeWasDoubleClicked; }//nodeWasDoubleClicked;
function selectNode(node) {
node.selected = true;
node.setData('dim', 30, 'current');
node.setData('onCanvas',true);
node.eachAdjacency(function (adj) {
selectEdge(adj);
});
}
function deselectNode(node) {
delete node.selected;
node.setData('onCanvas', false);
node.eachAdjacency(function(adj) {
deselectEdge(adj);
});
node.setData('dim', 25, 'current');
}
function selectNodeOnClickHandler(node, e) { function selectNodeOnClickHandler(node, e) {
if (Mconsole.busy) return; if (Mconsole.busy) return;
@ -66,28 +84,14 @@ function selectNodeOnClickHandler(node, e) {
if (!e.shiftKey) { if (!e.shiftKey) {
Mconsole.graph.eachNode(function (n) { Mconsole.graph.eachNode(function (n) {
if (n.id != node.id) { if (n.id != node.id) {
delete n.selected; deselectNode(n);
n.setData('onCanvas',false);
} }
n.setData('dim', 25, 'current');
n.eachAdjacency(function (adj) {
deselectEdge(adj);
});
}); });
} }
if (!node.selected) { if (node.selected) {
node.selected = true; deselectNode(node);
node.setData('dim', 30, 'current');
node.setData('onCanvas',true);
node.eachAdjacency(function (adj) {
selectEdge(adj);
});
Mconsole.plot();
} else { } else {
node.setData('dim', 25, 'current'); selectNode(node);
delete node.selected;
node.setData('onCanvas',false);
} }
//trigger animation to final styles //trigger animation to final styles
Mconsole.fx.animate({ Mconsole.fx.animate({