From d21464f4b8063945e7657e71832c1b4c3e5b9e86 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 4 Mar 2015 01:02:22 +0200 Subject: client:selection: invert on shift --- src/client/view/graph_view.js | 6 +++--- src/client/view/selection.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/client') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 32540bea..ff7de845 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -288,7 +288,7 @@ function GraphView(spec) { graph.links__delete([that.link.id]); }); view.edge_info.show(d); - selection.update([src, dst], d3.event.shiftKey); + (d3.event.shiftKey? selection.invert : selection.update)([src, dst]); }); link.attr("class", function(d, i){ @@ -421,7 +421,7 @@ function GraphView(spec) { } if (!temporary) { svgInput.enable(this, d, nodeTextX(d)); - selection.update([d], d3.event.shiftKey); + (d3.event.shiftKey ? selection.invert : selection.update)([d]); showNodeInfo(graph.find_node__by_id(this.parentNode.id)); } d3.event.stopPropagation(); @@ -484,7 +484,7 @@ function GraphView(spec) { return; } d3.event.stopPropagation(); - selection.update([d], d3.event.shiftKey); + (d3.event.shiftKey ? selection.invert : selection.update)([d]); if(!temporary) { showNodeInfo(d); } diff --git a/src/client/view/selection.js b/src/client/view/selection.js index 5e24e801..6ac675aa 100644 --- a/src/client/view/selection.js +++ b/src/client/view/selection.js @@ -213,9 +213,9 @@ var inner_update = function(nodes) connectedComponent(nodes); } -var update = function(nodes, append) +var update = function(nodes) { - var new_nodes = append ? _.union(root_nodes, nodes) : nodes; + var new_nodes = nodes; var not_same = !arr_compare(new_nodes, root_nodes); if (not_same) { @@ -223,6 +223,11 @@ var update = function(nodes, append) } } +var invert = function(nodes) +{ + update(_.union(_.difference(root_nodes, nodes), _.difference(nodes, root_nodes))); +} + var setup_toolbar = function(main_graph) { var merge_root_selection = function() { @@ -263,6 +268,7 @@ return { byVisitors: byVisitors, connectedComponent: connectedComponent, clear: clear, + invert: invert, update: update, selected_class__node: selected_class__node, selected_class__link: selected_class__link, -- cgit v1.3.1