Allow selecting lines in diff

This commit is contained in:
Jesse van den Kieboom 2013-12-28 15:51:39 +01:00
parent 7c91a7e3ff
commit b213b54ac1
2 changed files with 33 additions and 0 deletions

View file

@ -70,6 +70,14 @@ div#diff div.file table tr.added td:last-child {
background-color: #ddffdd;
}
div#diff div.file table tr.added.selected td:last-child {
background-color: #a8cfd6;
}
div#diff div.file table tr.removed.selected td:last-child {
background-color: #b8bed6;
}
div#diff div.file table tr.removed td:last-child {
background-color: #ffdddd;
}
@ -152,6 +160,11 @@ div#diff div.file table tr.hunk_header td.hunk_header {
border-bottom: 1px solid #d3d7cf;
}
div#diff div.file table tr.hunk_header.selected td.hunk_header {
color: #aaa;
background-color: #ececff;
}
div#diff div.file table td {
vertical-align: top;
}

View file

@ -144,6 +144,24 @@ function expand_collapse()
expander.closest('tbody').toggleClass("collapsed");
}
function stage_unstage_hunk()
{
var addrm = $(this).nextUntil('tr.file_header, tr.hunk_header').filter('tr.added, tr.removed');
var unsel = $.grep(addrm, function(e) { return !$(e).hasClass('selected'); });
addrm.removeClass('selected');
if (unsel.length != 0)
{
addrm.addClass('selected');
}
}
function stage_unstage_line()
{
$(this).toggleClass("selected");
}
function update_diff(id, lsettings)
{
if (html_builder_worker)
@ -214,6 +232,8 @@ function update_diff(id, lsettings)
content.html(event.data.diff_html);
$(".expander").click(expand_collapse);
$("tr.hunk_header").click(stage_unstage_hunk);
$("tr.added, tr.removed").click(stage_unstage_line);
}
}