diff options
| author | Eltrac <hi@guhub.cn> | 2025-04-01 10:52:52 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-04-01 10:52:52 +0800 |
| commit | dce16efa1c07ce72da3f02e3ffb25a9205f50a07 (patch) | |
| tree | 9d9abf8f23859db1784473320f014432cdddc21c /layouts | |
| parent | dd2386f954cc214d7484fa1aa8063007c53bcecd (diff) | |
feat: click search instruction to show search input
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/components/global-search.html | 27 | ||||
| -rw-r--r-- | layouts/partials/components/postnav.html | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/layouts/partials/components/global-search.html b/layouts/partials/components/global-search.html index c12a6d79..0b929b0a 100644 --- a/layouts/partials/components/global-search.html +++ b/layouts/partials/components/global-search.html @@ -76,19 +76,19 @@ <script> (() => { - window.addEventListener("keydown", (event) => { - const search = document.getElementById("global-search"); - const overlay = document.getElementById("global-search-overlay"); + const search = document.getElementById("global-search"); + const overlay = document.getElementById("global-search-overlay"); - const turnOn = () => { - search.classList.add("shown"); - overlay.classList.add("shown"); - }; - const turnOff = () => { - search.classList.remove("shown"); - overlay.classList.remove("shown"); - }; + const turnOn = () => { + search.classList.add("shown"); + overlay.classList.add("shown"); + }; + const turnOff = () => { + search.classList.remove("shown"); + overlay.classList.remove("shown"); + }; + window.addEventListener("keydown", (event) => { if (event.key === 'k' && (event.metaKey || event.ctrlKey)) { // Open the popup window if (search.classList.contains("shown")) { @@ -105,5 +105,10 @@ turnOff(); } }); + + const searchInstruction = document.getElementById("search-instruction"); + window.addEventListener("click", (event) => { + turnOn(); + }); })(); </script> diff --git a/layouts/partials/components/postnav.html b/layouts/partials/components/postnav.html index d7d21cc6..207ea99c 100644 --- a/layouts/partials/components/postnav.html +++ b/layouts/partials/components/postnav.html @@ -6,7 +6,7 @@ <li class="{{ if eq "/categories/" $.Page.RelPermalink }}active{{ end }}"> <a href="/categories">分类</a> </li> - <li class="search-instruction"> + <li id="search-instruction"> <span>{{ T "searchInstruction" }}</span> </li> <li class="list-decoration invert-if-dark"> |
