##// END OF EJS Templates
diffs/files: fix and improve line selections and anchor links.
marcink -
r2642:b8db5763 default
parent child Browse files
Show More
@@ -18,15 +18,6 b''
18 18 }
19 19 }
20 20
21 .compare_view_files {
22
23 .diff-container {
24
25 .diffblock {
26 margin-bottom: 0;
27 }
28 }
29 }
30 21
31 22 div.diffblock .sidebyside {
32 23 background: #ffffff;
@@ -1543,14 +1543,6 b' table.integrations {'
1543 1543 }
1544 1544 }
1545 1545
1546 .compare_view_files {
1547 width: 100%;
1548
1549 td {
1550 vertical-align: middle;
1551 }
1552 }
1553
1554 1546 .compare_view_filepath {
1555 1547 color: @grey1;
1556 1548 }
@@ -485,58 +485,6 b' table.compare_view_commits {'
485 485 }
486 486 }
487 487
488 .compare_view_files {
489
490 td.td-actions {
491 text-align: right;
492 }
493
494 .flag_status {
495 margin: 0 0 0 5px;
496 }
497
498 td.injected_diff {
499
500 .code-difftable {
501 border:none;
502 }
503
504 .diff-container {
505 border: @border-thickness solid @border-default-color;
506 .border-radius(@border-radius);
507 }
508
509 div.diffblock {
510 border:none;
511 }
512
513 div.code-body {
514 max-width: 1152px;
515 }
516 }
517
518 .rctable {
519
520 td {
521 padding-top: @space;
522 }
523
524 &:first-child td {
525 padding-top: 0;
526 }
527 }
528
529 .comment-bubble,
530 .show_comments {
531 float: right;
532 visibility: hidden;
533 padding: 0 1em 0 0;
534 }
535
536 .injected_diff {
537 padding-bottom: @padding;
538 }
539 }
540 488
541 489 // Gist List
542 490 #gist_list_table {
@@ -293,44 +293,27 b' function scrollToElement(element, percen'
293 293 });
294 294 }
295 295 });
296 $('.compare_view_files').on(
297 'mouseenter mouseleave', 'tr.line .lineno a',function(event) {
298 if (event.type === "mouseenter") {
299 $(this).parents('tr.line').addClass('hover');
300 } else {
301 $(this).parents('tr.line').removeClass('hover');
302 }
303 });
304 296
305 $('.compare_view_files').on(
306 'mouseenter mouseleave', 'tr.line .add-comment-line a',function(event){
307 if (event.type === "mouseenter") {
308 $(this).parents('tr.line').addClass('commenting');
309 } else {
310 $(this).parents('tr.line').removeClass('commenting');
311 }
312 });
313
314 $('body').on( /* TODO: replace the $('.compare_view_files').on('click') below
315 when new diffs are integrated */
316 'click', '.cb-lineno a', function(event) {
297 $('body').on('click', '.cb-lineno a', function(event) {
317 298
318 299 function sortNumber(a,b) {
319 300 return a - b;
320 301 }
321 302
322 if ($(this).attr('data-line-no') !== "") {
303 var lineNo = $(this).data('lineNo');
304 if (lineNo) {
323 305
324 306 // on shift, we do a range selection, if we got previous line
325 var prevLine = $('.cb-line-selected a').attr('data-line-no');
307 var prevLine = $('.cb-line-selected a').data('lineNo');
326 308 if (event.shiftKey && prevLine !== undefined) {
327 309 var prevLine = parseInt(prevLine);
328 var nextLine = parseInt($(this).attr('data-line-no'));
310 var nextLine = parseInt(lineNo);
329 311 var pos = [prevLine, nextLine].sort(sortNumber);
330 312 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
331 313
332 314 } else {
333 var nextLine = parseInt($(this).attr('data-line-no'));
315
316 var nextLine = parseInt(lineNo);
334 317 var pos = [nextLine, nextLine];
335 318 var anchor = '#L{0}'.format(pos[0]);
336 319
@@ -352,54 +335,35 b' function scrollToElement(element, percen'
352 335 }
353 336 });
354 337
355 // Replace URL without jumping to it if browser supports.
356 // Default otherwise
357 if (history.pushState) {
358 var new_location = location.href.rstrip('#');
359 if (location.hash) {
360 // location without hash
361 new_location = new_location.replace(location.hash, "");
362 }
363 338
364 // Make new anchor url
365 new_location = new_location + anchor;
366 history.pushState(true, document.title, new_location);
367
368 return false;
339 } else {
340 if ($(this).attr('name') !== undefined) {
341 // clear selection
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');
369 346 }
370 347 }
348
349 // Replace URL without jumping to it if browser supports.
350 // Default otherwise
351 if (history.pushState && anchor !== undefined) {
352 var new_location = location.href.rstrip('#');
353 if (location.hash) {
354 // location without hash
355 new_location = new_location.replace(location.hash, "");
356 }
357
358 // Make new anchor url
359 new_location = new_location + anchor;
360 history.pushState(true, document.title, new_location);
361
362 return false;
363 }
364
371 365 });
372 366
373 $('.compare_view_files').on( /* TODO: replace this with .cb function above
374 when new diffs are integrated */
375 'click', 'tr.line .lineno a',function(event) {
376 if ($(this).text() != ""){
377 $('tr.line').removeClass('selected');
378 $(this).parents("tr.line").addClass('selected');
379
380 // Replace URL without jumping to it if browser supports.
381 // Default otherwise
382 if (history.pushState) {
383 var new_location = location.href;
384 if (location.hash){
385 new_location = new_location.replace(location.hash, "");
386 }
387
388 // Make new anchor url
389 var new_location = new_location+$(this).attr('href');
390 history.pushState(true, document.title, new_location);
391
392 return false;
393 }
394 }
395 });
396
397 $('.compare_view_files').on(
398 'click', 'tr.line .add-comment-line a',function(event) {
399 var tr = $(event.currentTarget).parents('tr.line')[0];
400 injectInlineForm(tr);
401 return false;
402 });
403 367
404 368 $('.collapse_file').on('click', function(e) {
405 369 e.stopPropagation();
@@ -475,7 +475,7 b' var CommentsController = function() {'
475 475
476 476 this.getLineNumber = function(node) {
477 477 var $node = $(node);
478 var lineNo = $node.closest('td').attr('data-line-number');
478 var lineNo = $node.closest('td').attr('data-line-no');
479 479 if (lineNo === undefined && $node.data('commentInline')){
480 480 lineNo = $node.data('commentLineNo')
481 481 }
@@ -518,7 +518,7 b' from rhodecode.lib.diffs import NEW_FILE'
518 518
519 519 <tr class="cb-line">
520 520 <td class="cb-data ${action_class(line.original.action)}"
521 data-line-number="${line.original.lineno}"
521 data-line-no="${line.original.lineno}"
522 522 >
523 523 <div>
524 524 %if line.original.comments:
@@ -532,7 +532,7 b' from rhodecode.lib.diffs import NEW_FILE'
532 532 </div>
533 533 </td>
534 534 <td class="cb-lineno ${action_class(line.original.action)}"
535 data-line-number="${line.original.lineno}"
535 data-line-no="${line.original.lineno}"
536 536 %if old_line_anchor:
537 537 id="${old_line_anchor}"
538 538 %endif
@@ -542,7 +542,7 b' from rhodecode.lib.diffs import NEW_FILE'
542 542 %endif
543 543 </td>
544 544 <td class="cb-content ${action_class(line.original.action)}"
545 data-line-number="o${line.original.lineno}"
545 data-line-no="o${line.original.lineno}"
546 546 >
547 547 %if use_comments and line.original.lineno:
548 548 ${render_add_comment_button()}
@@ -553,7 +553,7 b' from rhodecode.lib.diffs import NEW_FILE'
553 553 %endif
554 554 </td>
555 555 <td class="cb-data ${action_class(line.modified.action)}"
556 data-line-number="${line.modified.lineno}"
556 data-line-no="${line.modified.lineno}"
557 557 >
558 558 <div>
559 559 %if line.modified.comments:
@@ -567,7 +567,7 b' from rhodecode.lib.diffs import NEW_FILE'
567 567 </div>
568 568 </td>
569 569 <td class="cb-lineno ${action_class(line.modified.action)}"
570 data-line-number="${line.modified.lineno}"
570 data-line-no="${line.modified.lineno}"
571 571 %if new_line_anchor:
572 572 id="${new_line_anchor}"
573 573 %endif
@@ -577,7 +577,7 b' from rhodecode.lib.diffs import NEW_FILE'
577 577 %endif
578 578 </td>
579 579 <td class="cb-content ${action_class(line.modified.action)}"
580 data-line-number="n${line.modified.lineno}"
580 data-line-no="n${line.modified.lineno}"
581 581 >
582 582 %if use_comments and line.modified.lineno:
583 583 ${render_add_comment_button()}
@@ -615,7 +615,7 b' from rhodecode.lib.diffs import NEW_FILE'
615 615 </div>
616 616 </td>
617 617 <td class="cb-lineno ${action_class(action)}"
618 data-line-number="${old_line_no}"
618 data-line-no="${old_line_no}"
619 619 %if old_line_anchor:
620 620 id="${old_line_anchor}"
621 621 %endif
@@ -625,7 +625,7 b' from rhodecode.lib.diffs import NEW_FILE'
625 625 %endif
626 626 </td>
627 627 <td class="cb-lineno ${action_class(action)}"
628 data-line-number="${new_line_no}"
628 data-line-no="${new_line_no}"
629 629 %if new_line_anchor:
630 630 id="${new_line_anchor}"
631 631 %endif
@@ -635,7 +635,7 b' from rhodecode.lib.diffs import NEW_FILE'
635 635 %endif
636 636 </td>
637 637 <td class="cb-content ${action_class(action)}"
638 data-line-number="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
638 data-line-no="${new_line_no and 'n' or 'o'}${new_line_no or old_line_no}"
639 639 >
640 640 %if use_comments:
641 641 ${render_add_comment_button()}
General Comments 0
You need to be logged in to leave comments. Login now