From 149a9df9e8e7e91c813232fb82e644b0d3369b09 Mon Sep 17 00:00:00 2001 From: Benno Date: Fri, 15 Nov 2019 10:52:59 +0800 Subject: Expand/Collapse Files and Blob Excerpt while Reviewing/Comparing code (#8924) * update #8659 fold/unfold code diffs * add fold button style * update #8659 implement expand up/down codes (blob excerpt) * fix golint errors * fix expand direction * remove debug message * update css style for blob exceprt * fix typo in comment * update style sheet with less * update expect diff (add SectionInfo) * update #8942 accept suggested change (fix typo) * close reader and check file type before get tail section * adjust button position and check file type before insert fold button * move index js to web_src * merge index.js with master * generate index.js * update js coding style --- templates/repo/diff/blob_excerpt.tmpl | 50 ++++++++++++++++++++++++++++++++ templates/repo/diff/box.tmpl | 42 +++++++++++++++++++-------- templates/repo/diff/section_unified.tmpl | 14 +++++++-- 3 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 templates/repo/diff/blob_excerpt.tmpl (limited to 'templates/repo/diff') diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl new file mode 100644 index 0000000000..5f0cd30bb7 --- /dev/null +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -0,0 +1,50 @@ +{{if $.IsSplitStyle}} + {{range $k, $line := $.section.Lines}} + + {{if eq .GetType 4}} + + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 2)}} + + {{end}} + + {{$.section.GetComputedInlineDiffFor $line}} + {{else}} + + {{if $line.LeftIdx}}{{end}} + {{if $line.LeftIdx}}{{$.section.GetComputedInlineDiffFor $line}}{{end}} + + {{if $line.RightIdx}}{{end}} + {{if $line.RightIdx}}{{$.section.GetComputedInlineDiffFor $line}}{{end}} + {{end}} + + {{end}} +{{else}} + {{range $k, $line := $.section.Lines}} + + {{if eq .GetType 4}} + + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 2)}} + + {{end}} + + {{else}} + + + {{end}} + + {{$.section.GetComputedInlineDiffFor $line}} + + {{end}} +{{end}} \ No newline at end of file diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index a12fc9bd4b..088dc5718d 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -81,6 +81,15 @@ {{else}}

+ {{$isImage := false}} + {{if $file.IsDeleted}} + {{$isImage = (call $.IsImageFileInBase $file.Name)}} + {{else}} + {{$isImage = (call $.IsImageFileInHead $file.Name)}} + {{end}} + {{if or (not $file.IsBin) $isImage}} + + {{end}}
{{if $file.IsBin}} {{$.i18n.Tr "repo.diff.bin"}} @@ -104,12 +113,6 @@

{{if ne $file.Type 4}} - {{$isImage := false}} - {{if $file.IsDeleted}} - {{$isImage = (call $.IsImageFileInBase $file.Name)}} - {{else}} - {{$isImage = (call $.IsImageFileInHead $file.Name)}} - {{end}}
@@ -121,12 +124,27 @@ {{range $j, $section := $file.Sections}} {{range $k, $line := $section.Lines}} - - - - - - + {{if eq .GetType 4}} + + + {{else}} + + + + + + + {{end}} {{if gt (len $line.Comments) 0}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 9a60c238dc..fcc511af75 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -4,9 +4,17 @@ {{range $k, $line := $section.Lines}} {{if eq .GetType 4}} - + {{else}} -- cgit v1.2.3
{{if $line.LeftIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}+{{end}}{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}{{if $line.RightIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}+{{end}}{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 2)}} + + {{end}} + {{$section.GetComputedInlineDiffFor $line}}{{if $line.LeftIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}+{{end}}{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}{{if $line.RightIdx}}{{end}}{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}+{{end}}{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
- {{/* {{if gt $j 0}}{{end}} */}} - + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{end}} + {{if or (eq $line.GetExpandDirection 2)}} + + {{end}} +