refactor(shortcut): Use declarative data attributes for keyboard shortcuts

Instead of having JavaScript code guess which elements exist on a page,
elements now declare their keyboard shortcuts via data-global-keyboard-shortcut
attribute. This makes it easier to add new shortcuts and follows Gitea's
existing patterns for data-global-init and data-global-click.
This commit is contained in:
micahkepe authored and Micah Kepe committed 2026-02-14 22:43:52 -08:00
1 parent 7226ecde9a
commit 663612cdab
5 files changed
+91 -138

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
<div class="repo-home-sidebar-top">
<form class="ignore-dirty tw-flex tw-flex-1" action="{{.RepoLink}}/search" method="get">
<div class="ui small action input tw-flex-1 repo-code-search-input-wrapper">
<input name="q" size="10" placeholder="{{ctx.Locale.Tr "search.code_kind"}}" class="code-search-input">
<input name="q" size="10" placeholder="{{ctx.Locale.Tr "search.code_kind"}}" class="code-search-input" data-global-keyboard-shortcut="s" data-global-init="initRepoCodeSearchShortcut">
<kbd class="repo-search-shortcut-hint">S</kbd>
{{template "shared/search/button"}}
</div>