Skip to content

Commit 8ffefc9

Browse files
committed
(maybe) a better way to set autofocus
1 parent 6d16a25 commit 8ffefc9

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

templates/explore/repo_search.tmpl

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<div class="ui secondary filter menu gt-ac gt-mx-0">
22
<form class="ui form ignore-dirty gt-f1">
33
<input type="hidden" name="sort" value="{{$.SortType}}">
4-
<input type="hidden" name="language" value="{{$.ctxData.Language}}">
4+
<input type="hidden" name="language" value="{{$.Language}}">
55
<div class="ui fluid action input">
6-
{{template "shared/searchinput" dict "Value" .ctxData.Keyword "AutoFocus" .AutoFocus}}
7-
{{if .ctxData.PageIsExploreRepositories}}
8-
<input type="hidden" name="only_show_relevant" value="{{.ctxData.OnlyShowRelevant}}">
9-
{{else if .ctxData.TabName}}
10-
<input type="hidden" name="tab" value="{{.ctxData.TabName}}">
6+
{{if .ProfileReadme}}
7+
{{template "shared/searchinput" dict "Value" .Keyword "AutoFocus" false}}
8+
{{else}}
9+
{{template "shared/searchinput" dict "Value" .Keyword "AutoFocus" true}}
10+
{{end}}
11+
{{if .PageIsExploreRepositories}}
12+
<input type="hidden" name="only_show_relevant" value="{{.OnlyShowRelevant}}">
13+
{{else if .TabName}}
14+
<input type="hidden" name="tab" value="{{.TabName}}">
1115
{{end}}
1216
<button class="ui primary button">{{ctx.Locale.Tr "explore.search"}}</button>
1317
</div>
@@ -19,24 +23,24 @@
1923
</span>
2024
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
2125
<div class="menu">
22-
<a class="{{if eq .ctxData.SortType "newest"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=newest&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
23-
<a class="{{if eq .ctxData.SortType "oldest"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=oldest&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
24-
<a class="{{if eq .ctxData.SortType "alphabetically"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=alphabetically&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
25-
<a class="{{if eq .ctxData.SortType "reversealphabetically"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=reversealphabetically&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
26-
<a class="{{if eq .ctxData.SortType "recentupdate"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=recentupdate&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
27-
<a class="{{if eq .ctxData.SortType "leastupdate"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=leastupdate&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
28-
{{if not .ctxData.DisableStars}}
29-
<a class="{{if eq .ctxData.SortType "moststars"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=moststars&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.moststars"}}</a>
30-
<a class="{{if eq .ctxData.SortType "feweststars"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=feweststars&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.feweststars"}}</a>
26+
<a class="{{if eq .SortType "newest"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=newest&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
27+
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=oldest&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
28+
<a class="{{if eq .SortType "alphabetically"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=alphabetically&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a>
29+
<a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=reversealphabetically&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
30+
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=recentupdate&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
31+
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=leastupdate&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
32+
{{if not .DisableStars}}
33+
<a class="{{if eq .SortType "moststars"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=moststars&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.moststars"}}</a>
34+
<a class="{{if eq .SortType "feweststars"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=feweststars&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.feweststars"}}</a>
3135
{{end}}
32-
<a class="{{if eq .ctxData.SortType "mostforks"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=mostforks&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostforks"}}</a>
33-
<a class="{{if eq .ctxData.SortType "fewestforks"}}active {{end}}item" href="{{$.ctxData.Link}}?tab={{$.ctxData.TabName}}&sort=fewestforks&q={{$.ctxData.Keyword}}&language={{$.ctxData.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.fewestforks"}}</a>
36+
<a class="{{if eq .SortType "mostforks"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=mostforks&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostforks"}}</a>
37+
<a class="{{if eq .SortType "fewestforks"}}active {{end}}item" href="{{$.Link}}?tab={{$.TabName}}&sort=fewestforks&q={{$.Keyword}}&language={{$.Language}}">{{ctx.Locale.Tr "repo.issues.filter_sort.fewestforks"}}</a>
3438
</div>
3539
</div>
3640
</div>
37-
{{if and .ctxData.PageIsExploreRepositories .ctxData.OnlyShowRelevant}}
41+
{{if and .PageIsExploreRepositories .OnlyShowRelevant}}
3842
<div class="ui message explore-relevancy-note">
39-
<span data-tooltip-content="{{ctx.Locale.Tr "explore.relevant_repositories_tooltip"}}">{{ctx.Locale.Tr "explore.relevant_repositories" ((printf "?only_show_relevant=0&sort=%s&q=%s&language=%s" $.ctxData.SortType (QueryEscape $.ctxData.Keyword) (QueryEscape $.ctxData.Language))|Escape) | Safe}}</span>
43+
<span data-tooltip-content="{{ctx.Locale.Tr "explore.relevant_repositories_tooltip"}}">{{ctx.Locale.Tr "explore.relevant_repositories" ((printf "?only_show_relevant=0&sort=%s&q=%s&language=%s" $.SortType (QueryEscape $.Keyword) (QueryEscape $.Language))|Escape) | Safe}}</span>
4044
</div>
4145
{{end}}
4246
<div class="divider"></div>

templates/explore/repos.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div role="main" aria-label="{{.Title}}" class="page-content explore repositories">
33
{{template "explore/navbar" .}}
44
<div class="ui container">
5-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
5+
{{template "explore/repo_search" .}}
66
{{template "explore/repo_list" .}}
77
{{template "base/paginate" .}}
88
</div>

templates/org/home.tmpl

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@
4040
<div class="ui {{if .ShowMemberAndTeamTab}}eleven wide{{end}} column">
4141
{{if .ProfileReadme}}
4242
<div id="readme_profile" class="markup">{{.ProfileReadme | Str2html}}</div>
43-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" false}}
44-
{{else}}
45-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
4643
{{end}}
47-
44+
{{template "explore/repo_search" .}}
4845
{{template "explore/repo_list" .}}
4946
{{template "base/paginate" .}}
5047
</div>

templates/user/notification/notification_subscriptions.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
7070
{{end}}
7171
{{else}}
72-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
72+
{{template "explore/repo_search" .}}
7373
{{template "explore/repo_list" .}}
7474
{{template "base/paginate" .}}
7575
{{end}}

templates/user/profile.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{template "user/dashboard/feeds" .}}
2121
{{else if eq .TabName "stars"}}
2222
<div class="stars">
23-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
23+
{{template "explore/repo_search" .}}
2424
{{template "explore/repo_list" .}}
2525
{{template "base/paginate" .}}
2626
</div>
@@ -31,7 +31,7 @@
3131
{{else if eq .TabName "overview"}}
3232
<div id="readme_profile" class="markup">{{.ProfileReadme | Str2html}}</div>
3333
{{else}}
34-
{{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
34+
{{template "explore/repo_search" .}}
3535
{{template "explore/repo_list" .}}
3636
{{template "base/paginate" .}}
3737
{{end}}

0 commit comments

Comments
 (0)