##// END OF EJS Templates
diffs: fixed selecting active lines in both types of diffs.
dan -
r3130:dc7450ba default
parent child Browse files
Show More
@@ -1132,6 +1132,9 b' table.cb {'
1132 .icon-comment {
1132 .icon-comment {
1133 cursor: pointer;
1133 cursor: pointer;
1134 }
1134 }
1135 &.cb-line-selected {
1136 background: @comment-highlight-color !important;
1137 }
1135 &.cb-line-selected > div {
1138 &.cb-line-selected > div {
1136 display: block;
1139 display: block;
1137 background: @comment-highlight-color !important;
1140 background: @comment-highlight-color !important;
@@ -1154,7 +1157,7 b' table.cb {'
1154 a::before {
1157 a::before {
1155 content: attr(data-line-no);
1158 content: attr(data-line-no);
1156 }
1159 }
1157 &.cb-line-selected a {
1160 &.cb-line-selected {
1158 background: @comment-highlight-color !important;
1161 background: @comment-highlight-color !important;
1159 }
1162 }
1160
1163
@@ -295,24 +295,25 b' function scrollToElement(element, percen'
295 });
295 });
296
296
297 $('body').on('click', '.cb-lineno a', function(event) {
297 $('body').on('click', '.cb-lineno a', function(event) {
298
299 function sortNumber(a,b) {
298 function sortNumber(a,b) {
300 return a - b;
299 return a - b;
301 }
300 }
302
301
303 var lineNo = $(this).data('lineNo');
302 var lineNo = $(this).data('lineNo');
303 var lineName = $(this).attr('name');
304
304 if (lineNo) {
305 if (lineNo) {
306 var prevLine = $('.cb-line-selected a').data('lineNo');
305
307
306 // on shift, we do a range selection, if we got previous line
308 // on shift, we do a range selection, if we got previous line
307 var prevLine = $('.cb-line-selected a').data('lineNo');
308 if (event.shiftKey && prevLine !== undefined) {
309 if (event.shiftKey && prevLine !== undefined) {
309 var prevLine = parseInt(prevLine);
310 var prevLine = parseInt(prevLine);
310 var nextLine = parseInt(lineNo);
311 var nextLine = parseInt(lineNo);
311 var pos = [prevLine, nextLine].sort(sortNumber);
312 var pos = [prevLine, nextLine].sort(sortNumber);
312 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
313 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
313
314
315 // single click
314 } else {
316 } else {
315
316 var nextLine = parseInt(lineNo);
317 var nextLine = parseInt(lineNo);
317 var pos = [nextLine, nextLine];
318 var pos = [nextLine, nextLine];
318 var anchor = '#L{0}'.format(pos[0]);
319 var anchor = '#L{0}'.format(pos[0]);
@@ -323,11 +324,12 b' function scrollToElement(element, percen'
323 for (var i = pos[0]; i <= pos[1]; i++) {
324 for (var i = pos[0]; i <= pos[1]; i++) {
324 range.push(i);
325 range.push(i);
325 }
326 }
326 // clear selection
327 // clear old selected lines
327 $('.cb-line-selected').removeClass('cb-line-selected');
328 $('.cb-line-selected').removeClass('cb-line-selected');
328
329
329 $.each(range, function (i, lineNo) {
330 $.each(range, function (i, lineNo) {
330 var line_td = $('td.cb-lineno#L' + lineNo);
331 var line_td = $('td.cb-lineno#L' + lineNo);
332
331 if (line_td.length) {
333 if (line_td.length) {
332 line_td.addClass('cb-line-selected'); // line number td
334 line_td.addClass('cb-line-selected'); // line number td
333 line_td.prev().addClass('cb-line-selected'); // line data
335 line_td.prev().addClass('cb-line-selected'); // line data
@@ -335,15 +337,20 b' function scrollToElement(element, percen'
335 }
337 }
336 });
338 });
337
339
338
340 } else if (lineName !== undefined) { // lineName only occurs in diffs
339 } else {
341 // clear old selected lines
340 if ($(this).attr('name') !== undefined) {
341 // clear selection
342 $('td.cb-line-selected').removeClass('cb-line-selected');
342 $('td.cb-line-selected').removeClass('cb-line-selected');
343 var aEl = $(this).closest('td');
343 var anchor = '#{0}'.format(lineName);
344 aEl.addClass('cb-line-selected');
344 var diffmode = templateContext.session_attrs.diffmode || "sideside";
345 aEl.next('td').addClass('cb-line-selected');
345
346 if (diffmode === "unified") {
347 $(this).closest('tr').find('td').addClass('cb-line-selected');
348 } else {
349 var activeTd = $(this).closest('td');
350 activeTd.addClass('cb-line-selected');
351 activeTd.next('td').addClass('cb-line-selected');
346 }
352 }
353
347 }
354 }
348
355
349 // Replace URL without jumping to it if browser supports.
356 // Replace URL without jumping to it if browser supports.
@@ -364,7 +371,6 b' function scrollToElement(element, percen'
364
371
365 });
372 });
366
373
367
368 $('.collapse_file').on('click', function(e) {
374 $('.collapse_file').on('click', function(e) {
369 e.stopPropagation();
375 e.stopPropagation();
370 if ($(e.target).is('a')) { return; }
376 if ($(e.target).is('a')) { return; }
General Comments 0
You need to be logged in to leave comments. Login now