diff options
| author | Eltrac <hi@guhub.cn> | 2025-04-02 18:28:02 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-04-02 18:28:02 +0800 |
| commit | 2fce6568356f731fed20198efc886f936b4a38f8 (patch) | |
| tree | 1958c2163114c563b6e71035a180a7eb42f7e56f /layouts/partials | |
| parent | 08138de243e82dc3112952874a4ebadc79e58bcc (diff) | |
| parent | c896f61fb6cc69b2cc65be3a5f5e28ddd2b90945 (diff) | |
Merge branch 'master' of https://github.com/BigCoke233/geek-death-project
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/components/global-search.html | 12 | ||||
| -rw-r--r-- | layouts/partials/scripts.html | 9 |
2 files changed, 15 insertions, 6 deletions
diff --git a/layouts/partials/components/global-search.html b/layouts/partials/components/global-search.html index c1051ee4..5b158abe 100644 --- a/layouts/partials/components/global-search.html +++ b/layouts/partials/components/global-search.html @@ -106,9 +106,15 @@ } }); + // trigger by clicking instruction text + // to allow mobile users to search const searchInstruction = document.getElementById("search-instruction"); - searchInstruction.addEventListener("click", (event) => { - turnOn(); - }); + if (searchInstruction) { + searchInstruction.addEventListener("click", turnOn); + } + + // double-click to turn off search + // in case esc and ctrl/cmd+k cannot be used + search.addEventListener("dblclick", turnOff); })(); </script> diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index b22c8989..dbf6aee0 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -8,9 +8,12 @@ <script>{{ $lazyload.Content | safeJS }}</script> {{- end }} -{{- $fancybox := resources.Get "js/fancybox.js" | minify }} -{{- if $fancybox }} - <script>{{ $fancybox.Content | safeJS }}</script> +{{- if or (in .Section "posts") (in .Section "cards") (in .Section "library") (eq .Type "single") }} + <script src="/js/fancybox.umd.js"></script> + {{- $fancybox := resources.Get "js/fancybox.js" | minify }} + {{- if $fancybox }} + <script>{{ $fancybox.Content | safeJS }}</script> + {{- end }} {{- end }} <script> |
