Skip to content

Commit b1c1e15

Browse files
6543zeripath
authored andcommittedOct 21, 2019
Ensure that diff stats can scroll independently of the diff (#8581)
This PR ensures that once opened the diff stats detail box can be scrolled independently of the diff on the compare page. Fixes #5532 Details: * make diff-detail-box the main container * move file diff at the same level as diff-stats * make diff-view options sticy again * make diff-stats scroll if to mouch * rm useless css info * less: mv diff-stats to own class * use new css class * cleanup less file * diff-counter: margin-right: 15px; * make CI work * make numbers colorful * add sign (-/+) to numbers
1 parent b539a6e commit b1c1e15

File tree

3 files changed

+205
-190
lines changed

3 files changed

+205
-190
lines changed
 

‎public/css/index.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,6 @@ i.icon.centerlock{top:1.5em}
667667
.repository #commits-table td.sha .sha.label.isSigned.isVerified:hover,.repository #repo-files-table .sha.label.isSigned.isVerified:hover{background:rgba(33,186,69,.3)!important}
668668
.repository .diff-detail-box{padding:7px 0;background:#fff;line-height:30px}
669669
.repository .diff-detail-box>div:after{clear:both;content:"";display:block}
670-
.repository .diff-detail-box ol{clear:both;padding-left:0;margin-top:5px;margin-bottom:28px}
671-
.repository .diff-detail-box ol li{list-style:none;padding-bottom:4px;margin-bottom:4px;border-bottom:1px dashed #ddd;padding-left:6px}
672670
.repository .diff-detail-box span.status{display:inline-block;width:12px;height:12px;margin-right:8px;vertical-align:middle}
673671
.repository .diff-detail-box span.status.modify{background-color:#f0db88}
674672
.repository .diff-detail-box span.status.add{background-color:#b4e2b4}
@@ -705,6 +703,11 @@ i.icon.centerlock{top:1.5em}
705703
.repository .diff-file-box.file-content{clear:right}
706704
.repository .diff-file-box.file-content img{max-width:100%;padding:5px 5px 0 5px}
707705
.repository .diff-file-box.file-content img.emoji{padding:0}
706+
.repository .diff-stats{clear:both;margin-bottom:5px;max-height:400px;overflow:auto;padding-left:0}
707+
.repository .diff-stats li{list-style:none;padding-bottom:4px;margin-bottom:4px;border-bottom:1px dashed #ddd;padding-left:6px}
708+
.repository .diff-stats .diff-counter{margin-right:15px}
709+
.repository .diff-stats .diff-counter .del{color:red}
710+
.repository .diff-stats .diff-counter .add{color:green}
708711
.repository .repo-search-result{padding-top:10px;padding-bottom:10px}
709712
.repository .repo-search-result .lines-num a{color:inherit}
710713
.repository.quickstart .guide .item{padding:1em}

‎public/less/_repository.less

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,21 +1246,6 @@
12461246
display: block;
12471247
}
12481248

1249-
ol {
1250-
clear: both;
1251-
padding-left: 0;
1252-
margin-top: 5px;
1253-
margin-bottom: 28px;
1254-
1255-
li {
1256-
list-style: none;
1257-
padding-bottom: 4px;
1258-
margin-bottom: 4px;
1259-
border-bottom: 1px dashed #dddddd;
1260-
padding-left: 6px;
1261-
}
1262-
}
1263-
12641249
span.status {
12651250
display: inline-block;
12661251
width: 12px;
@@ -1475,6 +1460,34 @@
14751460
}
14761461
}
14771462

1463+
.diff-stats {
1464+
1465+
clear: both;
1466+
margin-bottom: 5px;
1467+
max-height: 400px;
1468+
overflow: auto;
1469+
padding-left: 0;
1470+
1471+
li {
1472+
list-style: none;
1473+
padding-bottom: 4px;
1474+
margin-bottom: 4px;
1475+
border-bottom: 1px dashed #dddddd;
1476+
padding-left: 6px;
1477+
}
1478+
1479+
.diff-counter {
1480+
margin-right: 15px;
1481+
1482+
.del {
1483+
color: red;
1484+
}
1485+
.add {
1486+
color: green;
1487+
}
1488+
}
1489+
}
1490+
14781491
.repo-search-result {
14791492
padding-top: 10px;
14801493
padding-bottom: 10px;

‎templates/repo/diff/box.tmpl

Lines changed: 172 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</div>
1717
<h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
1818
{{else}}
19-
<div class="diff-detail-box diff-box ui sticky">
20-
<div>
19+
<div>
20+
<div class="diff-detail-box diff-box ui sticky">
2121
<i class="fa fa-retweet"></i>
2222
{{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
2323
<div class="ui right">
@@ -32,17 +32,17 @@
3232
{{end}}
3333
</div>
3434
</div>
35-
<ol class="detail-files hide" id="diff-files">
35+
<ol class="diff-detail-box diff-stats detail-files hide" id="diff-files">
3636
{{range .Diff.Files}}
3737
<li>
3838
<div class="diff-counter count pull-right">
3939
{{if not .IsBin}}
40-
<span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
40+
<span class="add" data-line="{{.Addition}}">+{{.Addition}}</span>
4141
<span class="bar">
4242
<div class="pull-left add"></div>
4343
<div class="pull-left del"></div>
4444
</span>
45-
<span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
45+
<span class="del" data-line="{{.Deletion}}">-{{.Deletion}}</span>
4646
{{else}}
4747
<span>{{$.i18n.Tr "repo.diff.bin"}}</span>
4848
{{end}}
@@ -53,188 +53,187 @@
5353
</li>
5454
{{end}}
5555
</ol>
56-
</div>
57-
58-
{{range $i, $file := .Diff.Files}}
59-
{{if $file.IsIncomplete}}
60-
<div class="diff-file-box diff-box file-content">
61-
<h4 class="ui top attached normal header rounded">
62-
<div class="diff-counter count ui left">
63-
{{if not $file.IsRenamed}}
64-
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
65-
<span class="bar">
66-
<div class="pull-left add"></div>
67-
<div class="pull-left del"></div>
68-
</span>
69-
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
70-
{{end}}
71-
</div>
72-
<span class="file">{{$file.Name}}</span>
73-
<div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
74-
{{if not $file.IsSubmodule}}
75-
{{if $file.IsDeleted}}
76-
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
77-
{{else}}
78-
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
79-
{{end}}
80-
{{end}}
81-
</h4>
82-
</div>
83-
{{else}}
84-
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
85-
<h4 class="ui top attached normal header">
86-
<div class="diff-counter count">
87-
{{if $file.IsBin}}
88-
{{$.i18n.Tr "repo.diff.bin"}}
89-
{{else if not $file.IsRenamed}}
90-
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
91-
<span class="bar">
92-
<div class="pull-left add"></div>
93-
<div class="pull-left del"></div>
94-
</span>
95-
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
96-
{{end}}
97-
</div>
98-
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
99-
{{if not $file.IsSubmodule}}
100-
{{if $file.IsDeleted}}
101-
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
102-
{{else}}
103-
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
56+
{{range $i, $file := .Diff.Files}}
57+
{{if $file.IsIncomplete}}
58+
<div class="diff-file-box diff-box file-content">
59+
<h4 class="ui top attached normal header rounded">
60+
<div class="diff-counter count ui left">
61+
{{if not $file.IsRenamed}}
62+
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
63+
<span class="bar">
64+
<div class="pull-left add"></div>
65+
<div class="pull-left del"></div>
66+
</span>
67+
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
68+
{{end}}
69+
</div>
70+
<span class="file">{{$file.Name}}</span>
71+
<div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
72+
{{if not $file.IsSubmodule}}
73+
{{if $file.IsDeleted}}
74+
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
75+
{{else}}
76+
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
77+
{{end}}
10478
{{end}}
105-
{{end}}
106-
</h4>
107-
<div class="ui attached unstackable table segment">
108-
{{if ne $file.Type 4}}
109-
{{$isImage := false}}
110-
{{if $file.IsDeleted}}
111-
{{$isImage = (call $.IsImageFileInBase $file.Name)}}
112-
{{else}}
113-
{{$isImage = (call $.IsImageFileInHead $file.Name)}}
79+
</h4>
80+
</div>
81+
{{else}}
82+
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
83+
<h4 class="ui top attached normal header">
84+
<div class="diff-counter count">
85+
{{if $file.IsBin}}
86+
{{$.i18n.Tr "repo.diff.bin"}}
87+
{{else if not $file.IsRenamed}}
88+
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
89+
<span class="bar">
90+
<div class="pull-left add"></div>
91+
<div class="pull-left del"></div>
92+
</span>
93+
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
94+
{{end}}
95+
</div>
96+
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
97+
{{if not $file.IsSubmodule}}
98+
{{if $file.IsDeleted}}
99+
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
100+
{{else}}
101+
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
102+
{{end}}
114103
{{end}}
115-
<div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
116-
<table>
117-
<tbody>
118-
{{if $isImage}}
119-
{{template "repo/diff/image_diff" dict "file" . "root" $}}
120-
{{else}}
121-
{{if $.IsSplitStyle}}
122-
{{$highlightClass := $file.GetHighlightClass}}
123-
{{range $j, $section := $file.Sections}}
124-
{{range $k, $line := $section.Lines}}
125-
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
126-
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
127-
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
128-
<td class="lines-code lines-code-old halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
129-
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
130-
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
131-
<td class="lines-code lines-code-new halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
132-
</tr>
133-
{{if gt (len $line.Comments) 0}}
134-
<tr class="add-code-comment">
135-
<td class="lines-num"></td>
136-
<td class="lines-type-marker"></td>
137-
<td class="add-comment-left">
138-
{{if eq $line.GetCommentSide "previous"}}
139-
<div class="field comment-code-cloud">
140-
<div class="comment-list">
141-
<ui class="ui comments">
142-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
143-
</ui>
104+
</h4>
105+
<div class="ui attached unstackable table segment">
106+
{{if ne $file.Type 4}}
107+
{{$isImage := false}}
108+
{{if $file.IsDeleted}}
109+
{{$isImage = (call $.IsImageFileInBase $file.Name)}}
110+
{{else}}
111+
{{$isImage = (call $.IsImageFileInHead $file.Name)}}
112+
{{end}}
113+
<div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
114+
<table>
115+
<tbody>
116+
{{if $isImage}}
117+
{{template "repo/diff/image_diff" dict "file" . "root" $}}
118+
{{else}}
119+
{{if $.IsSplitStyle}}
120+
{{$highlightClass := $file.GetHighlightClass}}
121+
{{range $j, $section := $file.Sections}}
122+
{{range $k, $line := $section.Lines}}
123+
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
124+
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
125+
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
126+
<td class="lines-code lines-code-old halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
127+
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
128+
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
129+
<td class="lines-code lines-code-new halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}} nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
130+
</tr>
131+
{{if gt (len $line.Comments) 0}}
132+
<tr class="add-code-comment">
133+
<td class="lines-num"></td>
134+
<td class="lines-type-marker"></td>
135+
<td class="add-comment-left">
136+
{{if eq $line.GetCommentSide "previous"}}
137+
<div class="field comment-code-cloud">
138+
<div class="comment-list">
139+
<ui class="ui comments">
140+
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
141+
</ui>
142+
</div>
143+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
144144
</div>
145-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
146-
</div>
147-
{{end}}
148-
</td>
149-
<td class="lines-num"></td>
150-
<td class="lines-type-marker"></td>
151-
<td class="add-comment-right">
152-
{{if eq $line.GetCommentSide "proposed"}}
153-
<div class="field comment-code-cloud">
154-
<div class="comment-list">
155-
<ui class="ui comments">
156-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
157-
</ui>
145+
{{end}}
146+
</td>
147+
<td class="lines-num"></td>
148+
<td class="lines-type-marker"></td>
149+
<td class="add-comment-right">
150+
{{if eq $line.GetCommentSide "proposed"}}
151+
<div class="field comment-code-cloud">
152+
<div class="comment-list">
153+
<ui class="ui comments">
154+
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
155+
</ui>
156+
</div>
157+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
158158
</div>
159-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
160-
</div>
161-
{{end}}
162-
</td>
163-
</tr>
159+
{{end}}
160+
</td>
161+
</tr>
162+
{{end}}
164163
{{end}}
165164
{{end}}
165+
{{else}}
166+
{{template "repo/diff/section_unified" dict "file" . "root" $}}
166167
{{end}}
167-
{{else}}
168-
{{template "repo/diff/section_unified" dict "file" . "root" $}}
169168
{{end}}
170-
{{end}}
171-
</tbody>
172-
</table>
173-
</div>
174-
{{end}}
169+
</tbody>
170+
</table>
171+
</div>
172+
{{end}}
173+
</div>
175174
</div>
176-
</div>
175+
{{end}}
176+
<br>
177177
{{end}}
178-
<br>
179-
{{end}}
180178

181-
{{if .Diff.IsIncomplete}}
182-
<div class="diff-file-box diff-box file-content">
183-
<h4 class="ui top attached normal header">
184-
{{$.i18n.Tr "repo.diff.too_many_files"}}
185-
</h4>
186-
</div>
187-
{{end}}
179+
{{if .Diff.IsIncomplete}}
180+
<div class="diff-file-box diff-box file-content">
181+
<h4 class="ui top attached normal header">
182+
{{$.i18n.Tr "repo.diff.too_many_files"}}
183+
</h4>
184+
</div>
185+
{{end}}
188186

189-
{{if not $.Repository.IsArchived}}
190-
<div id="pull_review_add_comment" class="hide">
191-
{{template "repo/diff/new_comment" dict "root" .}}
192-
</div>
193-
<div class="hide" id="edit-content-form">
194-
<div class="ui comment form">
195-
<div class="ui top attached tabular menu">
196-
<a class="active write item">{{$.i18n.Tr "write"}}</a>
197-
<a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
198-
</div>
199-
<div class="ui bottom attached active write tab segment">
200-
<textarea tabindex="1" name="content"></textarea>
201-
</div>
202-
<div class="ui bottom attached tab preview segment markdown">
203-
{{$.i18n.Tr "loading"}}
204-
</div>
205-
<div class="text right edit buttons">
206-
<div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
207-
<div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
208-
</div>
209-
</div>
210-
</div>
211-
{{end}}
187+
{{if not $.Repository.IsArchived}}
188+
<div id="pull_review_add_comment" class="hide">
189+
{{template "repo/diff/new_comment" dict "root" .}}
190+
</div>
191+
<div class="hide" id="edit-content-form">
192+
<div class="ui comment form">
193+
<div class="ui top attached tabular menu">
194+
<a class="active write item">{{$.i18n.Tr "write"}}</a>
195+
<a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
196+
</div>
197+
<div class="ui bottom attached active write tab segment">
198+
<textarea tabindex="1" name="content"></textarea>
199+
</div>
200+
<div class="ui bottom attached tab preview segment markdown">
201+
{{$.i18n.Tr "loading"}}
202+
</div>
203+
<div class="text right edit buttons">
204+
<div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
205+
<div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
206+
</div>
207+
</div>
208+
</div>
209+
{{end}}
212210

213-
{{if .IsSplitStyle}}
214-
<script>
215-
document.addEventListener('DOMContentLoaded', function() {
216-
$('tr.add-code').each(function() {
217-
var prev = $(this).prev();
218-
if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
219-
while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
220-
prev = prev.prev();
221-
}
222-
prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
223-
prev.children().eq(3).html($(this).children().eq(3).html());
224-
prev.children().eq(4).html($(this).children().eq(4).html());
225-
prev.children().eq(5).html($(this).children().eq(5).html());
211+
{{if .IsSplitStyle}}
212+
<script>
213+
document.addEventListener('DOMContentLoaded', function() {
214+
$('tr.add-code').each(function() {
215+
var prev = $(this).prev();
216+
if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
217+
while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
218+
prev = prev.prev();
219+
}
220+
prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
221+
prev.children().eq(3).html($(this).children().eq(3).html());
222+
prev.children().eq(4).html($(this).children().eq(4).html());
223+
prev.children().eq(5).html($(this).children().eq(5).html());
226224

227-
prev.children().eq(0).addClass('del-code');
228-
prev.children().eq(1).addClass('del-code');
229-
prev.children().eq(2).addClass('del-code');
230-
prev.children().eq(3).addClass('add-code');
231-
prev.children().eq(4).addClass('add-code');
232-
prev.children().eq(5).addClass('add-code');
225+
prev.children().eq(0).addClass('del-code');
226+
prev.children().eq(1).addClass('del-code');
227+
prev.children().eq(2).addClass('del-code');
228+
prev.children().eq(3).addClass('add-code');
229+
prev.children().eq(4).addClass('add-code');
230+
prev.children().eq(5).addClass('add-code');
233231

234-
$(this).remove();
235-
}
232+
$(this).remove();
233+
}
234+
});
236235
});
237-
});
238-
</script>
239-
{{end}}
236+
</script>
237+
{{end}}
238+
</div>
240239
{{end}}

0 commit comments

Comments
 (0)
Please sign in to comment.