diff_box_split.tmpl 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {{range $i, $file := .Diff.Files}}
  2. <div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
  3. <h4 class="ui top attached normal header">
  4. <div class="diff-counter count ui left">
  5. {{if $file.IsBin}}
  6. {{$.i18n.Tr "repo.diff.bin"}}
  7. {{else if not $file.IsRenamed}}
  8. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  9. <span class="bar">
  10. <span class="pull-left add"></span>
  11. <span class="pull-left del"></span>
  12. </span>
  13. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  14. {{end}}
  15. </div>
  16. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</span>
  17. <div class="ui right">
  18. {{if $file.IsDeleted}}
  19. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  20. {{else}}
  21. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  22. {{end}}
  23. </div>
  24. </h4>
  25. <div class="ui attached table segment">
  26. {{if not $file.IsRenamed}}
  27. {{$isImage := (call $.IsImageFile $file.Name)}}
  28. {{if and $isImage}}
  29. <div class="center">
  30. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  31. </div>
  32. {{else}}
  33. <div class="file-body file-code code-view code-diff">
  34. <table>
  35. <tbody>
  36. {{range $j, $section := .Sections}}
  37. {{range $k, $line := .Lines}}
  38. <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
  39. {{if eq .Type 4}}
  40. <td class="lines-num lines-num-old">
  41. <span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
  42. </td>
  43. <td class="lines-code halfwidth">
  44. <pre class="wrap">{{$line.Content}}</pre>
  45. </td>
  46. <td class="lines-num lines-num-old">
  47. <span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
  48. </td>
  49. <td class="lines-code halfwidth">
  50. <pre class="wrap">{{$line.Content}}</pre>
  51. </td>
  52. {{else}}
  53. <td class="lines-num lines-num-old">
  54. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
  55. </td>
  56. <td class="lines-code halfwidth">
  57. <pre class="wrap">{{if $line.LeftIdx}}{{$line.Content}}{{end}}</pre>
  58. </td>
  59. <td class="lines-num lines-num-new">
  60. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
  61. </td>
  62. <td class="lines-code halfwidth">
  63. <pre class="wrap">{{if $line.RightIdx}}{{$line.Content}}{{end}}</pre>
  64. </td>
  65. {{end}}
  66. </tr>
  67. {{end}}
  68. {{end}}
  69. </tbody>
  70. </table>
  71. </div>
  72. <script>
  73. (function() {
  74. $('.add-code').each(function() {
  75. var prev = $(this).prev();
  76. if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
  77. while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
  78. prev = prev.prev();
  79. }
  80. prev.children().eq(3).html($(this).children().eq(3).html());
  81. prev.children().eq(2).html($(this).children().eq(2).html());
  82. prev.children().eq(3).addClass('add-code');
  83. prev.children().eq(2).addClass('add-code');
  84. // prev.children().eq(2).attr('style', 'background-color: #eaffea !important');
  85. // prev.children().eq(2).children().eq(0).attr('style', 'background-color: #eaffea !important');
  86. // prev.children().eq(3).attr('style', 'background-color: #eaffea !important');
  87. // prev.children().eq(3).children().eq(0).attr('style', 'background-color: #eaffea !important');
  88. $(this).remove();
  89. }
  90. });
  91. }());
  92. </script>
  93. {{end}}
  94. {{end}}
  95. </div>
  96. </div>
  97. <br>
  98. {{end}}