##// 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 div.diffblock .sidebyside {
22 div.diffblock .sidebyside {
32 background: #ffffff;
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 .compare_view_filepath {
1546 .compare_view_filepath {
1555 color: @grey1;
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 // Gist List
489 // Gist List
542 #gist_list_table {
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(
297 $('body').on('click', '.cb-lineno a', function(event) {
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) {
317
298
318 function sortNumber(a,b) {
299 function sortNumber(a,b) {
319 return a - b;
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 // on shift, we do a range selection, if we got previous line
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 if (event.shiftKey && prevLine !== undefined) {
308 if (event.shiftKey && prevLine !== undefined) {
327 var prevLine = parseInt(prevLine);
309 var prevLine = parseInt(prevLine);
328 var nextLine = parseInt($(this).attr('data-line-no'));
310 var nextLine = parseInt(lineNo);
329 var pos = [prevLine, nextLine].sort(sortNumber);
311 var pos = [prevLine, nextLine].sort(sortNumber);
330 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
312 var anchor = '#L{0}-{1}'.format(pos[0], pos[1]);
331
313
332 } else {
314 } else {
333 var nextLine = parseInt($(this).attr('data-line-no'));
315
316 var nextLine = parseInt(lineNo);
334 var pos = [nextLine, nextLine];
317 var pos = [nextLine, nextLine];
335 var anchor = '#L{0}'.format(pos[0]);
318 var anchor = '#L{0}'.format(pos[0]);
336
319
@@ -352,9 +335,20 b' function scrollToElement(element, percen'
352 }
335 }
353 });
336 });
354
337
338
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');
346 }
347 }
348
355 // Replace URL without jumping to it if browser supports.
349 // Replace URL without jumping to it if browser supports.
356 // Default otherwise
350 // Default otherwise
357 if (history.pushState) {
351 if (history.pushState && anchor !== undefined) {
358 var new_location = location.href.rstrip('#');
352 var new_location = location.href.rstrip('#');
359 if (location.hash) {
353 if (location.hash) {
360 // location without hash
354 // location without hash
@@ -367,39 +361,9 b' function scrollToElement(element, percen'
367
361
368 return false;
362 return false;
369 }
363 }
370 }
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 $('.collapse_file').on('click', function(e) {
368 $('.collapse_file').on('click', function(e) {
405 e.stopPropagation();
369 e.stopPropagation();
@@ -475,7 +475,7 b' var CommentsController = function() {'
475
475
476 this.getLineNumber = function(node) {
476 this.getLineNumber = function(node) {
477 var $node = $(node);
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 if (lineNo === undefined && $node.data('commentInline')){
479 if (lineNo === undefined && $node.data('commentInline')){
480 lineNo = $node.data('commentLineNo')
480 lineNo = $node.data('commentLineNo')
481 }
481 }
@@ -518,7 +518,7 b' from rhodecode.lib.diffs import NEW_FILE'
518
518
519 <tr class="cb-line">
519 <tr class="cb-line">
520 <td class="cb-data ${action_class(line.original.action)}"
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 <div>
523 <div>
524 %if line.original.comments:
524 %if line.original.comments:
@@ -532,7 +532,7 b' from rhodecode.lib.diffs import NEW_FILE'
532 </div>
532 </div>
533 </td>
533 </td>
534 <td class="cb-lineno ${action_class(line.original.action)}"
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 %if old_line_anchor:
536 %if old_line_anchor:
537 id="${old_line_anchor}"
537 id="${old_line_anchor}"
538 %endif
538 %endif
@@ -542,7 +542,7 b' from rhodecode.lib.diffs import NEW_FILE'
542 %endif
542 %endif
543 </td>
543 </td>
544 <td class="cb-content ${action_class(line.original.action)}"
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 %if use_comments and line.original.lineno:
547 %if use_comments and line.original.lineno:
548 ${render_add_comment_button()}
548 ${render_add_comment_button()}
@@ -553,7 +553,7 b' from rhodecode.lib.diffs import NEW_FILE'
553 %endif
553 %endif
554 </td>
554 </td>
555 <td class="cb-data ${action_class(line.modified.action)}"
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 <div>
558 <div>
559 %if line.modified.comments:
559 %if line.modified.comments:
@@ -567,7 +567,7 b' from rhodecode.lib.diffs import NEW_FILE'
567 </div>
567 </div>
568 </td>
568 </td>
569 <td class="cb-lineno ${action_class(line.modified.action)}"
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 %if new_line_anchor:
571 %if new_line_anchor:
572 id="${new_line_anchor}"
572 id="${new_line_anchor}"
573 %endif
573 %endif
@@ -577,7 +577,7 b' from rhodecode.lib.diffs import NEW_FILE'
577 %endif
577 %endif
578 </td>
578 </td>
579 <td class="cb-content ${action_class(line.modified.action)}"
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 %if use_comments and line.modified.lineno:
582 %if use_comments and line.modified.lineno:
583 ${render_add_comment_button()}
583 ${render_add_comment_button()}
@@ -615,7 +615,7 b' from rhodecode.lib.diffs import NEW_FILE'
615 </div>
615 </div>
616 </td>
616 </td>
617 <td class="cb-lineno ${action_class(action)}"
617 <td class="cb-lineno ${action_class(action)}"
618 data-line-number="${old_line_no}"
618 data-line-no="${old_line_no}"
619 %if old_line_anchor:
619 %if old_line_anchor:
620 id="${old_line_anchor}"
620 id="${old_line_anchor}"
621 %endif
621 %endif
@@ -625,7 +625,7 b' from rhodecode.lib.diffs import NEW_FILE'
625 %endif
625 %endif
626 </td>
626 </td>
627 <td class="cb-lineno ${action_class(action)}"
627 <td class="cb-lineno ${action_class(action)}"
628 data-line-number="${new_line_no}"
628 data-line-no="${new_line_no}"
629 %if new_line_anchor:
629 %if new_line_anchor:
630 id="${new_line_anchor}"
630 id="${new_line_anchor}"
631 %endif
631 %endif
@@ -635,7 +635,7 b' from rhodecode.lib.diffs import NEW_FILE'
635 %endif
635 %endif
636 </td>
636 </td>
637 <td class="cb-content ${action_class(action)}"
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 %if use_comments:
640 %if use_comments:
641 ${render_add_comment_button()}
641 ${render_add_comment_button()}
General Comments 0
You need to be logged in to leave comments. Login now