Mercurial > hg
comparison mercurial/templates/spartan/graph.tmpl @ 35255:ad0de63e1d6a
hgweb: move common vertex code to Graph.prototype
Just to give some context to the return values: vertex() needs to return two
HTML elements as strings, <li> to be used as a background and a <li> to be
shown in foreground. The latter was made obsolete recently when changesets
started to be rendered server-side, but background elements are still useful
for now.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Wed, 06 Dec 2017 12:10:16 +0800 |
parents | 66c11a66ad1a |
children | 27ab3150cd50 |
comparison
equal
deleted
inserted
replaced
35254:9c99541e3d56 | 35255:ad0de63e1d6a |
---|---|
42 var data = {jsdata|json}; | 42 var data = {jsdata|json}; |
43 var graph = new Graph(); | 43 var graph = new Graph(); |
44 graph.scale({bg_height}); | 44 graph.scale({bg_height}); |
45 | 45 |
46 graph.vertex = function(x, y, radius, color, parity, cur) \{ | 46 graph.vertex = function(x, y, radius, color, parity, cur) \{ |
47 | 47 Graph.prototype.vertex.apply(this, arguments); |
48 this.ctx.beginPath(); | 48 return ['<li class="bg parity' + parity + '"></li>', '']; |
49 color = this.setColor(color, 0.25, 0.75); | |
50 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true); | |
51 this.ctx.fill(); | |
52 | |
53 var bg = '<li class="bg parity' + parity + '"></li>'; | |
54 var left = (this.bg_height - this.box_size) + (this.columns + 1) * this.box_size; | |
55 var item = document.querySelector('[data-node="' + cur.node + '"]'); | |
56 if (item) \{ | |
57 item.style.paddingLeft = left + 'px'; | |
58 } | |
59 | |
60 return [bg, '']; | |
61 | |
62 } | 49 } |
63 | 50 |
64 graph.render(data); | 51 graph.render(data); |
65 | 52 |
66 // stop hiding script --> | 53 // stop hiding script --> |