The Unified and Autonomous Development Platform
imdwork
robin shine776b9ed32b8d
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.htmlindex f6f58e5ac4..af9835b1c4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.html@@ -1,19 +1,21 @@<wicket:panel><div class="commit-list"><div wicket:id="tooManyCommits" class="alert alert-warning"></div>- <table>- <tr wicket:id="commits">- <td class="avatar">- <span wicket:id="avatar"></span>- </td>- <td class="detail">- <div wicket:id="message"></div>- <div wicket:id="author" class="author"></div>- </td>- <td class="info">- <span wicket:id="hashAndCode"></span>- </td>- </tr>- </table>+ <ul class="list-unstyled">+ <li wicket:id="commits"><div wicket:id="commit"></div></li>+ </ul></div>+ <wicket:fragment wicket:id="commitFrag">+ <div class="avatar pull-left">+ <span wicket:id="avatar"></span>+ </div>+ <div class="detail pull-left">+ <div wicket:id="message" class="message"></div>+ <div wicket:id="contribution"></div>+ </div>+ <div wicket:id="hashAndCode" class="pull-right"></div>+ </wicket:fragment>+ <wicket:fragment wicket:id="dateFrag">+ <i class="fa fa-calendar"></i> <span wicket:id="date"></span>+ </wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.javaindex ac22890093..ff76e0c0ba 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/CommitListPanel.java@@ -1,17 +1,20 @@package com.pmease.gitplex.web.component.commitlist;+import java.util.ArrayList;import java.util.List;+import org.apache.wicket.behavior.AttributeAppender;import org.apache.wicket.markup.head.CssHeaderItem;import org.apache.wicket.markup.head.IHeaderResponse;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.markup.html.list.ListItem;import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Fragment;import org.apache.wicket.markup.html.panel.Panel;-import org.apache.wicket.model.AbstractReadOnlyModel;import org.apache.wicket.model.IModel;import org.apache.wicket.model.LoadableDetachableModel;import org.apache.wicket.request.resource.CssResourceReference;+import org.joda.time.DateTime;import com.pmease.commons.git.Commit;import com.pmease.gitplex.core.model.Repository;@@ -55,37 +58,56 @@ public class CommitListPanel extends Panel {protected List<Commit> load() {List<Commit> commits = commitsModel.getObject();if (commits.size() > Constants.MAX_DISPLAY_COMMITS)- return commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());- else- return commits;+ commits = commits.subList(commits.size()-Constants.MAX_DISPLAY_COMMITS, commits.size());+ return separateByDate(commits);}}) {@Override- protected void populateItem(final ListItem<Commit> item) {+ protected void populateItem(ListItem<Commit> item) {Commit commit = item.getModelObject();- item.add(new ContributorAvatars("avatar", commit.getAuthor(), commit.getCommitter()));-- item.add(new CommitMessagePanel("message", repoModel, new AbstractReadOnlyModel<Commit>() {-- @Override- public Commit getObject() {- return item.getModelObject();- }+ if (commit != null) {+ Fragment fragment = new Fragment("commit", "commitFrag", CommitListPanel.this);+ fragment.add(new ContributorAvatars("avatar", commit.getAuthor(), commit.getCommitter()));+ fragment.add(new CommitMessagePanel("message", repoModel, item.getModel()));+ fragment.add(new ContributionPanel("contribution", commit.getAuthor(), commit.getCommitter()));+ fragment.add(new HashAndCodePanel("hashAndCode", repoModel, commit.getHash()));+ fragment.add(AttributeAppender.append("class", "commit clearfix"));- }));-- item.add(new ContributionPanel("author", commit.getAuthor(), commit.getCommitter()));-- item.add(new HashAndCodePanel("hashAndCode", repoModel, commit.getHash()));+ item.add(fragment);+ } else {+ Fragment fragment = new Fragment("commit", "dateFrag", CommitListPanel.this);+ DateTime dateTime = new DateTime(getModelObject().get(item.getIndex()+1).getCommitter().getWhen());+ fragment.add(new Label("date", Constants.DATE_FORMATTER.print(dateTime)));+ if (item.getIndex() == 0)+ fragment.add(AttributeAppender.append("class", "date first"));+ else+ fragment.add(AttributeAppender.append("class", "date"));+ item.add(fragment);+ }}});}+ private List<Commit> separateByDate(List<Commit> commits) {+ List<Commit> separated = new ArrayList<>();+ DateTime groupTime = null;+ for (Commit commit: commits) {+ DateTime commitTime = new DateTime(commit.getCommitter().getWhen());+ if (groupTime == null || commitTime.getYear() != groupTime.getYear()+ || commitTime.getDayOfYear() != groupTime.getDayOfYear()) {+ groupTime = commitTime;+ separated.add(null);+ }+ separated.add(commit);+ }+ return separated;+ }+@Overridepublic void renderHead(IHeaderResponse response) {super.renderHead(response);diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.cssindex c62b910781..477eedf42d 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/commitlist/commit-list.css@@ -1,48 +1,46 @@-.commit-list {- border: 1px solid #CCC;- border-radius: 4px;+.commit-list>ul {+ margin-bottom: 0;}-.commit-list td {- padding: 8px;- color: #999;- border-top: 1px solid #E8E8E8;+.commit-list>ul li {+ padding: 4px 0;}-.commit-list tr:first-child td {- border-top: none;+.commit-list>ul .commit>.avatar {+ margin-top: 4px;}-.commit-list td.avatar {- width: 1px;-}-.commit-list td.info {+.commit-list>ul .hash-and-code {text-align: right;+ margin-top: 10px;white-space: nowrap;}-.commit-list td.avatar img {- width: 37px;- height: 37px;-}-.commit-list a {- color: #666;+.commit-list>ul a {+ color: #555;}-.commit-list a.summary {+.commit-list>ul a.summary {font-weight: bold;+ font-size: 15px;}-.commit-list td.detail {+.commit-list>ul .detail {padding-left: 8px;padding-right: 8px;}-.commit-list td.detail .name {- color: #666;-}-.commit-list a.commit-hash {- font-family: monospace;-}-.commit-list tr:hover td {+.commit-list>ul .commit:hover {background: #F7ECB9;}-.commit-list .commit-message>.full {+.commit-list>ul .commit .contribution {+ font-size: 12px;+}+.commit-list>ul .message {margin-bottom: 4px;}+.commit-list .date {+ font-size: 18px;+ margin-top: 12px;+ text-align: left;+ border-bottom: 1px solid #EEE;+}+.commit-list .date.first {+ margin-top: 0;+}.commit-list .alert {- margin: 8px;+ margin-bottom: 0;}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.jsindex 73b4440e1b..7521a121c6 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.js@@ -1,439 +1,439 @@-gitplex.repocommits = {- init: function(commits) {- $(window).resize(function(e) {- e.stopPropagation();- gitplex.repocommits.drawCommitLane();- });- gitplex.repocommits.onCommitsLoaded(commits);- },-- initQuery: function() {- var $queryForm = $("#repo-commits>.head>.query");- var $queryInput = $queryForm.find(".input-group>input");- $queryInput.clearable();- $queryInput.on("input", function() {- if (!$queryInput.is(":focus"))- $queryForm.find("button[type='submit']").click();- });- },-- /*- * commits is an array of ordered commit object, and the commit object is itself a- * list of parent indexes- */- onCommitsLoaded: function(commits) {- var columnsLimit = 12;-- var colorsLimit = 12;-- /*- * rows store the map of line to row. A line represents a child->parent relationship.- * For instance line(1,5) represents the line from commit at row 1 (the child ) to- * commit at row 5 (the parent). In case child row index equals parent row index,- * the line represents a commit.- *- */- var rows = [];- var parent2children = {};- var colors = {};-- var colorStack = [];- function getSortedLines(row, reverse) {- var lines = [];- var keys = Object.keys(row);- for (var i in keys)- lines.push(keys[i]);-- lines.sort(function(x, y) {- if (reverse)- return row[y] - row[x];- else- return row[x] - row[y];- });- return lines;- }-- function fromKey(lineKey) {- return lineKey.split(',').map(function(item) {- return parseInt(item, 10);- });- }-- function toKey(line) {- return line[0] + "," + line[1];- }-- function assignColor(lineKey) {- var color = colors[lineKey];- if (color == undefined) {- if (colorStack.length == 0) {- for (var i=colorsLimit; i>=1; i--)- colorStack.push(i);- }- color = colorStack.pop();- colors[lineKey] = color;- }- return color;- }-- for (var i in commits) {- commits[i] = commits[i][1];- var parents = commits[i];- for (var j in parents) {- var parent = parents[j];- var children = parent2children[parent];- if (children == undefined) {- children = [];- parent2children[parent] = children;- }- children.push(i);- }- }-- for (var rowIndex in commits) {- var row = {};- if (rowIndex == 0) {- row["0,0"] = 0;- } else {- var parents = commits[rowIndex-1];- // special line represents the commit at rowIndex itself- var commitLineKey = toKey([rowIndex, rowIndex]);- var lastRow = rows[rowIndex-1];- var column = 0;- var linesOfLastRow = getSortedLines(lastRow, false);- for (var i in linesOfLastRow) {- var lineOfLastRow = fromKey(linesOfLastRow[i]);- if (lineOfLastRow[1] < 0) // line is cutted due to max columns limitation- continue;- if (lineOfLastRow[1] != lineOfLastRow[0]) { // not a commit point- // line not started from last row, in this case, the line- // only occupies a column when it goes through current row- if (lineOfLastRow[1] == rowIndex) {- if (row[commitLineKey] == undefined)- row[commitLineKey] = column++;- } else {- row[toKey(lineOfLastRow)] = column++;- }- } else {- for (var j in parents) {- var parent = parents[j];- if (parent == rowIndex) {- if (row[commitLineKey] == undefined)- row[commitLineKey] = column++;- } else {- row[toKey([rowIndex-1, parent])] = column++;- }- }- }- }-- if (row[commitLineKey] == undefined)- row[commitLineKey] = column++;- if (column > columnsLimit) {- var reversedLines = getSortedLines(row, true);- for (var i in reversedLines) {- var line = fromKey(reversedLines[i]);- if (line[0] == rowIndex-1) {- var cuttedLine = [line[0], line[1]*-1];- var lineKey = toKey(line);- var lineColumn = row[lineKey];- delete row[lineKey];- row[toKey(cuttedLine)] = lineColumn;- column--;- if (column == columnsLimit)- break;- }- }- if (column != columnsLimit)- throw "Error calculating commit lane at row " + rowIndex;- }-- var cuttedLines = [];- var children = parent2children[rowIndex];- if (children) {- for (var i in children) {- var child = children[i];- if (child != rowIndex-1) {- var line = [child, rowIndex];- var cuttedLine = [child, rowIndex*-1];- var lineKey = toKey(line);- var cuttedLineKey = toKey(cuttedLine);- if (lastRow[lineKey] == undefined) {- if (lastRow[cuttedLineKey] != undefined) {- var cuttedLineColumn = lastRow[cuttedLineKey];- delete lastRow[cuttedLineKey];- lastRow[lineKey] = cuttedLineColumn;- } else {- cuttedLines.push(cuttedLine);- }- }- }- }- }- if (cuttedLines.length != 0) {- // for every disappeared line, we need to make them appear again in last row- // so that end part of the line can be drawn from last row to this row.- // Below code find column in last row to insert these appeared lines, and- // we want to make sure that this column can result in minimum line crossovers.- var commitColumn = row[commitLineKey];- var insertColumn = 0;- for (var i=linesOfLastRow.length-1; i>=0; i--) {- var lineOfLastRowKey = linesOfLastRow[i];- var lineOfLastRow = fromKey(lineOfLastRowKey);- if (lineOfLastRow[0] == lineOfLastRow[1]) {- var found = false;- for (var j in parents) {- var parent = parents[j];- var lineKey = toKey([rowIndex-1, parent]);- var lineColumn = row[lineKey];- if (lineColumn != undefined) {- if (lineColumn<commitColumn) {- found = true;- break;- }- } else {- lineKey = toKey([rowIndex-1, parent*-1]);- lineColumn = row[lineKey];- if (lineColumn != undefined && lineColumn<commitColumn) {- found = true;- break;- }- }- }- if (found) {- insertColumn = i;- break;- }- } else {- var lineColumn = row[lineOfLastRowKey];- if (lineColumn!=undefined && lineColumn<commitColumn) {- insertColumn = i;- break;- }- }- }- column = insertColumn+1;- for (var i in cuttedLines)- lastRow[toKey(cuttedLines[i])] = column++;- for (var i=insertColumn+1; i<linesOfLastRow.length; i++)- lastRow[linesOfLastRow[i]] = column++;- }- }- rows.push(row);- }- for (var i=1; i<rows.length; i++) {- var row = rows[i];- var lastRow = rows[i-1];- var lines = getSortedLines(row, false);- var lastLines = getSortedLines(lastRow, true);-- var recycledColors = [];-- for (var j in lines) {- var line = fromKey(lines[j]);- if (line[0] == line[1]) {- for (var k in lastLines) {- var lastLine = fromKey(lastLines[k]);- if (lastLine[0] == lastLine[1]) {- if (commits[i-1].indexOf(i) != -1)- recycledColors.push(assignColor(toKey([i-1, i])));- } else if (lastLine[1] == i) {- recycledColors.push(assignColor(toKey(lastLine)));- } else if (lastLine[1]*-1 == i) {- recycledColors.push(assignColor(toKey([lastLine[0], i])));- }- }- } else {- if (line[1] < 0)- assignColor(toKey([line[0], line[1]*-1]));- else- assignColor(toKey(line));- }- }- for (var j in recycledColors)- colorStack.push(recycledColors[j]);- }- gitplex.repocommits.rows = rows;- gitplex.repocommits.commits = commits;- gitplex.repocommits.parent2children = parent2children;- gitplex.repocommits.colors = colors;-- gitplex.repocommits.drawCommitLane();-- var paper = Snap("#repo-commits>.body>.lane");- function getCommitDot(e) {- var $target = $(e.target);- if (!$target.hasClass("commit") || !$target.is("li"))- $target = $target.closest("li.commit");- var index = $target.attr("class").split(" ").pop().split("-").pop();- return paper.select("#commit-dot-" + index);- }- function onMouseEnter(e) {- getCommitDot(e).attr("strokeWidth", 3);- }- function onMouseLeave(e) {- getCommitDot(e).attr("strokeWidth", 0);- }- var $commits = $("#repo-commits li.commit");- $commits.off("mouseenter");- $commits.off("mouseleave");- $commits.mouseenter(onMouseEnter);- $commits.mouseleave(onMouseLeave);- },- drawCommitLane: function() {- var columnWidth = 12;- var topOffset = 22;- var rightOffset = 12;- var dotSize = 3;-- var dotColorClass = "commit-dot-color";- var lineColorClass = "commit-line-color";-- var rows = gitplex.repocommits.rows;- var commits = gitplex.repocommits.commits;- var parent2children = gitplex.repocommits.parent2children;- var colors = gitplex.repocommits.colors;-- var maxColumns = 0;- for (var i in rows) {- var columns = Object.keys(rows[i]).length;- if (columns > maxColumns)- maxColumns = columns;- }-- function fromKey(lineKey) {- return lineKey.split(',').map(function(item) {- return parseInt(item, 10);- });- }-- function toKey(line) {- return line[0] + "," + line[1];- }-- var bodyTop = $("#repo-commits>.body").offset().top - topOffset;-- function getTop(row) {- return $(".commit-item-"+row).offset().top - bodyTop;- }-- function getLeft(column) {- return column*columnWidth + columnWidth/2;- }-- var $list = $("#repo-commits>.body>.list");- $list.css("margin-left", maxColumns*columnWidth+rightOffset);-- var $lane = $("#repo-commits>.body>.lane");- $lane.empty();- $lane.height($list.outerHeight());- $lane.width(maxColumns*columnWidth);- var paper = Snap($lane[0]);-- for (var i=0; i<commits.length; i++) {- var parents = commits[i];- var row = rows[i];-- var column = row[toKey([i, i])];- var left = getLeft(column);- var top = getTop(i);-- if (i != commits.length-1) {- var nextRow = rows[i+1];- var nextTop = getTop(i+1);- for (var lineKey in row) {- var line = fromKey(lineKey);- column = row[lineKey];-- function drawLine(nextColumn, color, upArrow, downArrow) {- if (nextColumn != undefined) {- var arrowOffset = 10;- var arrowWidth = 4;- var arrowHeight = 8;- var left = getLeft(column);- var nextLeft = getLeft(nextColumn);- var line = paper.line(left, top, nextLeft, nextTop);- line.addClass("commit-line");- line.addClass(lineColorClass + color);- var arrow;- if (upArrow) {- arrow = paper.path("M" + left + " " + top + "l0 -" + arrowOffset- + "l-" + arrowWidth + " " + arrowHeight + "m" + arrowWidth*2- + " 0l-" + arrowWidth + " -" + arrowHeight);- } else if (downArrow) {- arrow = paper.path("M" + nextLeft + " " + nextTop + "l0 " + arrowOffset- + "l-" + arrowWidth + " -" + arrowHeight + "m" + arrowWidth*2- + " 0l-" + arrowWidth + " " + arrowHeight);- }- if (arrow) {- arrow.addClass("commit-line");- arrow.addClass(lineColorClass + color);- }- }- }-- if (line[0] == line[1]) {- for (var j in parents) {- var parent = parents[j];- if (parent == i+1) {- drawLine(nextRow[toKey([i+1, i+1])], colors[toKey([i, i+1])]);- } else {- var nextLineKey = toKey([i, parent]);- var nextColumn = nextRow[nextLineKey];- if (nextColumn != undefined) {- drawLine(nextColumn, colors[nextLineKey], false, false);- } else {- var nextCuttedLineKey = toKey([i, -1*parent]);- drawLine(nextRow[nextCuttedLineKey], colors[nextLineKey], false, true);- }- }- }- } else {- if (line[1] < 0) {- if (line[1]*-1 == i+1) {- var nextColumn = nextRow[toKey([i+1, i+1])];- drawLine(nextColumn, colors[toKey([line[0], i+1])], true, false);- }- } else if (line[1] == i+1){- var nextColumn = nextRow[toKey([i+1, i+1])];- drawLine(nextColumn, colors[lineKey], false, false);- } else {- drawLine(nextRow[lineKey], colors[lineKey], false, false);- }- }- }- }- }-- for (var i in commits) {- var parents = commits[i];- var row = rows[i];-- var column = row[toKey([i, i])];- var left = getLeft(column);- var top = getTop(i);- var circle = paper.circle(left, top, dotSize);- circle.addClass("commit-dot");- if (parents.length != 0) {- circle.addClass(dotColorClass + colors[toKey([i, parents[0]])]);- } else {- var children = parent2children[i];- if (children && children.length != 0)- circle.addClass(dotColorClass + colors[toKey([children[0], i])]);- }- circle.attr("id", "commit-dot-" + i);- circle.mouseover(function() {- this.attr("strokeWidth", 4);- var index = this.attr("id").split("-").pop();- $(".commit-item-" + index).addClass("hover");- });- circle.mouseout(function() {- this.attr("strokeWidth", 0);- var index = this.attr("id").split("-").pop();- $(".commit-item-" + index).removeClass("hover");- });- }-- }-+gitplex.repocommits = {+ init: function(commits) {+ $(window).resize(function(e) {+ e.stopPropagation();+ gitplex.repocommits.drawCommitLane();+ });+ gitplex.repocommits.onCommitsLoaded(commits);+ },++ initQuery: function() {+ var $queryForm = $("#repo-commits>.head>.query");+ var $queryInput = $queryForm.find(".input-group>input");+ $queryInput.clearable();+ $queryInput.on("input", function() {+ if (!$queryInput.is(":focus"))+ $queryForm.find("button[type='submit']").click();+ });+ },++ /*+ * commits is an array of ordered commit object, and the commit object is itself a+ * list of parent indexes+ */+ onCommitsLoaded: function(commits) {+ var columnsLimit = 12;++ var colorsLimit = 12;++ /*+ * rows store the map of line to row. A line represents a child->parent relationship.+ * For instance line(1,5) represents the line from commit at row 1 (the child ) to+ * commit at row 5 (the parent). In case child row index equals parent row index,+ * the line represents a commit.+ *+ */+ var rows = [];+ var parent2children = {};+ var colors = {};++ var colorStack = [];+ function getSortedLines(row, reverse) {+ var lines = [];+ var keys = Object.keys(row);+ for (var i in keys)+ lines.push(keys[i]);++ lines.sort(function(x, y) {+ if (reverse)+ return row[y] - row[x];+ else+ return row[x] - row[y];+ });+ return lines;+ }++ function fromKey(lineKey) {+ return lineKey.split(',').map(function(item) {+ return parseInt(item, 10);+ });+ }++ function toKey(line) {+ return line[0] + "," + line[1];+ }++ function assignColor(lineKey) {+ var color = colors[lineKey];+ if (color == undefined) {+ if (colorStack.length == 0) {+ for (var i=colorsLimit; i>=1; i--)+ colorStack.push(i);+ }+ color = colorStack.pop();+ colors[lineKey] = color;+ }+ return color;+ }++ for (var i in commits) {+ commits[i] = commits[i][1];+ var parents = commits[i];+ for (var j in parents) {+ var parent = parents[j];+ var children = parent2children[parent];+ if (children == undefined) {+ children = [];+ parent2children[parent] = children;+ }+ children.push(i);+ }+ }++ for (var rowIndex in commits) {+ var row = {};+ if (rowIndex == 0) {+ row["0,0"] = 0;+ } else {+ var parents = commits[rowIndex-1];+ // special line represents the commit at rowIndex itself+ var commitLineKey = toKey([rowIndex, rowIndex]);+ var lastRow = rows[rowIndex-1];+ var column = 0;+ var linesOfLastRow = getSortedLines(lastRow, false);+ for (var i in linesOfLastRow) {+ var lineOfLastRow = fromKey(linesOfLastRow[i]);+ if (lineOfLastRow[1] < 0) // line is cutted due to max columns limitation+ continue;+ if (lineOfLastRow[1] != lineOfLastRow[0]) { // not a commit point+ // line not started from last row, in this case, the line+ // only occupies a column when it goes through current row+ if (lineOfLastRow[1] == rowIndex) {+ if (row[commitLineKey] == undefined)+ row[commitLineKey] = column++;+ } else {+ row[toKey(lineOfLastRow)] = column++;+ }+ } else {+ for (var j in parents) {+ var parent = parents[j];+ if (parent == rowIndex) {+ if (row[commitLineKey] == undefined)+ row[commitLineKey] = column++;+ } else {+ row[toKey([rowIndex-1, parent])] = column++;+ }+ }+ }+ }++ if (row[commitLineKey] == undefined)+ row[commitLineKey] = column++;+ if (column > columnsLimit) {+ var reversedLines = getSortedLines(row, true);+ for (var i in reversedLines) {+ var line = fromKey(reversedLines[i]);+ if (line[0] == rowIndex-1) {+ var cuttedLine = [line[0], line[1]*-1];+ var lineKey = toKey(line);+ var lineColumn = row[lineKey];+ delete row[lineKey];+ row[toKey(cuttedLine)] = lineColumn;+ column--;+ if (column == columnsLimit)+ break;+ }+ }+ if (column != columnsLimit)+ throw "Error calculating commit lane at row " + rowIndex;+ }++ var cuttedLines = [];+ var children = parent2children[rowIndex];+ if (children) {+ for (var i in children) {+ var child = children[i];+ if (child != rowIndex-1) {+ var line = [child, rowIndex];+ var cuttedLine = [child, rowIndex*-1];+ var lineKey = toKey(line);+ var cuttedLineKey = toKey(cuttedLine);+ if (lastRow[lineKey] == undefined) {+ if (lastRow[cuttedLineKey] != undefined) {+ var cuttedLineColumn = lastRow[cuttedLineKey];+ delete lastRow[cuttedLineKey];+ lastRow[lineKey] = cuttedLineColumn;+ } else {+ cuttedLines.push(cuttedLine);+ }+ }+ }+ }+ }+ if (cuttedLines.length != 0) {+ // for every disappeared line, we need to make them appear again in last row+ // so that end part of the line can be drawn from last row to this row.+ // Below code find column in last row to insert these appeared lines, and+ // we want to make sure that this column can result in minimum line crossovers.+ var commitColumn = row[commitLineKey];+ var insertColumn = 0;+ for (var i=linesOfLastRow.length-1; i>=0; i--) {+ var lineOfLastRowKey = linesOfLastRow[i];+ var lineOfLastRow = fromKey(lineOfLastRowKey);+ if (lineOfLastRow[0] == lineOfLastRow[1]) {+ var found = false;+ for (var j in parents) {+ var parent = parents[j];+ var lineKey = toKey([rowIndex-1, parent]);+ var lineColumn = row[lineKey];+ if (lineColumn != undefined) {+ if (lineColumn<commitColumn) {+ found = true;+ break;+ }+ } else {+ lineKey = toKey([rowIndex-1, parent*-1]);+ lineColumn = row[lineKey];+ if (lineColumn != undefined && lineColumn<commitColumn) {+ found = true;+ break;+ }+ }+ }+ if (found) {+ insertColumn = i;+ break;+ }+ } else {+ var lineColumn = row[lineOfLastRowKey];+ if (lineColumn!=undefined && lineColumn<commitColumn) {+ insertColumn = i;+ break;+ }+ }+ }+ column = insertColumn+1;+ for (var i in cuttedLines)+ lastRow[toKey(cuttedLines[i])] = column++;+ for (var i=insertColumn+1; i<linesOfLastRow.length; i++)+ lastRow[linesOfLastRow[i]] = column++;+ }+ }+ rows.push(row);+ }+ for (var i=1; i<rows.length; i++) {+ var row = rows[i];+ var lastRow = rows[i-1];+ var lines = getSortedLines(row, false);+ var lastLines = getSortedLines(lastRow, true);++ var recycledColors = [];++ for (var j in lines) {+ var line = fromKey(lines[j]);+ if (line[0] == line[1]) {+ for (var k in lastLines) {+ var lastLine = fromKey(lastLines[k]);+ if (lastLine[0] == lastLine[1]) {+ if (commits[i-1].indexOf(i) != -1)+ recycledColors.push(assignColor(toKey([i-1, i])));+ } else if (lastLine[1] == i) {+ recycledColors.push(assignColor(toKey(lastLine)));+ } else if (lastLine[1]*-1 == i) {+ recycledColors.push(assignColor(toKey([lastLine[0], i])));+ }+ }+ } else {+ if (line[1] < 0)+ assignColor(toKey([line[0], line[1]*-1]));+ else+ assignColor(toKey(line));+ }+ }+ for (var j in recycledColors)+ colorStack.push(recycledColors[j]);+ }+ gitplex.repocommits.rows = rows;+ gitplex.repocommits.commits = commits;+ gitplex.repocommits.parent2children = parent2children;+ gitplex.repocommits.colors = colors;++ gitplex.repocommits.drawCommitLane();++ var paper = Snap("#repo-commits>.body>.lane");+ function getCommitDot(e) {+ var $target = $(e.target);+ if (!$target.hasClass("commit") || !$target.is("li"))+ $target = $target.closest("li.commit");+ var index = $target.attr("class").split(" ").pop().split("-").pop();+ return paper.select("#commit-dot-" + index);+ }+ function onMouseEnter(e) {+ getCommitDot(e).attr("strokeWidth", 3);+ }+ function onMouseLeave(e) {+ getCommitDot(e).attr("strokeWidth", 0);+ }+ var $commits = $("#repo-commits li.commit");+ $commits.off("mouseenter");+ $commits.off("mouseleave");+ $commits.mouseenter(onMouseEnter);+ $commits.mouseleave(onMouseLeave);+ },+ drawCommitLane: function() {+ var columnWidth = 12;+ var topOffset = 22;+ var rightOffset = 12;+ var dotSize = 3;++ var dotColorClass = "commit-dot-color";+ var lineColorClass = "commit-line-color";++ var rows = gitplex.repocommits.rows;+ var commits = gitplex.repocommits.commits;+ var parent2children = gitplex.repocommits.parent2children;+ var colors = gitplex.repocommits.colors;++ var maxColumns = 0;+ for (var i in rows) {+ var columns = Object.keys(rows[i]).length;+ if (columns > maxColumns)+ maxColumns = columns;+ }++ function fromKey(lineKey) {+ return lineKey.split(',').map(function(item) {+ return parseInt(item, 10);+ });+ }++ function toKey(line) {+ return line[0] + "," + line[1];+ }++ var bodyTop = $("#repo-commits>.body").offset().top - topOffset;++ function getTop(row) {+ return $(".commit-item-"+row).offset().top - bodyTop;+ }++ function getLeft(column) {+ return column*columnWidth + columnWidth/2;+ }++ var $list = $("#repo-commits>.body>.list");+ $list.css("margin-left", maxColumns*columnWidth+rightOffset);++ var $lane = $("#repo-commits>.body>.lane");+ $lane.empty();+ $lane.height($list.outerHeight());+ $lane.width(maxColumns*columnWidth);+ var paper = Snap($lane[0]);++ for (var i=0; i<commits.length; i++) {+ var parents = commits[i];+ var row = rows[i];++ var column = row[toKey([i, i])];+ var left = getLeft(column);+ var top = getTop(i);++ if (i != commits.length-1) {+ var nextRow = rows[i+1];+ var nextTop = getTop(i+1);+ for (var lineKey in row) {+ var line = fromKey(lineKey);+ column = row[lineKey];++ function drawLine(nextColumn, color, upArrow, downArrow) {+ if (nextColumn != undefined) {+ var arrowOffset = 10;+ var arrowWidth = 4;+ var arrowHeight = 8;+ var left = getLeft(column);+ var nextLeft = getLeft(nextColumn);+ var line = paper.line(left, top, nextLeft, nextTop);+ line.addClass("commit-line");+ line.addClass(lineColorClass + color);+ var arrow;+ if (upArrow) {+ arrow = paper.path("M" + left + " " + top + "l0 -" + arrowOffset+ + "l-" + arrowWidth + " " + arrowHeight + "m" + arrowWidth*2+ + " 0l-" + arrowWidth + " -" + arrowHeight);+ } else if (downArrow) {+ arrow = paper.path("M" + nextLeft + " " + nextTop + "l0 " + arrowOffset+ + "l-" + arrowWidth + " -" + arrowHeight + "m" + arrowWidth*2+ + " 0l-" + arrowWidth + " " + arrowHeight);+ }+ if (arrow) {+ arrow.addClass("commit-line");+ arrow.addClass(lineColorClass + color);+ }+ }+ }++ if (line[0] == line[1]) {+ for (var j in parents) {+ var parent = parents[j];+ if (parent == i+1) {+ drawLine(nextRow[toKey([i+1, i+1])], colors[toKey([i, i+1])]);+ } else {+ var nextLineKey = toKey([i, parent]);+ var nextColumn = nextRow[nextLineKey];+ if (nextColumn != undefined) {+ drawLine(nextColumn, colors[nextLineKey], false, false);+ } else {+ var nextCuttedLineKey = toKey([i, -1*parent]);+ drawLine(nextRow[nextCuttedLineKey], colors[nextLineKey], false, true);+ }+ }+ }+ } else {+ if (line[1] < 0) {+ if (line[1]*-1 == i+1) {+ var nextColumn = nextRow[toKey([i+1, i+1])];+ drawLine(nextColumn, colors[toKey([line[0], i+1])], true, false);+ }+ } else if (line[1] == i+1){+ var nextColumn = nextRow[toKey([i+1, i+1])];+ drawLine(nextColumn, colors[lineKey], false, false);+ } else {+ drawLine(nextRow[lineKey], colors[lineKey], false, false);+ }+ }+ }+ }+ }++ for (var i in commits) {+ var parents = commits[i];+ var row = rows[i];++ var column = row[toKey([i, i])];+ var left = getLeft(column);+ var top = getTop(i);+ var circle = paper.circle(left, top, dotSize);+ circle.addClass("commit-dot");+ if (parents.length != 0) {+ circle.addClass(dotColorClass + colors[toKey([i, parents[0]])]);+ } else {+ var children = parent2children[i];+ if (children && children.length != 0)+ circle.addClass(dotColorClass + colors[toKey([children[0], i])]);+ }+ circle.attr("id", "commit-dot-" + i);+ circle.mouseover(function() {+ this.attr("strokeWidth", 4);+ var index = this.attr("id").split("-").pop();+ $(".commit-item-" + index).addClass("hover");+ });+ circle.mouseout(function() {+ this.attr("strokeWidth", 0);+ var index = this.attr("id").split("-").pop();+ $(".commit-item-" + index).removeClass("hover");+ });+ }++ }+}\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/revision-compare.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/revision-compare.cssindex 402dfcadd1..65c1e6a54b 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/revision-compare.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/compare/revision-compare.css@@ -23,7 +23,8 @@}#revision-compare>.body>.revisions>.revision>label {font-size: 16px;- color: #555;+ color: #333;+ font-weight: normal;}#revision-compare>.body>.nav-tabs {margin-bottom: 20px;