diff options
author | Adam Spiers <git@adamspiers.org> | 2015-01-11 14:58:49 +0000 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2015-01-11 15:32:58 +0000 |
commit | 17359971ad244262ba513769708086cb9ec13941 (patch) | |
tree | c72c5c9935b33935578299b2ea7b9df8fd24b7bb /html/js/git-deps-graph.coffee | |
parent | 07ed46a54333d24ccbde60346658c98075316de0 (diff) | |
download | git-deps-17359971ad244262ba513769708086cb9ec13941.tar.gz |
double-click to explore commit (#15)
Later we'll change this to clicking a plus icon to expand.
Diffstat (limited to 'html/js/git-deps-graph.coffee')
-rw-r--r-- | html/js/git-deps-graph.coffee | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/html/js/git-deps-graph.coffee b/html/js/git-deps-graph.coffee index 7762745..84bbd83 100644 --- a/html/js/git-deps-graph.coffee +++ b/html/js/git-deps-graph.coffee @@ -180,6 +180,7 @@ draw_graph = (commitish) -> unless new_data gdn.warn "No new commits or dependencies found!" + update_rect_explored() return new_data_notification new_data @@ -255,7 +256,18 @@ draw_nodes = (fg, node) -> hide_tip_on_drag = d3cola.drag().on("dragstart", tip.hide) node.call hide_tip_on_drag - rect = node.append("rect").attr("rx", 5).attr("ry", 5) + rect = node.append("rect") \ + .attr("rx", 5) \ + .attr("ry", 5) + + update_rect_explored() + + rect.on "dblclick", (d) -> + if d.explored + gdn.warn "Commit #{d.name} already explored" + else + add_commitish d.sha1 + label = node.append("text").text((d) -> d.name ).each((d) -> @@ -271,6 +283,7 @@ draw_nodes = (fg, node) -> d.width = d.rect_width + 2 * RECT_MARGIN d.height = d.rect_height + 2 * RECT_MARGIN ) + position_nodes rect, label, tip position_nodes = (rect, label, tip) -> @@ -298,6 +311,11 @@ position_nodes = (rect, label, tip) -> # d3cola.avoidOverlaps true # d3cola.start +update_rect_explored = () -> + d3.selectAll(".node rect").attr "class", (d) -> + console.log "rect #{d.name}: #{d.explored}" + if d.explored then "explored" else "unexplored" + tip_html = (d) -> fragment = $(tip_template).clone() top = fragment.find("#fragment") |