##// END OF EJS Templates
Better handling of horizontal position....
Etienne Massip -
r8747:d8fed7d515bf
parent child
Show More
@@ -1,104 +1,105
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 = $H(commits_hash),
9 9 commits = commits_by_scmid.values();
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 var graph_offset = $(holder).getLayout().get('top'),
25 graph_width = (graph_space + 1) * XSTEP,
26 graph_height = commit_table_rows[max_rdmid].getLayout().get('top') + commit_table_rows[max_rdmid].getLayout().get('height') - graph_offset;
24 var graph_x_offset = Element.select(commit_table_rows.first(),'td').first().getLayout().get('left') - $(holder).getLayout().get('left'),
25 graph_y_offset = $(holder).getLayout().get('top'),
26 graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
27 graph_bottom = commit_table_rows.last().getLayout().get('top') + commit_table_rows.last().getLayout().get('height') - graph_y_offset;
27 28
28 revisionGraph.setSize(graph_width, graph_height);
29 revisionGraph.setSize(graph_right_side, graph_bottom);
29 30
30 31 // init colors
31 32 var colors = [];
32 33 Raphael.getColor.reset();
33 34 for (var k = 0; k <= graph_space; k++) {
34 35 colors.push(Raphael.getColor());
35 36 }
36 37
37 38 var parent_commit;
38 39 var x, y, parent_x, parent_y;
39 40 var path, longrefs, shortrefs, label, labelBBox;
40 41
41 42 commits.each(function(commit) {
42 43
43 y = commit_table_rows[max_rdmid - commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET;
44 x = XSTEP / 2 + XSTEP * commit.space;
44 y = commit_table_rows[max_rdmid - commit.rdmid].getLayout().get('top') - graph_y_offset + CIRCLE_INROW_OFFSET;
45 x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
45 46
46 47 revisionGraph.circle(x, y, 3).attr({fill: colors[commit.space], stroke: 'none'});
47 48
48 49 // title
49 50 if (commit.refs != null && commit.refs != '') {
50 51 longrefs = commit.refs;
51 52 shortrefs = longrefs.length > 15 ? longrefs.substr(0, 13) + '...' : longrefs;
52 53
53 54 label = revisionGraph.text(x + 5, y + 5, shortrefs)
54 55 .attr({
55 56 font: '12px Fontin-Sans, Arial',
56 57 fill: '#666',
57 58 title: longrefs,
58 59 cursor: 'pointer',
59 60 rotation: '0'});
60 61
61 62 labelBBox = label.getBBox();
62 63 label.translate(labelBBox.width / 2, -labelBBox.height / 3);
63 64 }
64 65
65 66 // paths to parents
66 67 commit.parent_scmids.each(function(parent_scmid) {
67 68 parent_commit = commits_by_scmid.get(parent_scmid);
68 69
69 70 if (parent_commit) {
70 parent_y = commit_table_rows[max_rdmid - parent_commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET;
71 parent_x = XSTEP / 2 + XSTEP * parent_commit.space;
71 parent_y = commit_table_rows[max_rdmid - parent_commit.rdmid].getLayout().get('top') - graph_y_offset + CIRCLE_INROW_OFFSET;
72 parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
72 73
73 74 if (parent_commit.space == commit.space) {
74 75 // vertical path
75 76 path = revisionGraph.path([
76 77 'M', x, y,
77 78 'V', parent_y]);
78 79 } else {
79 80 // path to a commit in a different branch (Bezier curve)
80 81 path = revisionGraph.path([
81 82 'M', x, y,
82 83 'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
83 84 'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
84 85 }
85 86 } else {
86 87 // vertical path ending at the bottom of the revisionGraph
87 88 path = revisionGraph.path([
88 89 'M', x, y,
89 'V', graph_height]);
90 'V', graph_bottom]);
90 91 }
91 92 path.attr({stroke: colors[commit.space], "stroke-width": 1.5});
92 93 });
93 94
94 95 top.push(revisionGraph.circle(x, y, 10)
95 96 .attr({
96 97 fill: '#000',
97 98 opacity: 0,
98 99 cursor: 'pointer',
99 100 href: commit.href})
100 101 .hover(function () {}, function () {}));
101 102 });
102 103
103 104 top.toFront();
104 105 };
@@ -1,201 +1,201
1 1
2 2 table.revision-info td {
3 3 margin: 0px;
4 4 padding: 0px;
5 5 }
6 6
7 div.revision-graph { position: absolute; overflow:hidden; }
7 div.revision-graph { position: absolute; }
8 8
9 9 div.changeset-changes ul { margin: 0; padding: 0; }
10 10 div.changeset-changes ul > ul { margin-left: 18px; padding: 0; }
11 11
12 12 li.change {
13 13 list-style-type:none;
14 14 background-image: url(../images/bullet_black.png);
15 15 background-position: 1px 1px;
16 16 background-repeat: no-repeat;
17 17 padding-top: 1px;
18 18 padding-bottom: 1px;
19 19 padding-left: 20px;
20 20 margin: 0;
21 21 }
22 22 li.change.folder { background-image: url(../images/folder_open.png); }
23 23 li.change.folder.change-A { background-image: url(../images/folder_open_add.png); }
24 24 li.change.folder.change-M { background-image: url(../images/folder_open_orange.png); }
25 25 li.change.change-A { background-image: url(../images/bullet_add.png); }
26 26 li.change.change-M { background-image: url(../images/bullet_orange.png); }
27 27 li.change.change-C { background-image: url(../images/bullet_blue.png); }
28 28 li.change.change-R { background-image: url(../images/bullet_purple.png); }
29 29 li.change.change-D { background-image: url(../images/bullet_delete.png); }
30 30
31 31 li.change .copied-from { font-style: italic; color: #999; font-size: 0.9em; }
32 32 li.change .copied-from:before { content: " - "}
33 33
34 34 #changes-legend { float: right; font-size: 0.8em; margin: 0; }
35 35 #changes-legend li { float: left; background-position: 5px 0; }
36 36
37 37 table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; background-color: #fafafa; }
38 38 table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
39 39 table.filecontent th.filename { background-color: #e4e4d4; text-align: left; padding: 0.2em;}
40 40 table.filecontent tr.spacing th { text-align:center; }
41 41 table.filecontent tr.spacing td { height: 0.4em; background: #EAF2F5;}
42 42 table.filecontent th.line-num {
43 43 border: 1px solid #d7d7d7;
44 44 font-size: 0.8em;
45 45 text-align: right;
46 46 width: 2%;
47 47 padding-right: 3px;
48 48 color: #999;
49 49 user-select: none;
50 50 -moz-user-select: none;
51 51 -o-user-select: none;
52 52 -ms-user-select: none;
53 53 -webkit-user-select: none;
54 54 }
55 55 table.filecontent th.line-num a {
56 56 text-decoration: none;
57 57 color: inherit;
58 58 }
59 59 table.filecontent td.line-code pre {
60 60 margin: 0px;
61 61 white-space: pre-wrap;
62 62 }
63 63
64 64 /* 12 different colors for the annonate view */
65 65 table.annotate tr.bloc-0 {background: #FFFFBF;}
66 66 table.annotate tr.bloc-1 {background: #EABFFF;}
67 67 table.annotate tr.bloc-2 {background: #BFFFFF;}
68 68 table.annotate tr.bloc-3 {background: #FFD9BF;}
69 69 table.annotate tr.bloc-4 {background: #E6FFBF;}
70 70 table.annotate tr.bloc-5 {background: #BFCFFF;}
71 71 table.annotate tr.bloc-6 {background: #FFBFEF;}
72 72 table.annotate tr.bloc-7 {background: #FFE6BF;}
73 73 table.annotate tr.bloc-8 {background: #FFE680;}
74 74 table.annotate tr.bloc-9 {background: #AA80FF;}
75 75 table.annotate tr.bloc-10 {background: #FFBFDC;}
76 76 table.annotate tr.bloc-11 {background: #BFE4FF;}
77 77
78 78 table.annotate td.revision {
79 79 text-align: center;
80 80 width: 2%;
81 81 padding-left: 1em;
82 82 background: inherit;
83 83 }
84 84
85 85 table.annotate td.author {
86 86 text-align: center;
87 87 border-right: 1px solid #d7d7d7;
88 88 white-space: nowrap;
89 89 padding-left: 1em;
90 90 padding-right: 1em;
91 91 width: 3%;
92 92 background: inherit;
93 93 font-size: 90%;
94 94 }
95 95
96 96 table.annotate td.line-code { background-color: #fafafa; }
97 97
98 98 div.action_M { background: #fd8 }
99 99 div.action_D { background: #f88 }
100 100 div.action_A { background: #bfb }
101 101
102 102 /************* CodeRay styles *************/
103 103 .syntaxhl div {display: inline;}
104 104 .syntaxhl .line-numbers {
105 105 padding: 2px 4px 2px 4px; background-color: #eee; margin:0px 5px 0px 0px;
106 106 user-select: none;
107 107 -moz-user-select: none;
108 108 -o-user-select: none;
109 109 -ms-user-select: none;
110 110 -webkit-user-select: none;
111 111 }
112 112 .syntaxhl .code pre { overflow: auto }
113 113 .syntaxhl .debug { color:white ! important; background:blue ! important; }
114 114
115 115 .syntaxhl .attribute-name { color:#b48 }
116 116 .syntaxhl .annotation { color:#007 }
117 117 .syntaxhl .attribute-value { color:#700 }
118 118 .syntaxhl .binary { color:#509 }
119 119
120 120 .syntaxhl .comment { color:#777 }
121 121 .syntaxhl .comment .char { color:#444 }
122 122 .syntaxhl .comment .delimiter { color:#444 }
123 123
124 124 .syntaxhl .char { color:#D20 }
125 125 .syntaxhl .char .content { color:#D20 }
126 126 .syntaxhl .char .delimiter { color:#710 }
127 127
128 128 .syntaxhl .class { color:#B06; font-weight:bold }
129 129 .syntaxhl .complex { color:#A08 }
130 130 .syntaxhl .constant { color:#036; font-weight:bold }
131 131 .syntaxhl .color { color:#0A0 }
132 132 .syntaxhl .class-variable { color:#369 }
133 133 .syntaxhl .decorator { color:#B0B }
134 134 .syntaxhl .definition { color:#099; font-weight:bold }
135 135 .syntaxhl .directive { color:#088; font-weight:bold }
136 136 .syntaxhl .delimiter { color:black }
137 137 .syntaxhl .doc { color:#970 }
138 138 .syntaxhl .doctype { color:#34b }
139 139 .syntaxhl .doc-string { color:#D42; font-weight:bold }
140 140 .syntaxhl .escape { color:#666 }
141 141 .syntaxhl .entity { color:#800; font-weight:bold }
142 142 .syntaxhl .error { color:#F00; background-color:#FAA }
143 143 .syntaxhl .exception { color:#C00; font-weight:bold }
144 144 .syntaxhl .float { color:#60E }
145 145 .syntaxhl .function { color:#06B; font-weight:bold }
146 146 .syntaxhl .global-variable { color:#d70 }
147 147 .syntaxhl .hex { color:#02b }
148 148 .syntaxhl .integer { color:#00D }
149 149 .syntaxhl .include { color:#B44; font-weight:bold }
150 150 .syntaxhl .imaginary { color:#f00 }
151 151
152 152 .syntaxhl .inline { background-color: hsla(0,0%,0%,0.07); color: black }
153 153 .syntaxhl .inline-delimiter { font-weight: bold; color: #666 }
154 154
155 155 .syntaxhl .instance-variable { color:#33B }
156 156 .syntaxhl .label { color:#970; font-weight:bold }
157 157 .syntaxhl .local-variable { color:#963 }
158 158 .syntaxhl .namespace { color:#707; font-weight:bold }
159 159 .syntaxhl .octal { color:#40E }
160 160 .syntaxhl .operator { }
161 161 .syntaxhl .predefined-constant { color:#069 }
162 162 .syntaxhl .predefined { color:#369; font-weight:bold }
163 163 .syntaxhl .predefined-type { color:#0a5; font-weight:bold }
164 164 .syntaxhl .preprocessor { color:#579 }
165 165 .syntaxhl .pseudo-class { color:#00C; font-weight:bold }
166 166 .syntaxhl .reserved { color:#080; font-weight:bold }
167 167
168 168 .syntaxhl .key .char { color: #60f }
169 169 .syntaxhl .key .delimiter { color: #404 }
170 170 .syntaxhl .key { color: #606 }
171 171 .syntaxhl .keyword { color:#080; font-weight:bold }
172 172
173 173 .syntaxhl .regexp { background-color:hsla(300,100%,50%,0.06); }
174 174 .syntaxhl .regexp .content { color:#808 }
175 175 .syntaxhl .regexp .delimiter { color:#404 }
176 176 .syntaxhl .regexp .modifier { color:#C2C }
177 177
178 178 .syntaxhl .string { background-color:hsla(0,100%,50%,0.05); }
179 179 .syntaxhl .string .content { color: #D20 }
180 180 .syntaxhl .string .char { color: #b0b }
181 181 .syntaxhl .string .delimiter { color: #710 }
182 182 .syntaxhl .string .modifier { color: #E40 }
183 183
184 184 .syntaxhl .shell { background-color:hsla(120,100%,50%,0.06); }
185 185 .syntaxhl .shell .content { color:#2B2 }
186 186 .syntaxhl .shell .delimiter { color:#161 }
187 187
188 188 .syntaxhl .symbol { color:#A60 }
189 189 .syntaxhl .symbol .content { color:#A60 }
190 190 .syntaxhl .symbol .delimiter { color:#630 }
191 191
192 192 .syntaxhl .tag { color:#070 }
193 193 .syntaxhl .type { color:#339; font-weight:bold }
194 194 .syntaxhl .value { color: #088; }
195 195 .syntaxhl .variable { color:#037 }
196 196
197 197 .syntaxhl .insert { background: hsla(120,100%,50%,0.12) }
198 198 .syntaxhl .delete { background: hsla(0,100%,50%,0.12) }
199 199 .syntaxhl .change { color: #bbf; background: #007; }
200 200 .syntaxhl .head { color: #f8f; background: #505 }
201 201 .syntaxhl .head .filename { color: white; }
General Comments 0
You need to be logged in to leave comments. Login now