##// 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 1132 .icon-comment {
1133 1133 cursor: pointer;
1134 1134 }
1135 &.cb-line-selected {
1136 background: @comment-highlight-color !important;
1137 }
1135 1138 &.cb-line-selected > div {
1136 1139 display: block;
1137 1140 background: @comment-highlight-color !important;
@@ -1154,7 +1157,7 b' table.cb {'
1154 1157 a::before {
1155 1158 content: attr(data-line-no);
1156 1159 }
1157 &.cb-line-selected a {
1160 &.cb-line-selected {
1158 1161 background: @comment-highlight-color !important;
1159 1162 }
1160 1163
@@ -295,24 +295,25 b' function scrollToElement(element, percen'
295 295 });
296 296
297 297 $('body').on('click', '.cb-lineno a', function(event) {
298
299 298 function sortNumber(a,b) {
300 299 return a - b;
301 300 }
302 301
303 302 var lineNo = $(this).data('lineNo');
303 var lineName = $(this).attr('name');
304
304 305 if (lineNo) {
306 var prevLine = $('.cb-line-selected a').data('lineNo');
305 307
306 308 // on shift, we do a range selection, if we got previous line
307 var prevLine = $('.cb-line-selected a').data('lineNo');
308 309 if (event.shiftKey && prevLine !== undefined) {
309 310 var prevLine = parseInt(prevLine);
310 311 var nextLine = parseInt(lineNo);
311 312 var pos = [prevLine, nextLine].sort(sortNumber);
312 313 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
313 314
315 // single click
314 316 } else {
315
316 317 var nextLine = parseInt(lineNo);
317 318 var pos = [nextLine, nextLine];
318 319 var anchor = '#L{0}'.format(pos[0]);
@@ -323,11 +324,12 b' function scrollToElement(element, percen'
323 324 for (var i = pos[0]; i <= pos[1]; i++) {
324 325 range.push(i);
325 326 }
326 // clear selection
327 // clear old selected lines
327 328 $('.cb-line-selected').removeClass('cb-line-selected');
328 329
329 330 $.each(range, function (i, lineNo) {
330 331 var line_td = $('td.cb-lineno#L' + lineNo);
332
331 333 if (line_td.length) {
332 334 line_td.addClass('cb-line-selected'); // line number td
333 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
339 } else {
340 if ($(this).attr('name') !== undefined) {
341 // clear selection
340 } else if (lineName !== undefined) { // lineName only occurs in diffs
341 // clear old selected lines
342 342 $('td.cb-line-selected').removeClass('cb-line-selected');
343 var aEl = $(this).closest('td');
344 aEl.addClass('cb-line-selected');
345 aEl.next('td').addClass('cb-line-selected');
343 var anchor = '#{0}'.format(lineName);
344 var diffmode = templateContext.session_attrs.diffmode || "sideside";
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 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 374 $('.collapse_file').on('click', function(e) {
369 375 e.stopPropagation();
370 376 if ($(e.target).is('a')) { return; }
General Comments 0
You need to be logged in to leave comments. Login now