diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-02-19 12:06:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-19 12:06:14 +0800 |
commit | d32af84a1002ceb235c86e4ac569c866ab7816d4 (patch) | |
tree | 3832638122aac31fdc2215f85873629fd8ef2fd2 /templates/repo/diff | |
parent | 6221a6fd5450692ae27e5602b41fc9ebd9150736 (diff) | |
download | gitea-d32af84a1002ceb235c86e4ac569c866ab7816d4.tar.gz gitea-d32af84a1002ceb235c86e4ac569c866ab7816d4.zip |
Refactor hiding-methods, remove jQuery show/hide, remove `.hide` class, remove inline style=display:none (#22950)
Close #22847
This PR:
* introduce Gitea's own `showElem` and related functions
* remove jQuery show/hide
* remove .hide class
* remove inline style=display:none
From now on:
do not use:
* "[hidden]" attribute: it's too weak, can not be applied to an element
with "display: flex"
* ".hidden" class: it has been polluted by Fomantic UI in many cases
* inline style="display: none": it's difficult to tweak
* jQuery's show/hide/toggle: it can not show/hide elements with
"display: xxx !important"
only use:
* this ".gt-hidden" class
* showElem/hideElem/toggleElem functions in "utils/dom.js"
cc: @silverwind , this is the all-in-one PR
Diffstat (limited to 'templates/repo/diff')
-rw-r--r-- | templates/repo/diff/box.tmpl | 8 | ||||
-rw-r--r-- | templates/repo/diff/comment_form.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/diff/comments.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/diff/compare.tmpl | 12 | ||||
-rw-r--r-- | templates/repo/diff/conversation.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/diff/image_diff.tmpl | 2 |
6 files changed, 16 insertions, 16 deletions
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 319fdb58f8..62cc069555 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -67,7 +67,7 @@ </script> <div id="diff-file-list"></div> <div id="diff-container"> - <div id="diff-file-tree" class="hide"></div> + <div id="diff-file-tree" class="gt-hidden"></div> <div id="diff-file-boxes" class="sixteen wide column"> {{range $i, $file := .Diff.Files}} {{/*notice: the index of Diff.Files should not be used for element ID, because the index will be restarted from 0 when doing load-more for PRs with a lot of files*/}} @@ -116,7 +116,7 @@ {{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" style="display: none;">{{$.locale.Tr "repo.escape_control_characters"}}</a> + <a class="ui basic tiny button escape-button gt-hidden">{{$.locale.Tr "repo.escape_control_characters"}}</a> {{end}} {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} {{if $file.IsDeleted}} @@ -136,7 +136,7 @@ </div> </h4> <div class="diff-file-body ui attached unstackable table segment" {{if $file.IsViewed}}data-folded="true"{{end}}> - <div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} hide{{end}}"> + <div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} gt-hidden{{end}}"> {{if or $file.IsIncomplete $file.IsBin}} <div class="diff-file-body binary" style="padding: 5px 10px;"> {{if $file.IsIncomplete}} @@ -187,7 +187,7 @@ </div> {{if not $.Repository.IsArchived}} - <div class="hide" id="edit-content-form"> + <div class="gt-hidden" id="edit-content-form"> <div class="ui comment form"> <div class="ui top attached tabular menu"> <a class="active write item">{{$.locale.Tr "write"}}</a> diff --git a/templates/repo/diff/comment_form.tmpl b/templates/repo/diff/comment_form.tmpl index 2ce0612e63..407f84e5c9 100644 --- a/templates/repo/diff/comment_form.tmpl +++ b/templates/repo/diff/comment_form.tmpl @@ -1,5 +1,5 @@ {{if and $.root.SignedUserID (not $.Repository.IsArchived)}} - <form class="ui form {{if $.hidden}}hide comment-form comment-form-reply{{end}}" action="{{$.root.Issue.Link}}/files/reviews/comments" method="post"> + <form class="ui form {{if $.hidden}}gt-hidden comment-form comment-form-reply{{end}}" action="{{$.root.Issue.Link}}/files/reviews/comments" method="post"> {{$.root.CsrfTokenHtml}} <input type="hidden" name="origin" value="{{if $.root.PageIsPullFiles}}diff{{else}}timeline{{end}}"> <input type="hidden" name="latest_commit_id" value="{{$.root.AfterCommitID}}"/> diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index ebed33bf21..a6f191728c 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -54,8 +54,8 @@ <span class="no-content">{{$.root.locale.Tr "repo.issues.no_content"}}</span> {{end}} </div> - <div id="issuecomment-{{.ID}}-raw" class="raw-content hide">{{.Content}}</div> - <div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.root.RepoLink}}/comments/{{.ID}}" data-context="{{$.root.RepoLink}}"></div> + <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> + <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.root.RepoLink}}/comments/{{.ID}}" data-context="{{$.root.RepoLink}}"></div> </div> {{$reactions := .Reactions.GroupByType}} {{if $reactions}} diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 16749bacbf..c7538a7969 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -88,7 +88,7 @@ {{end}} {{end}} </div> - <div class="scrolling menu reference-list-menu base-tag-list" style="display: none"> + <div class="scrolling menu reference-list-menu base-tag-list gt-hidden"> {{range .Tags}} <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments $.HeadBranch}}">{{$BaseCompareName}}:{{.}}</div> {{end}} @@ -157,7 +157,7 @@ {{end}} {{end}} </div> - <div class="scrolling menu reference-list-menu head-tag-list" style="display: none"> + <div class="scrolling menu reference-list-menu head-tag-list gt-hidden"> {{range .HeadTags}} <div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments .}}">{{$HeadCompareName}}:{{.}}</div> {{end}} @@ -184,10 +184,10 @@ {{if .IsNothingToCompare}} {{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived)}} <div class="ui segment">{{.locale.Tr "repo.pulls.nothing_to_compare_and_allow_empty_pr"}}</div> - <div class="ui info message show-form-container" {{if .Flash}}style="display: none"{{end}}> + <div class="ui info message show-form-container {{if .Flash}}gt-hidden{{end}}"> <button class="ui button green show-form">{{.locale.Tr "repo.pulls.new"}}</button> </div> - <div class="pullrequest-form" {{if not .Flash}}style="display: none"{{end}}> + <div class="pullrequest-form {{if not .Flash}}gt-hidden{{end}}"> {{template "repo/issue/new_form" .}} </div> {{else}} @@ -214,7 +214,7 @@ </div> {{else}} {{if and $.IsSigned (not .Repository.IsArchived)}} - <div class="ui info message show-form-container" {{if .Flash}}style="display: none"{{end}}> + <div class="ui info message show-form-container {{if .Flash}}gt-hidden{{end}}"> <button class="ui button green show-form">{{.locale.Tr "repo.pulls.new"}}</button> </div> {{else if .Repository.IsArchived}} @@ -223,7 +223,7 @@ </div> {{end}} {{if $.IsSigned}} - <div class="pullrequest-form" {{if not .Flash}}style="display: none"{{end}}> + <div class="pullrequest-form {{if not .Flash}}gt-hidden{{end}}"> {{template "repo/issue/new_form" .}} </div> {{end}} diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl index b6d577ee5a..999197f94a 100644 --- a/templates/repo/diff/conversation.tmpl +++ b/templates/repo/diff/conversation.tmpl @@ -13,14 +13,14 @@ {{svg "octicon-unfold" 16 "gt-mr-3"}} {{$.locale.Tr "repo.issues.review.show_resolved"}} </button> - <button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated gt-df gt-ac"> + <button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny right labeled button hide-outdated gt-df gt-ac gt-hidden"> {{svg "octicon-fold" 16 "gt-mr-3"}} {{$.locale.Tr "repo.issues.review.hide_resolved"}} </button> </div> </div> {{end}} - <div id="code-comments-{{(index .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}"> + <div id="code-comments-{{(index .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}gt-hidden{{end}}"> <div class="comment-list"> <ui class="ui comments"> {{template "repo/diff/comments" dict "root" $ "comments" .comments}} diff --git a/templates/repo/diff/image_diff.tmpl b/templates/repo/diff/image_diff.tmpl index d068a12d13..2d4a731758 100644 --- a/templates/repo/diff/image_diff.tmpl +++ b/templates/repo/diff/image_diff.tmpl @@ -11,7 +11,7 @@ {{end}} </div> </div> - <div class="hide"> + <div class="gt-hidden"> <div class="ui bottom attached tab image-diff-container active" data-tab="diff-side-by-side-{{.file.Index}}"> <div class="diff-side-by-side"> {{if .blobBase}} |