Permalink
Browse files

[History] Draw line to below if parent does not exist

  • Loading branch information...
1 parent 71b5ad2 commit 1a52570bd8889e2db147920e3b95c2f6a223d81e @alexandresalome alexandresalome committed Sep 19, 2012
Showing with 25 additions and 16 deletions.
  1. +25 −16 src/Gitonomy/Bundle/FrontendBundle/Resources/public/js/history.js
@@ -100,32 +100,37 @@ function history_graph(commits) {
var parents = commit.parents;
parents.forEach(function (parent) {
- if (positions[parent] === undefined) {
- return;
- }
+ if (positions[parent] !== undefined) {
- if (drawn[positions[parent]] === undefined) {
- matrix_draw(positions[parent]);
- }
+ if (drawn[positions[parent]] === undefined) {
+ matrix_draw(positions[parent]);
+ }
- if (commits[positions[parent]].children.length > 1) {
- family = commits[position].family;
+ if (commits[positions[parent]].children.length > 1) {
+ family = commits[position].family;
+ } else {
+ family = commits[positions[parent]].family;
+ }
} else {
- family = commits[positions[parent]].family;
+ family = commits[position].family;
}
- matrix_connect(commit.hash, parent, family);
+
+ matrix_line(commit.hash, parent, family);
});
}
- function matrix_connect(from, to, family) {
- if (positions[from] === undefined || positions[to] === undefined) {
- return;
- }
+ function matrix_line(from, to, family) {
var fromX = commits[positions[from]].x;
var fromY = commits[positions[from]].y;
- var toX = commits[positions[to]].x;
- var toY = commits[positions[to]].y;
+ var toX, toY;
+ if (positions[to] !== undefined) {
+ toX = commits[positions[to]].x;
+ toY = commits[positions[to]].y;
+ } else {
+ toX = null;
+ toY = commits.length;
+ }
var x,y;
@@ -138,6 +143,10 @@ function history_graph(commits) {
fromX = x;
}
+ if (null === toX) {
+ toX = fromX;
+ }
+
links.push([
{x: fromX, y: y, family: family},
{x: toX, y: y + 1}

0 comments on commit 1a52570

Please sign in to comment.