##// END OF EJS Templates
Fixed: error when creating a project with a version format custom field (#10218)....
Fixed: error when creating a project with a version format custom field (#10218). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8865 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8730:1ad977f7129b
r8745:cccfed7006f1
Show More
revision_graph.js
97 lines | 3.4 KiB | application/javascript | JavascriptLexer
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605
Etienne Massip
Integrated revision graph into scmid column....
r8730 function revisionGraph(holder, commits_hash, graph_space) {
Etienne Massip
Revision graph code cleanup....
r8653
Etienne Massip
Integrated revision graph into scmid column....
r8730 var XSTEP = 20,
CIRCLE_INROW_OFFSET = 10;
Etienne Massip
Revision graph code cleanup....
r8653
var commits_by_scmid = $H(commits_hash),
commits = commits_by_scmid.values();
Etienne Massip
Integrated revision graph into scmid column....
r8730 var max_rdmid = commits.length - 1;
var commit_table_rows = $$('table.changesets tr.changeset');
Etienne Massip
Revision graph code cleanup....
r8653
Etienne Massip
Integrated revision graph into scmid column....
r8730 // init dimensions
var graph_offset = $(holder).getLayout().get('top'),
graph_width = (graph_space + 1) * XSTEP,
graph_height = commit_table_rows[max_rdmid].getLayout().get('top') + commit_table_rows[max_rdmid].getLayout().get('height') - graph_offset;
Etienne Massip
Revision graph code cleanup....
r8653
// init colors
Etienne Massip
Integrated revision graph into scmid column....
r8730 var colors = [];
for (var k = 0; k < graph_space + 1; k++) {
Etienne Massip
Revision graph code cleanup....
r8653 colors.push(Raphael.getColor());
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 }
Etienne Massip
Revision graph code cleanup....
r8653
// create graph
var graph = Raphael(holder, graph_width, graph_height),
top = graph.set();
var parent_commit;
var x, y, parent_x, parent_y;
var path, longrefs, shortrefs, label, labelBBox;
commits.each(function(commit) {
Etienne Massip
Integrated revision graph into scmid column....
r8730 y = commit_table_rows[max_rdmid - commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET;
x = XSTEP / 2 + XSTEP * commit.space;
Etienne Massip
Revision graph code cleanup....
r8653
graph.circle(x, y, 3).attr({fill: colors[commit.space], stroke: 'none'});
// title
if (commit.refs != null && commit.refs != '') {
longrefs = commit.refs;
shortrefs = longrefs.length > 15 ? longrefs.substr(0, 13) + '...' : longrefs;
label = graph.text(x + 5, y + 5, shortrefs)
.attr({
font: '12px Fontin-Sans, Arial',
fill: '#666',
title: longrefs,
cursor: 'pointer',
rotation: '0'});
labelBBox = label.getBBox();
label.translate(labelBBox.width / 2, -labelBBox.height / 3);
}
// paths to parents
commit.parent_scmids.each(function(parent_scmid) {
parent_commit = commits_by_scmid.get(parent_scmid);
if (parent_commit) {
Etienne Massip
Integrated revision graph into scmid column....
r8730 parent_y = commit_table_rows[max_rdmid - parent_commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET;
parent_x = XSTEP / 2 + XSTEP * parent_commit.space;
Etienne Massip
Revision graph code cleanup....
r8653
if (parent_commit.space == commit.space) {
// vertical path
path = graph.path([
'M', x, y,
'V', parent_y]);
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 } else {
Etienne Massip
Revision graph code cleanup....
r8653 // path to a commit in a different branch (Bezier curve)
path = graph.path([
'M', x, y,
'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 }
} else {
Etienne Massip
Revision graph code cleanup....
r8653 // vertical path ending at the bottom of the graph
path = graph.path([
'M', x, y,
'V', graph_height]);
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 }
Etienne Massip
Revision graph code cleanup....
r8653 path.attr({stroke: colors[commit.space], "stroke-width": 1.5});
});
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605
Etienne Massip
Revision graph code cleanup....
r8653 top.push(graph.circle(x, y, 10)
.attr({
fill: '#000',
opacity: 0,
cursor: 'pointer',
href: commit.href})
.hover(function () {}, function () {}));
});
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605
Etienne Massip
Revision graph code cleanup....
r8653 top.toFront();
Toshi MARUYAMA
scm: git: mercurial: add a new feature of revision graph (#5501)...
r7605 };