diff --git a/src/main/twirl/helper/diff.scala.html b/src/main/twirl/helper/diff.scala.html
index 23c5474..b9a044a 100644
--- a/src/main/twirl/helper/diff.scala.html
+++ b/src/main/twirl/helper/diff.scala.html
@@ -154,15 +154,13 @@
tmp = getInlineContainer('old');
}
tmp.children('td:first').html($(this).clone().show());
- $('table[filename="' + filename + '"]').find('table.diff').find('.oldline').filter(function() {
- return new RegExp('^' + oldline + '[\\+]*$').test($(this).text());
- }).parent().nextAll(':not(.not-diff):first').before(tmp);
+ $('table[filename="' + filename + '"]').find('table.diff').find('.oldline[line-number=' + oldline + ']')
+ .parent().nextAll(':not(.not-diff):first').before(tmp);
} else {
var tmp = getInlineContainer('new');
tmp.children('td:last').html($(this).clone().show());
- $('table[filename="' + filename + '"]').find('table.diff').find('.newline').filter(function() {
- return new RegExp('^' + newline + '\\+$').test($(this).text());
- }).parent().nextAll(':not(.not-diff):first').before(tmp);
+ $('table[filename="' + filename + '"]').find('table.diff').find('.newline[line-number=' + newline + ']')
+ .parent().nextAll(':not(.not-diff):first').before(tmp);
}
});
$('.toggle-notes').change(function() {
@@ -172,7 +170,7 @@
$(this).closest('table').find('.not-diff').toggle();
});
@if(hasWritePermission) {
- $('table.diff th').hover(
+ $('table.diff td').hover(
function() {
$(this).find('b').css('display', 'inline-block');
},
@@ -180,12 +178,12 @@
$(this).find('b').css('display', 'none');
}
);
- $('table.diff td').hover(
+ $('table.diff th').hover(
function() {
- $(this).prev('th').find('b').css('display', 'inline-block');
+ $(this).closest('tr').find('td').find('b').css('display', 'inline-block');
},
function() {
- $(this).prev('th').find('b').css('display', 'none');
+ $(this).closest('tr').find('td').find('b').css('display', 'none');
}
);
$('.add-comment').click(function() {
@@ -198,12 +196,14 @@
if (!$tr.nextAll(':not(.not-diff):first').prev().hasClass('inline-comment-form')) {
var commitId = $this.closest('.table-bordered').attr('commitId'),
fileName = $this.closest('.table-bordered').attr('fileName'),
- oldLineNumber, newLineNumber = $this.closest('.newline').clone().children().remove().end().text(),
+ oldLineNumber, newLineNumber,
url = '@url(repository)/commit/' + commitId + '/comment/_form?fileName=' + fileName@issueId.map { id => + '&issueId=@id' };
if (viewType == 0) {
- oldLineNumber = $this.closest('.oldline').clone().children().remove().end().text();
+ oldLineNumber = $this.parent().prev('.oldline').attr('line-number');
+ newLineNumber = $this.parent().prev('.newline').attr('line-number');
} else {
- oldLineNumber = $this.closest('tr').find('.oldline').text();
+ oldLineNumber = $this.parent().prevAll('.oldline').attr('line-number');
+ newLineNumber = $this.parent().prevAll('.newline').attr('line-number');
}
if (!isNaN(oldLineNumber) && oldLineNumber) {
url += ('&oldLineNumber=' + oldLineNumber)
diff --git a/src/main/webapp/assets/common/css/gitbucket.css b/src/main/webapp/assets/common/css/gitbucket.css
index 63e2901..90c3c99 100644
--- a/src/main/webapp/assets/common/css/gitbucket.css
+++ b/src/main/webapp/assets/common/css/gitbucket.css
@@ -975,15 +975,16 @@
position: absolute;
background: blue;
top: 0;
+ left: -7px;
color: white;
- padding: 2px;
+ padding: 2px 4px;
border: solid 1px blue;
border-radius: 3px;
z-index: 99;
}
table.diff .add-comment:hover {
- padding: 4px;
+ padding: 4px 6px;
top: -1px;
}
@@ -1009,6 +1010,10 @@
padding: 10px;
}
+.diff .oldline:before, .diff .newline:before {
+ content: attr(line-number);
+}
+
/****************************************************************************/
/* Repository Settings */
/****************************************************************************/
diff --git a/src/main/webapp/assets/vendors/jsdifflib/diffview.js b/src/main/webapp/assets/vendors/jsdifflib/diffview.js
index b9fd2cc..cf8d18b 100644
--- a/src/main/webapp/assets/vendors/jsdifflib/diffview.js
+++ b/src/main/webapp/assets/vendors/jsdifflib/diffview.js
@@ -84,7 +84,7 @@
b.appendChild(document.createTextNode("+"));
b.style.display = "none";
b.className = "add-comment";
- e.appendChild(b);
+ e.insertBefore(b, e.firstChild);
e.style.position = "relative";
return e;
}
@@ -117,9 +117,12 @@
* to the given row.
*/
function addCells (row, tidx, tend, textLines, change, thclass) {
+ var tmp;
if (tidx < tend) {
- row.appendChild(addButton(ctelt("th", thclass, (tidx + 1).toString())));
- row.appendChild(ctelt("td", change, textLines[tidx].replace(/\t/g, "\u00a0\u00a0\u00a0\u00a0")));
+ tmp = ctelt("th", thclass, "");
+ tmp.setAttribute("line-number", (tidx + 1).toString());
+ row.appendChild(tmp);
+ row.appendChild(addButton(ctelt("td", change, textLines[tidx].replace(/\t/g, "\u00a0\u00a0\u00a0\u00a0"))));
return tidx + 1;
} else {
row.appendChild(document.createElement("th"));
@@ -129,9 +132,13 @@
}
function addCellsInline (row, tidx, tidx2, textLines, change) {
- row.appendChild(ctelt("th", "oldline", tidx == null ? "" : (tidx + 1).toString()));
- row.appendChild(addButton(ctelt("th", "newline", tidx2 == null ? "" : (tidx2 + 1).toString())));
- row.appendChild(ctelt("td", change, textLines[tidx != null ? tidx : tidx2].replace(/\t/g, "\u00a0\u00a0\u00a0\u00a0")));
+ var tmp = ctelt("th", "oldline", "");
+ tmp.setAttribute("line-number", tidx == null ? "" : (tidx + 1).toString());
+ row.appendChild(tmp);
+ tmp = ctelt("th", "newline", "");
+ tmp.setAttribute("line-number", tidx2 == null ? "" : (tidx2 + 1).toString());
+ row.appendChild(tmp);
+ row.appendChild(addButton(ctelt("td", change, textLines[tidx != null ? tidx : tidx2].replace(/\t/g, "\u00a0\u00a0\u00a0\u00a0"))));
}
for (var idx = 0; idx < opcodes.length; idx++) {