Chris@909: var commits = chunk.commits, Chris@909: comms = {}, Chris@909: pixelsX = [], Chris@909: pixelsY = [], Chris@909: mmax = Math.max, Chris@909: max_rdmid = 0, Chris@909: max_space = 0, Chris@909: parents = {}; Chris@909: for (var i = 0, ii = commits.length; i < ii; i++) { Chris@909: for (var j = 0, jj = commits[i].parents.length; j < jj; j++) { Chris@909: parents[commits[i].parents[j][0]] = true; Chris@909: } Chris@909: max_rdmid = Math.max(max_rdmid, commits[i].rdmid); Chris@909: max_space = Math.max(max_space, commits[i].space); Chris@909: } Chris@909: Chris@909: for (i = 0; i < ii; i++) { Chris@909: if (commits[i].scmid in parents) { Chris@909: commits[i].isParent = true; Chris@909: } Chris@909: comms[commits[i].scmid] = commits[i]; Chris@909: } Chris@909: var colors = ["#000"]; Chris@909: for (var k = 0; k < max_space; k++) { Chris@909: colors.push(Raphael.getColor()); Chris@909: } Chris@909: Chris@909: function branchGraph(holder) { Chris@909: var xstep = 20; Chris@909: var ystep = $$('tr.changeset')[0].getHeight(); Chris@909: var ch, cw; Chris@909: cw = max_space * xstep + xstep; Chris@909: ch = max_rdmid * ystep + ystep; Chris@909: var r = Raphael("holder", cw, ch), Chris@909: top = r.set(); Chris@909: var cuday = 0, cumonth = ""; Chris@909: Chris@909: for (i = 0; i < ii; i++) { Chris@909: var x, y; Chris@909: y = 10 + ystep *(max_rdmid - commits[i].rdmid); Chris@909: x = 3 + xstep * commits[i].space; Chris@909: var stroke = "none"; Chris@909: r.circle(x, y, 3).attr({fill: colors[commits[i].space], stroke: stroke}); Chris@909: if (commits[i].refs != null && commits[i].refs != "") { Chris@909: var longrefs = commits[i].refs Chris@909: var shortrefs = commits[i].refs; Chris@909: if (shortrefs.length > 15) { Chris@909: shortrefs = shortrefs.substr(0,13) + "..."; Chris@909: } Chris@909: var t = r.text(x+5,y+5,shortrefs).attr({font: "12px Fontin-Sans, Arial", fill: "#666", Chris@909: title: longrefs, cursor: "pointer", rotation: "0"}); Chris@909: Chris@909: var textbox = t.getBBox(); Chris@909: t.translate(textbox.width / 2, textbox.height / -3); Chris@909: } Chris@909: for (var j = 0, jj = commits[i].parents.length; j < jj; j++) { Chris@909: var c = comms[commits[i].parents[j][0]]; Chris@909: var p,arrow; Chris@909: if (c) { Chris@909: var cy, cx; Chris@909: cy = 10 + ystep * (max_rdmid - c.rdmid), Chris@909: cx = 3 + xstep * c.space; Chris@909: Chris@909: if (c.space == commits[i].space) { Chris@909: p = r.path("M" + x + "," + y + "L" + cx + "," + cy); Chris@909: } else { Chris@909: p = r.path(["M", x, y, "C",x,y,x, y+(cy-y)/2,x+(cx-x)/2, y+(cy-y)/2, Chris@909: "C", x+(cx-x)/2,y+(cy-y)/2, cx, cy-(cy-y)/2, cx, cy]); Chris@909: } Chris@909: } else { Chris@909: p = r.path("M" + x + "," + y + "L" + x + "," + ch); Chris@909: } Chris@909: p.attr({stroke: colors[commits[i].space], "stroke-width": 1.5}); Chris@909: } Chris@909: (function (c, x, y) { Chris@909: top.push(r.circle(x, y, 10).attr({fill: "#000", opacity: 0, Chris@909: cursor: "pointer", href: commits[i].href}) Chris@909: .hover(function () {}, function () {}) Chris@909: ); Chris@909: }(commits[i], x, y)); Chris@909: } Chris@909: top.toFront(); Chris@909: var hw = holder.offsetWidth, Chris@909: hh = holder.offsetHeight, Chris@909: drag, Chris@909: dragger = function (e) { Chris@909: if (drag) { Chris@909: e = e || window.event; Chris@909: holder.scrollLeft = drag.sl - (e.clientX - drag.x); Chris@909: holder.scrollTop = drag.st - (e.clientY - drag.y); Chris@909: } Chris@909: }; Chris@909: holder.onmousedown = function (e) { Chris@909: e = e || window.event; Chris@909: drag = {x: e.clientX, y: e.clientY, st: holder.scrollTop, sl: holder.scrollLeft}; Chris@909: document.onmousemove = dragger; Chris@909: }; Chris@909: document.onmouseup = function () { Chris@909: drag = false; Chris@909: document.onmousemove = null; Chris@909: }; Chris@909: holder.scrollLeft = cw; Chris@909: }; Chris@909: Chris@909: Raphael.fn.popupit = function (x, y, set, dir, size) { Chris@909: dir = dir == null ? 2 : dir; Chris@909: size = size || 5; Chris@909: x = Math.round(x); Chris@909: y = Math.round(y); Chris@909: var bb = set.getBBox(), Chris@909: w = Math.round(bb.width / 2), Chris@909: h = Math.round(bb.height / 2), Chris@909: dx = [0, w + size * 2, 0, -w - size * 2], Chris@909: dy = [-h * 2 - size * 3, -h - size, 0, -h - size], Chris@909: p = ["M", x - dx[dir], y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), Chris@909: 0, "a", size, size, 0, 0, 1, -size, -size, Chris@909: "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, Chris@909: -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, Chris@909: "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), Chris@909: 0, "a", size, size, 0, 0, 1, size, size, Chris@909: "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, Chris@909: mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, Chris@909: "l", -mmax(w - size, 0), 0, "z"].join(","), Chris@909: xy = [{x: x, y: y + size * 2 + h}, Chris@909: {x: x - size * 2 - w, y: y}, Chris@909: {x: x, y: y - size * 2 - h}, Chris@909: {x: x + size * 2 + w, y: y}] Chris@909: [dir]; Chris@909: set.translate(xy.x - w - bb.x, xy.y - h - bb.y); Chris@909: return this.set(this.path(p).attr({fill: "#234", stroke: "none"}) Chris@909: .insertBefore(set.node ? set : set[0]), set); Chris@909: }; Chris@909: Chris@909: Raphael.fn.popup = function (x, y, text, dir, size) { Chris@909: dir = dir == null ? 2 : dir > 3 ? 3 : dir; Chris@909: size = size || 5; Chris@909: text = text || "$9.99"; Chris@909: var res = this.set(), Chris@909: d = 3; Chris@909: res.push(this.path().attr({fill: "#000", stroke: "#000"})); Chris@909: res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"})); Chris@909: res.update = function (X, Y, withAnimation) { Chris@909: X = X || x; Chris@909: Y = Y || y; Chris@909: var bb = this[1].getBBox(), Chris@909: w = bb.width / 2, Chris@909: h = bb.height / 2, Chris@909: dx = [0, w + size * 2, 0, -w - size * 2], Chris@909: dy = [-h * 2 - size * 3, -h - size, 0, -h - size], Chris@909: p = ["M", X - dx[dir], Y - dy[dir], "l", -size, (dir == 2) * -size, Chris@909: -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size, Chris@909: "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, Chris@909: 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, Chris@909: "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), Chris@909: 0, "a", size, size, 0, 0, 1, size, size, Chris@909: "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, Chris@909: mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, Chris@909: "l", -mmax(w - size, 0), 0, "z"].join(","), Chris@909: xy = [{x: X, y: Y + size * 2 + h}, Chris@909: {x: X - size * 2 - w, y: Y}, Chris@909: {x: X, y: Y - size * 2 - h}, Chris@909: {x: X + size * 2 + w, y: Y}] Chris@909: [dir]; Chris@909: xy.path = p; Chris@909: if (withAnimation) { Chris@909: this.animate(xy, 500, ">"); Chris@909: } else { Chris@909: this.attr(xy); Chris@909: } Chris@909: return this; Chris@909: }; Chris@909: return res.update(x, y); Chris@909: };