From 1631f8d71dad7b67a5b1b85eee63683b64614bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20R=C3=BChle?= Date: Fri, 25 Aug 2017 15:51:58 +0200 Subject: [PATCH] Mark current branch tag --- css/explaingit.css | 6 ++++++ js/historyview.js | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/css/explaingit.css b/css/explaingit.css index cbae11b..58ce9a3 100644 --- a/css/explaingit.css +++ b/css/explaingit.css @@ -228,6 +228,12 @@ g.branch-tag > rect { stroke-width: 2; } +g.branch-tag.current-branch > rect { + fill: #FFCC66; + stroke: #339900; + stroke-width: 2; +} + g.branch-tag.git-tag > rect { fill: #7FC9FF; stroke: #0026FF; diff --git a/js/historyview.js b/js/historyview.js index 683201e..0796f1d 100644 --- a/js/historyview.js +++ b/js/historyview.js @@ -669,7 +669,8 @@ define(['d3'], function () { renderTags: function () { var view = this, tagData = this._parseTagData(), - existingTags, newTags; + existingTags, newTags, + currentBranch = this.currentBranch; existingTags = this.tagBox.selectAll('g.branch-tag') .data(tagData, function (d) { return d.name; }); @@ -707,6 +708,9 @@ define(['d3'], function () { } else if (d.name.toUpperCase() === 'HEAD') { classes += ' head-tag'; } + if (d.name == currentBranch) { + classes += " current-branch" + } return classes; }); @@ -737,6 +741,19 @@ define(['d3'], function () { return commit.cx; }); + this.tagBox.selectAll('g.branch-tag').attr('class', function(d) { + var cls = d3.select(this).attr('class').split(" "), + currentBranchIndex = cls.indexOf('current-branch'); + if (d.name == currentBranch) { + if (currentBranchIndex < 0) { + cls.push('current-branch'); + } + } else if (currentBranchIndex >= 0) { + cls.splice(currentBranchIndex, 1); + } + return cls.join(' '); + }); + this._markBranchlessCommits(); },