##// END OF EJS Templates
replace tab to space at revision_graph.js...
Toshi MARUYAMA -
r10109:ee2481a3b90c
parent child
Show More
@@ -1,102 +1,102
1 1 var revisionGraph = null;
2 2
3 3 function drawRevisionGraph(holder, commits_hash, graph_space) {
4 4
5 5 var XSTEP = 20,
6 6 CIRCLE_INROW_OFFSET = 10;
7 7
8 8 var commits_by_scmid = commits_hash,
9 9 commits = $.map(commits_by_scmid, function(val,i){return val;});
10 10
11 11 var max_rdmid = commits.length - 1;
12 12
13 13 var commit_table_rows = $('table.changesets tr.changeset');
14 14
15 15 // create graph
16 16 if(revisionGraph != null)
17 17 revisionGraph.clear();
18 18 else
19 19 revisionGraph = Raphael(holder);
20 20
21 21 var top = revisionGraph.set();
22 22
23 23 // init dimensions
24 24 var graph_x_offset = commit_table_rows.first().find('td').first().position().left - $(holder).position().left,
25 25 graph_y_offset = $(holder).position().top,
26 26 graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
27 27 graph_bottom = commit_table_rows.last().position().top + commit_table_rows.last().height() - graph_y_offset;
28 28
29 29 revisionGraph.setSize(graph_right_side, graph_bottom);
30 30
31 31 // init colors
32 32 var colors = [];
33 33 Raphael.getColor.reset();
34 34 for (var k = 0; k <= graph_space; k++) {
35 35 colors.push(Raphael.getColor());
36 36 }
37 37
38 38 var parent_commit;
39 39 var x, y, parent_x, parent_y;
40 40 var path, title;
41 41 var revision_dot_overlay;
42 42
43 43 $.each(commits, function(index, commit) {
44 44
45 45 y = commit_table_rows.eq(max_rdmid - commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
46 46 x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
47 47
48 48 revisionGraph.circle(x, y, 3)
49 49 .attr({
50 50 fill: colors[commit.space],
51 51 stroke: 'none',
52 52 }).toFront();
53 53
54 54 // paths to parents
55 55 $.each(commit.parent_scmids, function(index, parent_scmid) {
56 56 parent_commit = commits_by_scmid[parent_scmid];
57 57
58 58 if (parent_commit) {
59 59 parent_y = commit_table_rows.eq(max_rdmid - parent_commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
60 60 parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
61 61
62 62 if (parent_commit.space == commit.space) {
63 63 // vertical path
64 64 path = revisionGraph.path([
65 65 'M', x, y,
66 66 'V', parent_y]);
67 67 } else {
68 68 // path to a commit in a different branch (Bezier curve)
69 69 path = revisionGraph.path([
70 70 'M', x, y,
71 71 'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
72 72 'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
73 73 }
74 74 } else {
75 75 // vertical path ending at the bottom of the revisionGraph
76 76 path = revisionGraph.path([
77 77 'M', x, y,
78 78 'V', graph_bottom]);
79 79 }
80 80 path.attr({stroke: colors[commit.space], "stroke-width": 1.5}).toBack();
81 81 });
82 82
83 83 revision_dot_overlay = revisionGraph.circle(x, y, 10);
84 84 revision_dot_overlay
85 85 .attr({
86 fill: '#000',
86 fill: '#000',
87 87 opacity: 0,
88 88 cursor: 'pointer',
89 89 href: commit.href
90 90 });
91 91
92 92 if(commit.refs != null && commit.refs.length > 0) {
93 93 title = document.createElementNS(revisionGraph.canvas.namespaceURI, 'title');
94 94 title.appendChild(document.createTextNode(commit.refs));
95 95 revision_dot_overlay.node.appendChild(title);
96 96 }
97 97
98 98 top.push(revision_dot_overlay);
99 99 });
100 100
101 101 top.toFront();
102 102 };
General Comments 0
You need to be logged in to leave comments. Login now