mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-12 08:25:50 +01:00
(refs #549) Selecting lines in diff without line numbers.
This commit is contained in:
@@ -154,15 +154,13 @@ $(function(){
|
||||
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 @@ $(function(){
|
||||
$(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 @@ $(function(){
|
||||
$(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 @@ $(function(){
|
||||
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)
|
||||
|
||||
@@ -975,15 +975,16 @@ table.diff .add-comment {
|
||||
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 @@ table.diff tbody tr.not-diff:hover td{
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.diff .oldline:before, .diff .newline:before {
|
||||
content: attr(line-number);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Repository Settings */
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -84,7 +84,7 @@ diffview = {
|
||||
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 @@ diffview = {
|
||||
* 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 @@ diffview = {
|
||||
}
|
||||
|
||||
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++) {
|
||||
|
||||
Reference in New Issue
Block a user