forked from gitea/gitea
		
	Improve accessibility when (re-)viewing files (#24817)
Visually, nothing should have changed. Changes include - Convert most `<a [no href]>` to `<button>` when (re-)viewing files: - `<a [no href]>` are, by HTML definition, not a link and hence cannot be focused - `<a class="ui button">` can now be clicked (again?) using <kbd>Enter</kbd> - Previously, the installed keypress handler on `.ui.button` elements disabled it for links somehow - The `(un)escape file`, the `expand section` and the `expand/collapse file` buttons can now be focused (and subsequently clicked using only the keyboard) - You can now press <kbd>Space</kbd> on a focused `View file` checkbox to mark the file as viewed. - previously, this was impossible as this checkbox listened on the wrong event listener The `add code comment` button has been left inaccessible for now as it requires quite a bit of extra logic so that it is unhidden when it is focused (you can otherwise focus it without seeing it as you are not hovering on the corresponding line). --------- Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		
							parent
							
								
									c59a057297
								
							
						
					
					
						commit
						e95b42e187
					
				| @ -11,8 +11,8 @@ | ||||
| 				{{end}} | ||||
| 				<a class="ui tiny button" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{.locale.Tr "repo.normal_view"}}</a> | ||||
| 				<a class="ui tiny button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{.locale.Tr "repo.file_history"}}</a> | ||||
| 				<a class="ui tiny button unescape-button">{{.locale.Tr "repo.unescape_control_characters"}}</a> | ||||
| 				<a class="ui tiny button escape-button gt-hidden">{{.locale.Tr "repo.escape_control_characters"}}</a> | ||||
| 				<button class="ui tiny button unescape-button">{{.locale.Tr "repo.unescape_control_characters"}}</button> | ||||
| 				<button class="ui tiny button escape-button gt-hidden">{{.locale.Tr "repo.escape_control_characters"}}</button> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 	</h4> | ||||
| @ -52,7 +52,7 @@ | ||||
| 							{{if $.EscapeStatus.Escaped}} | ||||
| 								<td class="lines-escape"> | ||||
| 									{{if $row.EscapeStatus.Escaped}} | ||||
| 										<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $row "locale" $.locale}}"></a> | ||||
| 										<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $row "locale" $.locale}}"></button> | ||||
| 									{{end}} | ||||
| 								</td> | ||||
| 							{{end}} | ||||
|  | ||||
| @ -3,28 +3,30 @@ | ||||
| 	<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}"> | ||||
| 		{{if eq .GetType 4}} | ||||
| 			<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"> | ||||
| 				<div class="gt-df"> | ||||
| 				{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 					<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold-down"}} | ||||
| 					</a> | ||||
| 					</button> | ||||
| 				{{end}} | ||||
| 				{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 					<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold-up"}} | ||||
| 					</a> | ||||
| 					</button> | ||||
| 				{{end}} | ||||
| 				{{if eq $line.GetExpandDirection 2}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 					<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold"}} | ||||
| 					</a> | ||||
| 					</button> | ||||
| 				{{end}} | ||||
| 				</div> | ||||
| 			</td> | ||||
| 			<td colspan="7" class="lines-code lines-code-old ">{{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}}{{/* | ||||
| 				*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}</td> | ||||
| 		{{else}} | ||||
| 			{{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}} | ||||
| 			<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$.FileNameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> | ||||
| 			<td class="blob-excerpt lines-escape lines-escape-old">{{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></a>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-escape lines-escape-old">{{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></button>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker=""></span>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-code lines-code-old">{{/* | ||||
| 				*/}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* | ||||
| @ -32,7 +34,7 @@ | ||||
| 				*/}}{{end}}{{/* | ||||
| 			*/}}</td> | ||||
| 			<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$.FileNameHash}}R{{$line.RightIdx}}{{end}}"></span></td> | ||||
| 			<td class="blob-excerpt lines-escape lines-escape-new">{{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></a>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-escape lines-escape-new">{{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></button>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker=""></span>{{end}}</td> | ||||
| 			<td class="blob-excerpt lines-code lines-code-new">{{/* | ||||
| 				*/}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* | ||||
| @ -47,28 +49,30 @@ | ||||
| 	<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}"> | ||||
| 		{{if eq .GetType 4}} | ||||
| 			<td colspan="2" class="lines-num"> | ||||
| 				{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold-down"}} | ||||
| 					</a> | ||||
| 				{{end}} | ||||
| 				{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold-up"}} | ||||
| 					</a> | ||||
| 				{{end}} | ||||
| 				{{if eq $line.GetExpandDirection 2}} | ||||
| 					<a role="button" class="blob-excerpt" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 						{{svg "octicon-fold"}} | ||||
| 					</a> | ||||
| 				{{end}} | ||||
| 				<div class="gt-df"> | ||||
| 					{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 						<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 							{{svg "octicon-fold-down"}} | ||||
| 						</button> | ||||
| 					{{end}} | ||||
| 					{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 						<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 							{{svg "octicon-fold-up"}} | ||||
| 						</button> | ||||
| 					{{end}} | ||||
| 					{{if eq $line.GetExpandDirection 2}} | ||||
| 						<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}"> | ||||
| 							{{svg "octicon-fold"}} | ||||
| 						</button> | ||||
| 					{{end}} | ||||
| 				</div> | ||||
| 			</td> | ||||
| 		{{else}} | ||||
| 			<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$.FileNameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> | ||||
| 			<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$.FileNameHash}}R{{$line.RightIdx}}{{end}}"></span></td> | ||||
| 		{{end}} | ||||
| 		{{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}} | ||||
| 		<td class="blob-excerpt lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></a>{{end}}</td> | ||||
| 		<td class="blob-excerpt lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"></button>{{end}}</td> | ||||
| 		<td class="blob-excerpt lines-type-marker"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> | ||||
| 		<td class="blob-excerpt lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}"><code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.locale}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code></td> | ||||
| 	</tr> | ||||
|  | ||||
| @ -90,13 +90,13 @@ | ||||
| 						<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} gt-mt-3" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if or ($file.ShouldBeHidden) (not $isExpandable)}}data-folded="true"{{end}}> | ||||
| 							<h4 class="diff-file-header sticky-2nd-row ui top attached normal header gt-df gt-ac gt-sb"> | ||||
| 								<div class="diff-file-name gt-df gt-ac gt-mr-3"> | ||||
| 									<a role="button" class="fold-file muted gt-mr-2" {{if not $isExpandable}}style="visibility: hidden"{{end}}> | ||||
| 									<button class="fold-file ui button button-ghost gt-p-0 gt-mr-3{{if not $isExpandable}} gt-invisible{{end}}"> | ||||
| 										{{if $file.ShouldBeHidden}} | ||||
| 											{{svg "octicon-chevron-right" 18}} | ||||
| 										{{else}} | ||||
| 											{{svg "octicon-chevron-down" 18}} | ||||
| 										{{end}} | ||||
| 									</a> | ||||
| 									</button> | ||||
| 									<div class="gt-bold gt-df gt-ac gt-mono"> | ||||
| 										{{if $file.IsBin}} | ||||
| 											<span class="gt-ml-1 gt-mr-3"> | ||||
| @ -125,8 +125,8 @@ | ||||
| 										<span class="ui basic label">{{$.locale.Tr "repo.diff.protected"}}</span> | ||||
| 									{{end}} | ||||
| 									{{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}} | ||||
| 										<a class="ui basic tiny button unescape-button">{{$.locale.Tr "repo.unescape_control_characters"}}</a> | ||||
| 										<a class="ui basic tiny button escape-button gt-hidden">{{$.locale.Tr "repo.escape_control_characters"}}</a> | ||||
| 										<button class="ui basic tiny button unescape-button">{{$.locale.Tr "repo.unescape_control_characters"}}</button> | ||||
| 										<button class="ui basic tiny button escape-button gt-hidden">{{$.locale.Tr "repo.escape_control_characters"}}</button> | ||||
| 									{{end}} | ||||
| 									{{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} | ||||
| 										{{if $file.IsDeleted}} | ||||
|  | ||||
| @ -16,23 +16,25 @@ | ||||
| 			<tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}"> | ||||
| 				{{if eq .GetType 4}} | ||||
| 					<td class="lines-num lines-num-old"> | ||||
| 						<div class="gt-df"> | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-down"}} | ||||
| 							</a> | ||||
| 							</button> | ||||
| 						{{end}} | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-up"}} | ||||
| 							</a> | ||||
| 							</button> | ||||
| 						{{end}} | ||||
| 						{{if eq $line.GetExpandDirection 2}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 							<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold"}} | ||||
| 							</a> | ||||
| 							</button> | ||||
| 						{{end}} | ||||
| 						</div> | ||||
| 					</td>{{$inlineDiff := $section.GetComputedInlineDiffFor $line $.root.locale}} | ||||
| 					<td class="lines-escape lines-escape-old">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}</td> | ||||
| 					<td class="lines-escape lines-escape-old">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></button>{{end}}</td> | ||||
| 					<td colspan="6" class="lines-code lines-code-old ">{{/* | ||||
| 						*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/* | ||||
| 					*/}}</td> | ||||
| @ -41,7 +43,7 @@ | ||||
| 					{{- $leftDiff := ""}}{{if $line.LeftIdx}}{{$leftDiff = $section.GetComputedInlineDiffFor $line $.root.locale}}{{end}} | ||||
| 					{{- $rightDiff := ""}}{{if $match.RightIdx}}{{$rightDiff = $section.GetComputedInlineDiffFor $match $.root.locale}}{{end}} | ||||
| 					<td class="lines-num lines-num-old del-code" data-line-num="{{$line.LeftIdx}}"><span rel="diff-{{$file.NameHash}}L{{$line.LeftIdx}}"></span></td> | ||||
| 					<td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> | ||||
| 					<td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> | ||||
| 					<td class="lines-type-marker lines-type-marker-old del-code"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> | ||||
| 					<td class="lines-code lines-code-old del-code">{{/* | ||||
| 						*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* | ||||
| @ -56,7 +58,7 @@ | ||||
| 						*/}}{{end}}{{/* | ||||
| 					*/}}</td> | ||||
| 					<td class="lines-num lines-num-new add-code" data-line-num="{{if $match.RightIdx}}{{$match.RightIdx}}{{end}}"><span rel="{{if $match.RightIdx}}diff-{{$file.NameHash}}R{{$match.RightIdx}}{{end}}"></span></td> | ||||
| 					<td class="lines-escape add-code lines-escape-new">{{if $match.RightIdx}}{{if $rightDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $rightDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> | ||||
| 					<td class="lines-escape add-code lines-escape-new">{{if $match.RightIdx}}{{if $rightDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $rightDiff "locale" $.root.locale}}"></button>{{end}}{{end}}</td> | ||||
| 					<td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="gt-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td> | ||||
| 					<td class="lines-code lines-code-new add-code">{{/* | ||||
| 						*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* | ||||
| @ -73,7 +75,7 @@ | ||||
| 				{{else}} | ||||
| 					{{$inlineDiff := $section.GetComputedInlineDiffFor $line $.root.locale}} | ||||
| 					<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> | ||||
| 					<td class="lines-escape lines-escape-old">{{if $line.LeftIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> | ||||
| 					<td class="lines-escape lines-escape-old">{{if $line.LeftIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></button>{{end}}{{end}}</td> | ||||
| 					<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> | ||||
| 					<td class="lines-code lines-code-old">{{/* | ||||
| 						*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/* | ||||
| @ -88,7 +90,7 @@ | ||||
| 						*/}}{{end}}{{/* | ||||
| 					*/}}</td> | ||||
| 					<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td> | ||||
| 					<td class="lines-escape lines-escape-new">{{if $line.RightIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> | ||||
| 					<td class="lines-escape lines-escape-new">{{if $line.RightIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></button>{{end}}{{end}}</td> | ||||
| 					<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> | ||||
| 					<td class="lines-code lines-code-new">{{/* | ||||
| 						*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/* | ||||
|  | ||||
| @ -12,21 +12,23 @@ | ||||
| 			{{if eq .GetType 4}} | ||||
| 				{{if $.root.AfterCommitID}} | ||||
| 					<td colspan="2" class="lines-num"> | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-down"}} | ||||
| 							</a> | ||||
| 						{{end}} | ||||
| 						{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold-up"}} | ||||
| 							</a> | ||||
| 						{{end}} | ||||
| 						{{if eq $line.GetExpandDirection 2}} | ||||
| 							<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 								{{svg "octicon-fold"}} | ||||
| 							</a> | ||||
| 						{{end}} | ||||
| 						<div class="gt-df"> | ||||
| 							{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} | ||||
| 								<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold-down"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
| 							{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} | ||||
| 								<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold-up"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
| 							{{if eq $line.GetExpandDirection 2}} | ||||
| 								<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> | ||||
| 									{{svg "octicon-fold"}} | ||||
| 								</button> | ||||
| 							{{end}} | ||||
| 						</div> | ||||
| 					</td> | ||||
| 				{{else}} | ||||
| 					{{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}} | ||||
| @ -37,7 +39,11 @@ | ||||
| 				<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td> | ||||
| 			{{end}} | ||||
| 			{{$inlineDiff := $section.GetComputedInlineDiffFor $line $.root.locale -}} | ||||
| 			<td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></a>{{end}}</td> | ||||
| 			<td class="lines-escape"> | ||||
| 				{{- if $inlineDiff.EscapeStatus.Escaped -}} | ||||
| 					<button class="toggle-escape-button button button-ghost" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff "locale" $.root.locale}}"></button> | ||||
| 				{{- end -}} | ||||
| 			</td> | ||||
| 			<td class="lines-type-marker"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> | ||||
| 			{{if eq .GetType 4}} | ||||
| 				<td class="chroma lines-code blob-hunk">{{/* | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| <div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown"> | ||||
| 	<a class="text gt-df gt-ac muted"> | ||||
| 	<span class="text gt-df gt-ac muted"> | ||||
| 		<strong>{{.locale.Tr "repo.issues.new.labels"}}</strong> | ||||
| 		{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} | ||||
| 			{{svg "octicon-gear" 16 "gt-ml-2"}} | ||||
| 		{{end}} | ||||
| 	</a> | ||||
| 	</span> | ||||
| 	<div class="filter menu" {{if .Issue}}data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/labels"{{else}}data-id="#label_ids"{{end}}> | ||||
| 		<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_labels_title"}}</div> | ||||
| 		{{if or .Labels .OrgLabels}} | ||||
|  | ||||
| @ -45,12 +45,12 @@ | ||||
| 			{{if .Issue.IsPull}} | ||||
| 				{{$headHref := .HeadTarget|Escape}} | ||||
| 				{{if .HeadBranchLink}} | ||||
| 					{{$headHref = printf "<a href=\"%s\">%s</a>" (.HeadBranchLink | Escape) $headHref}} | ||||
| 					{{$headHref = printf `<a href="%s">%s</a>` (.HeadBranchLink | Escape) $headHref}} | ||||
| 				{{end}} | ||||
| 				{{$headHref = printf "%s <a data-tooltip-content=\"%s\" data-clipboard-text=\"%s\">%s</a>" $headHref (.locale.Tr "copy_branch") (.HeadTarget | Escape) (svg "octicon-copy" 14)}} | ||||
| 				{{$headHref = printf `%s <button class="button button-ghost" data-tooltip-content="%s" data-clipboard-text="%s">%s</button>` $headHref (.locale.Tr "copy_branch") (.HeadTarget | Escape) (svg "octicon-copy" 14)}} | ||||
| 				{{$baseHref := .BaseTarget|Escape}} | ||||
| 				{{if .BaseBranchLink}} | ||||
| 					{{$baseHref = printf "<a href=\"%s\">%s</a>" (.BaseBranchLink | Escape) $baseHref}} | ||||
| 					{{$baseHref = printf `<a href="%s">%s</a>` (.BaseBranchLink | Escape) $baseHref}} | ||||
| 				{{end}} | ||||
| 				{{if .Issue.PullRequest.HasMerged}} | ||||
| 					{{$mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.locale}} | ||||
|  | ||||
| @ -36,8 +36,8 @@ | ||||
| 					{{end}} | ||||
| 					<a class="ui mini basic button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{PathEscapeSegments .TreePath}}">{{.locale.Tr "repo.file_history"}}</a> | ||||
| 					{{if .EscapeStatus.Escaped}} | ||||
| 						<a class="ui mini basic button unescape-button gt-hidden">{{.locale.Tr "repo.unescape_control_characters"}}</a> | ||||
| 						<a class="ui mini basic button escape-button">{{.locale.Tr "repo.escape_control_characters"}}</a> | ||||
| 						<button class="ui mini basic button unescape-button gt-hidden">{{.locale.Tr "repo.unescape_control_characters"}}</button> | ||||
| 						<button class="ui mini basic button escape-button">{{.locale.Tr "repo.escape_control_characters"}}</button> | ||||
| 					{{end}} | ||||
| 				</div> | ||||
| 				<a download href="{{$.RawFileLink}}"><span class="btn-octicon" data-tooltip-content="{{.locale.Tr "repo.download_file"}}">{{svg "octicon-download"}}</span></a> | ||||
| @ -58,8 +58,8 @@ | ||||
| 					{{end}} | ||||
| 				{{end}} | ||||
| 			{{else if .EscapeStatus.Escaped}} | ||||
| 				<a class="ui mini basic button unescape-button gt-mr-2 gt-hidden">{{.locale.Tr "repo.unescape_control_characters"}}</a> | ||||
| 				<a class="ui mini basic button escape-button gt-mr-2">{{.locale.Tr "repo.escape_control_characters"}}</a> | ||||
| 				<button class="ui mini basic button unescape-button gt-mr-2 gt-hidden">{{.locale.Tr "repo.unescape_control_characters"}}</button> | ||||
| 				<button class="ui mini basic button escape-button gt-mr-2">{{.locale.Tr "repo.escape_control_characters"}}</button> | ||||
| 			{{end}} | ||||
| 		</div> | ||||
| 	</h4> | ||||
| @ -107,7 +107,7 @@ | ||||
| 						<tr> | ||||
| 							<td id="L{{$line}}" class="lines-num"><span id="L{{$line}}" data-line-number="{{$line}}"></span></td> | ||||
| 							{{if $.EscapeStatus.Escaped}} | ||||
| 								<td class="lines-escape">{{if (index $.LineEscapeStatus $idx).Escaped}}<a href="" class="toggle-escape-button" title="{{if (index $.LineEscapeStatus $idx).HasInvisible}}{{$.locale.Tr "repo.invisible_runes_line"}} {{end}}{{if (index $.LineEscapeStatus $idx).HasAmbiguous}}{{$.locale.Tr "repo.ambiguous_runes_line"}}{{end}}"></a>{{end}}</td> | ||||
| 								<td class="lines-escape">{{if (index $.LineEscapeStatus $idx).Escaped}}<button class="toggle-escape-button button button-ghost" title="{{if (index $.LineEscapeStatus $idx).HasInvisible}}{{$.locale.Tr "repo.invisible_runes_line"}} {{end}}{{if (index $.LineEscapeStatus $idx).HasAmbiguous}}{{$.locale.Tr "repo.ambiguous_runes_line"}}{{end}}"></button>{{end}}</td> | ||||
| 							{{end}} | ||||
| 							<td rel="L{{$line}}" class="lines-code chroma"><code class="code-inner">{{$code | Safe}}</code></td> | ||||
| 						</tr> | ||||
|  | ||||
| @ -125,7 +125,7 @@ | ||||
| 
 | ||||
| 				<div class="field"> | ||||
| 					<button class="ui green button">{{$.locale.Tr "settings.update_avatar"}}</button> | ||||
| 					<a class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.locale.Tr "settings.delete_current_avatar"}}</a> | ||||
| 					<button class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.locale.Tr "settings.delete_current_avatar"}}</button> | ||||
| 				</div> | ||||
| 			</form> | ||||
| 		</div> | ||||
|  | ||||
| @ -2943,7 +2943,7 @@ tbody.commit-list { | ||||
|   padding-top: 0 !important; | ||||
| } | ||||
| 
 | ||||
| td.blob-excerpt { | ||||
| .blob-excerpt { | ||||
|   background-color: var(--color-secondary-alpha-30); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -21,7 +21,7 @@ | ||||
|   transform: scale(1.1); | ||||
| } | ||||
| 
 | ||||
| .lines-escape a.toggle-escape-button::before { | ||||
| .lines-escape .toggle-escape-button::before { | ||||
|   visibility: visible; | ||||
|   content: "⚠️"; | ||||
|   font-family: var(--fonts-emoji); | ||||
| @ -198,7 +198,8 @@ | ||||
|   color: var(--color-text); | ||||
| } | ||||
| 
 | ||||
| a.blob-excerpt { | ||||
| .code-expander-button { | ||||
|   border: none; | ||||
|   color: var(--color-text-light); | ||||
|   height: 28px; | ||||
|   display: flex; | ||||
| @ -206,9 +207,10 @@ a.blob-excerpt { | ||||
|   align-items: center; | ||||
|   width: 100%; | ||||
|   background: var(--color-expand-button); | ||||
|   flex: 1; | ||||
| } | ||||
| 
 | ||||
| a.blob-excerpt:hover { | ||||
| .code-expander-button:hover { | ||||
|   background: var(--color-primary); | ||||
|   color: var(--color-primary-contrast); | ||||
| } | ||||
|  | ||||
| @ -56,9 +56,8 @@ export function initGlobalEnterQuickSubmit() { | ||||
| } | ||||
| 
 | ||||
| export function initGlobalButtonClickOnEnter() { | ||||
|   $(document).on('keypress', '.ui.button', (e) => { | ||||
|     if (e.keyCode === 13 || e.keyCode === 32) { // enter key or space bar
 | ||||
|       if (e.target.nodeName === 'BUTTON') return; // button already handles space&enter correctly
 | ||||
|   $(document).on('keypress', 'div.ui.button,span.ui.button', (e) => { | ||||
|     if (e.code === ' ' || e.code === 'Enter') { | ||||
|       $(e.target).trigger('click'); | ||||
|       e.preventDefault(); | ||||
|     } | ||||
|  | ||||
| @ -38,7 +38,7 @@ export function initViewedCheckboxListenerFor() { | ||||
|     // The checkbox consists of a div containing the real checkbox with its label and the CSRF token,
 | ||||
|     // hence the actual checkbox first has to be found
 | ||||
|     const checkbox = form.querySelector('input[type=checkbox]'); | ||||
|     checkbox.addEventListener('change', function() { | ||||
|     checkbox.addEventListener('input', function() { | ||||
|       // Mark the file as viewed visually - will especially change the background
 | ||||
|       if (this.checked) { | ||||
|         form.classList.add(viewedStyleClass); | ||||
|  | ||||
| @ -181,7 +181,7 @@ export function initRepoCodeView() { | ||||
|   $(document).on('click', '.fold-file', ({currentTarget}) => { | ||||
|     invertFileFolding(currentTarget.closest('.file-content'), currentTarget); | ||||
|   }); | ||||
|   $(document).on('click', '.blob-excerpt', async ({currentTarget}) => { | ||||
|   $(document).on('click', '.code-expander-button', async ({currentTarget}) => { | ||||
|     const url = currentTarget.getAttribute('data-url'); | ||||
|     const query = currentTarget.getAttribute('data-query'); | ||||
|     const anchor = currentTarget.getAttribute('data-anchor'); | ||||
|  | ||||
| @ -62,9 +62,9 @@ function initRepoDiffConversationForm() { | ||||
| 
 | ||||
|     $form.closest('.conversation-holder').replaceWith($newConversationHolder); | ||||
|     if ($form.closest('tr').data('line-type') === 'same') { | ||||
|       $(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).addClass('invisible'); | ||||
|       $(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).addClass('invisible'); | ||||
|     } else { | ||||
|       $(`[data-path="${path}"] a.add-code-comment[data-side="${side}"][data-idx="${idx}"]`).addClass('invisible'); | ||||
|       $(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).addClass('invisible'); | ||||
|     } | ||||
|     $newConversationHolder.find('.dropdown').dropdown(); | ||||
|     initCompReactionSelector($newConversationHolder); | ||||
|  | ||||
| @ -177,9 +177,9 @@ export function initRepoIssueCommentDelete() { | ||||
|           const idx = $conversationHolder.data('idx'); | ||||
|           const lineType = $conversationHolder.closest('tr').data('line-type'); | ||||
|           if (lineType === 'same') { | ||||
|             $(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).removeClass('invisible'); | ||||
|             $(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).removeClass('invisible'); | ||||
|           } else { | ||||
|             $(`[data-path="${path}"] a.add-code-comment[data-side="${side}"][data-idx="${idx}"]`).removeClass('invisible'); | ||||
|             $(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).removeClass('invisible'); | ||||
|           } | ||||
|           $conversationHolder.remove(); | ||||
|         } | ||||
| @ -488,7 +488,7 @@ export function initRepoPullRequestReview() { | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   $(document).on('click', 'a.add-code-comment', async function (e) { | ||||
|   $(document).on('click', '.add-code-comment', async function (e) { | ||||
|     if ($(e.target).hasClass('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745
 | ||||
|     e.preventDefault(); | ||||
| 
 | ||||
|  | ||||
| @ -2,30 +2,30 @@ import $ from 'jquery'; | ||||
| import {hideElem, showElem} from '../utils/dom.js'; | ||||
| 
 | ||||
| export function initUnicodeEscapeButton() { | ||||
|   $(document).on('click', 'a.escape-button', (e) => { | ||||
|   $(document).on('click', '.escape-button', (e) => { | ||||
|     e.preventDefault(); | ||||
|     $(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').addClass('unicode-escaped'); | ||||
|     hideElem($(e.target)); | ||||
|     showElem($(e.target).siblings('a.unescape-button')); | ||||
|     showElem($(e.target).siblings('.unescape-button')); | ||||
|   }); | ||||
|   $(document).on('click', 'a.unescape-button', (e) => { | ||||
|   $(document).on('click', '.unescape-button', (e) => { | ||||
|     e.preventDefault(); | ||||
|     $(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').removeClass('unicode-escaped'); | ||||
|     hideElem($(e.target)); | ||||
|     showElem($(e.target).siblings('a.escape-button')); | ||||
|     showElem($(e.target).siblings('.escape-button')); | ||||
|   }); | ||||
|   $(document).on('click', 'a.toggle-escape-button', (e) => { | ||||
|   $(document).on('click', '.toggle-escape-button', (e) => { | ||||
|     e.preventDefault(); | ||||
|     const fileContent = $(e.target).parents('.file-content, .non-diff-file-content'); | ||||
|     const fileView = fileContent.find('.file-code, .file-view'); | ||||
|     if (fileView.hasClass('unicode-escaped')) { | ||||
|       fileView.removeClass('unicode-escaped'); | ||||
|       hideElem(fileContent.find('a.unescape-button')); | ||||
|       showElem(fileContent.find('a.escape-button')); | ||||
|       hideElem(fileContent.find('.unescape-button')); | ||||
|       showElem(fileContent.find('.escape-button')); | ||||
|     } else { | ||||
|       fileView.addClass('unicode-escaped'); | ||||
|       showElem(fileContent.find('a.unescape-button')); | ||||
|       hideElem(fileContent.find('a.escape-button')); | ||||
|       showElem(fileContent.find('.unescape-button')); | ||||
|       hideElem(fileContent.find('.escape-button')); | ||||
|     } | ||||
|   }); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 delvh
						delvh