diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-03 19:11:50 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-04 00:04:38 +0200 |
| commit | 7dc78649f57f9cd7db25abf35fece19680a80a84 (patch) | |
| tree | 84f7c12387c24d09819b4df59aede84ef4b4da98 | |
| parent | 5c60b07877f99e22809849dffe756ff44a9b96cb (diff) | |
selection: add update (reduces code in rz_core)
| -rw-r--r-- | src/view/selection.js | 21 |
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, }; }); |
