The Unified and Autonomous Development Platform
highlight commit line if hover on commit dot
robin shine5e6fbad264cc
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.javaindex 2fe8af7f70..d2de461371 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/RepoCommitsPage.java@@ -263,7 +263,7 @@ public class RepoCommitsPage extends RepositoryPage {}target.prependJavaScript(builder);target.add(foot);- String script = String.format("gitplex.repocommits.renderCommitLane(%s);", getCommitsJson());+ String script = String.format("gitplex.repocommits.onCommitsLoaded(%s);", getCommitsJson());target.appendJavaScript(script);pushState(target);}@@ -309,7 +309,7 @@ public class RepoCommitsPage extends RepositoryPage {}private void addCommitClass(Component item, int commitIndex) {- item.add(AttributeAppender.append("class", " commitindex-" + commitIndex));+ item.add(AttributeAppender.append("class", " commit-item-" + commitIndex));}private Component newCommitItem(String itemId, final int index) {diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.cssindex 93f7a95bfc..ef21baf092 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/commit/repo-commits.css@@ -36,9 +36,10 @@#repo-commits>.body .commit-hash {font-family: monospace;}-#repo-commits>.body li.commit:hover {+#repo-commits>.body li.commit:hover, #repo-commits>.body li.commit.hover {background: #F7ECB9;}+#repo-commits>.body .commit-message>.full {margin-bottom: 4px;}@@ -65,95 +66,108 @@border-bottom: 1px solid #EEE;}-.commit-lane-dot {+.commit-dot {fill: #53a8fd;+ stroke: #53a8fd;}-.commit-lane-line {+.commit-line {stroke-width: 2px;stroke: #53a8fd;fill: none;}-.commit-lane-dot1 {+.commit-dot-color1 {fill: #53a8fd;+ stroke: #53a8fd;}-.commit-lane-line1 {+.commit-line-color1 {stroke: #53a8fd;}-.commit-lane-dot2 {+.commit-dot-color2 {fill: #09c112;+ stroke: #09c112;}-.commit-lane-line2 {+.commit-line-color2 {stroke: #09c112;}-.commit-lane-dot3 {+.commit-dot-color3 {fill: #ff4242;+ stroke: #ff4242;}-.commit-lane-line3 {+.commit-line-color3 {stroke: #ff4242;}-.commit-lane-dot4 {+.commit-dot-color4 {fill: #0252a2;+ stroke: #0252a2;}-.commit-lane-line4 {+.commit-line-color4 {stroke: #0252a2;}-.commit-lane-dot5 {+.commit-dot-color5 {fill: #056d0b;+ stroke: #056d0b;}-.commit-lane-line5 {+.commit-line-color5 {stroke: #056d0b;}-.commit-lane-dot6 {+.commit-dot-color6 {fill: #b00000;+ stroke: #b00000;}-.commit-lane-line6 {+.commit-line-color6 {stroke: #b00000;}-.commit-lane-dot7 {+.commit-dot-color7 {fill: #af29f8;+ stroke: #af29f8;}-.commit-lane-line7 {+.commit-line-color7 {stroke: #af29f8;}-.commit-lane-dot8 {+.commit-dot-color8 {fill: #ee6c1e;+ stroke: #ee6c1e;}-.commit-lane-line8 {+.commit-line-color8 {stroke: #ee6c1e;}-.commit-lane-dot9 {+.commit-dot-color9 {fill: #ef56cd;+ stroke: #ef56cd;}-.commit-lane-line9 {+.commit-line-color9 {stroke: #ef56cd;}-.commit-lane-dot10 {+.commit-dot-color10 {fill: #630596;+ stroke: #630596;}-.commit-lane-line10 {+.commit-line-color10 {stroke: #630596;}-.commit-lane-dot11 {+.commit-dot-color11 {fill: #8e4509;+ stroke: #8e4509;}-.commit-lane-line11 {+.commit-line-color11 {stroke: #8e4509;}-.commit-lane-dot12 {+.commit-dot-color12 {fill: #9b0f7b;+ stroke: #9b0f7b;}-.commit-lane-line12 {+.commit-line-color12 {stroke: #9b0f7b;}diff --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 ad1e1e5ce4..fe7e2850ce 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@@ -4,14 +4,14 @@ gitplex.repocommits = {e.stopPropagation();gitplex.repocommits.drawCommitLane();});- gitplex.repocommits.renderCommitLane(commits);+ gitplex.repocommits.onCommitsLoaded(commits);},/** commits is an array of ordered commit object, and the commit object is itself a* list of parent indexes*/- renderCommitLane: function(commits) {+ onCommitsLoaded: function(commits) {var columnsLimit = 12;var colorsLimit = 12;@@ -249,15 +249,35 @@ gitplex.repocommits = {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", 4);+ }+ 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 = 4;- var commitSize = 4;+ var dotSize = 4;- var commitClass = "commit-lane-dot";- var lineClass = "commit-lane-line";+ var dotColorClass = "commit-dot-color";+ var lineColorClass = "commit-line-color";var rows = gitplex.repocommits.rows;var commits = gitplex.repocommits.commits;@@ -284,7 +304,7 @@ gitplex.repocommits = {var bodyTop = $("#repo-commits>.body").offset().top - topOffset;function getTop(row) {- return $(".commitindex-"+row).offset().top - bodyTop;+ return $(".commit-item-"+row).offset().top - bodyTop;}function getLeft(column) {@@ -307,15 +327,7 @@ gitplex.repocommits = {var column = row[toKey([i, i])];var left = getLeft(column);var top = getTop(i);- var circle = paper.circle(left, top, commitSize);- circle.addClass(commitClass);- if (parents.length != 0) {- circle.addClass(commitClass + colors[toKey([i, parents[0]])]);- } else {- var children = parent2children[i];- if (children && children.length != 0)- circle.addClass(commitClass + colors[toKey([children[0], i])]);- }+if (i != commits.length-1) {var nextRow = rows[i+1];var nextTop = getTop(i+1);@@ -331,8 +343,8 @@ gitplex.repocommits = {var left = getLeft(column);var nextLeft = getLeft(nextColumn);var line = paper.line(left, top, nextLeft, nextTop);- line.addClass(lineClass);- line.addClass(lineClass + color);+ line.addClass("commit-line");+ line.addClass(lineColorClass + color);var arrow;if (upArrow) {arrow = paper.path("M" + left + " " + top + "l0 -" + arrowOffset@@ -344,8 +356,8 @@ gitplex.repocommits = {+ " 0l-" + arrowWidth + " " + arrowHeight);}if (arrow) {- arrow.addClass(lineClass);- arrow.addClass(lineClass + color);+ arrow.addClass(lineColorClass);+ arrow.addClass(lineColorClass + color);}}}@@ -382,6 +394,36 @@ gitplex.repocommits = {}}}++ 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 file