comparison .svn/pristine/7d/7d3cbe14fc84c9fc42efa7908095cf2d1fad9643.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 var revisionGraph = null;
2
3 function drawRevisionGraph(holder, commits_hash, graph_space) {
4 var XSTEP = 20,
5 CIRCLE_INROW_OFFSET = 10;
6 var commits_by_scmid = commits_hash,
7 commits = $.map(commits_by_scmid, function(val,i){return val;});
8 var max_rdmid = commits.length - 1;
9 var commit_table_rows = $('table.changesets tr.changeset');
10
11 // create graph
12 if(revisionGraph != null)
13 revisionGraph.clear();
14 else
15 revisionGraph = Raphael(holder);
16
17 var top = revisionGraph.set();
18 // init dimensions
19 var graph_x_offset = commit_table_rows.first().find('td').first().position().left - $(holder).position().left,
20 graph_y_offset = $(holder).position().top,
21 graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
22 graph_bottom = commit_table_rows.last().position().top + commit_table_rows.last().height() - graph_y_offset;
23
24 revisionGraph.setSize(graph_right_side, graph_bottom);
25
26 // init colors
27 var colors = [];
28 Raphael.getColor.reset();
29 for (var k = 0; k <= graph_space; k++) {
30 colors.push(Raphael.getColor());
31 }
32
33 var parent_commit;
34 var x, y, parent_x, parent_y;
35 var path, title;
36 var revision_dot_overlay;
37 $.each(commits, function(index, commit) {
38 if (!commit.hasOwnProperty("space"))
39 commit.space = 0;
40
41 y = commit_table_rows.eq(max_rdmid - commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
42 x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
43 revisionGraph.circle(x, y, 3)
44 .attr({
45 fill: colors[commit.space],
46 stroke: 'none'
47 }).toFront();
48 // paths to parents
49 $.each(commit.parent_scmids, function(index, parent_scmid) {
50 parent_commit = commits_by_scmid[parent_scmid];
51 if (parent_commit) {
52 if (!parent_commit.hasOwnProperty("space"))
53 parent_commit.space = 0;
54
55 parent_y = commit_table_rows.eq(max_rdmid - parent_commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
56 parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
57 if (parent_commit.space == commit.space) {
58 // vertical path
59 path = revisionGraph.path([
60 'M', x, y,
61 'V', parent_y]);
62 } else {
63 // path to a commit in a different branch (Bezier curve)
64 path = revisionGraph.path([
65 'M', x, y,
66 'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
67 'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
68 }
69 } else {
70 // vertical path ending at the bottom of the revisionGraph
71 path = revisionGraph.path([
72 'M', x, y,
73 'V', graph_bottom]);
74 }
75 path.attr({stroke: colors[commit.space], "stroke-width": 1.5}).toBack();
76 });
77 revision_dot_overlay = revisionGraph.circle(x, y, 10);
78 revision_dot_overlay
79 .attr({
80 fill: '#000',
81 opacity: 0,
82 cursor: 'pointer',
83 href: commit.href
84 });
85
86 if(commit.refs != null && commit.refs.length > 0) {
87 title = document.createElementNS(revisionGraph.canvas.namespaceURI, 'title');
88 title.appendChild(document.createTextNode(commit.refs));
89 revision_dot_overlay.node.appendChild(title);
90 }
91 top.push(revision_dot_overlay);
92 });
93 top.toFront();
94 };