diff options
| author | Alon Levy <alon@pobox.com> | 2015-04-12 19:06:37 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-04-12 19:06:45 +0200 |
| commit | 310295684fa1e146af9a0e9b3affc5bfdac75f3b (patch) | |
| tree | 9ec2b073864a440e3a583d447d9bbc83bed810d1 /src/client/view/graph_view.js | |
| parent | a4c41a96ebf99c1d972030adf6927476f973c93c (diff) | |
client: introduce zen mode
Diffstat (limited to 'src/client/view/graph_view.js')
| -rw-r--r-- | src/client/view/graph_view.js | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index a7d37052..3c97383f 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -155,6 +155,7 @@ function GraphView(spec) { vis, deliverables, filter_states, + zen_mode = false, // FIXME - want to use parent_element w, h, @@ -181,14 +182,14 @@ function GraphView(spec) { $(window).asEventStream('resize').map(update_window_size).onValue(function () { update_view(false); }); update_window_size(); - function node__is_shown(d) { + function node__pass_filter(d) { var state = filter_states && filter_states[d.type]; return temporary || state === undefined || state; } - function link__is_shown(d) { - return node__is_shown(d.__src) && node__is_shown(d.__dst); + function link__pass_filter(d) { + return node__pass_filter(d.__src) && node__pass_filter(d.__dst); } @@ -382,12 +383,20 @@ function GraphView(spec) { return urlValid(d) && image_endings[d.url.slice(d.url.lastIndexOf('.') + 1)] !== undefined; }; + function nodes__filtered() { + return graph.nodes().filter(node__pass_filter); + } + function nodes__visible() { - return graph.nodes().filter(node__is_shown); + return zen_mode ? selection.related() : nodes__filtered(); + } + + function links__filtered() { + return graph.links().filter(link__pass_filter); } function links__visible() { - return graph.links().filter(link__is_shown); + return zen_mode ? graph.find_links__by_nodes(selection.related()) : links__filtered(); } function update_view(relayout) { @@ -1256,6 +1265,17 @@ function GraphView(spec) { zoomInProgress = val; tick(); }); + + gv.link__pass_filter = link__pass_filter; + gv.node__pass_filter = node__pass_filter; + gv.zen_mode__toggle = function () { + zen_mode = !zen_mode; + update_view(true); + } + gv.zen_mode__cancel = function () { + zen_mode = false; + update_view(true); + } return gv; } |
