summaryrefslogtreecommitdiff
path: root/src/view
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-12-03 19:11:50 +0200
committerAlon Levy <alon@pobox.com>2014-12-04 00:04:38 +0200
commit7dc78649f57f9cd7db25abf35fece19680a80a84 (patch)
tree84f7c12387c24d09819b4df59aede84ef4b4da98 /src/view
parent5c60b07877f99e22809849dffe756ff44a9b96cb (diff)
selection: add update (reduces code in rz_core)
Diffstat (limited to 'src/view')
-rw-r--r--src/view/selection.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/view/selection.js b/src/view/selection.js
index bc1c38c0..dfc043e1 100644
--- a/src/view/selection.js
+++ b/src/view/selection.js
@@ -70,11 +70,24 @@ var clear = function() {
get_rz_core().graph.setRegularState();
}
+function all(arr, pred)
+{
+ return arr.length == arr.filter(pred).length;
+}
+
+var update = function(nodes) {
+ clear();
+ if (all(nodes, function(node) { return node.state != 'chosen'; })) {
+ connectedComponent(nodes);
+ }
+}
+
return {
- 'byVisitors': byVisitors,
- 'connectedComponent': connectedComponent,
- 'clear': clear,
- 'selected_class': selected_class,
+ byVisitors: byVisitors,
+ connectedComponent: connectedComponent,
+ clear: clear,
+ update: update,
+ selected_class: selected_class,
};
});