mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved search user experience
This commit is contained in:
parent
357c6f4122
commit
bda96f88df
File diff suppressed because one or more lines are too long
@ -150,7 +150,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ base_url }}/assets/javascripts/application-8ec1c9e2d8.js"></script>
|
<script src="{{ base_url }}/assets/javascripts/application-07b0fbb49b.js"></script>
|
||||||
{% set languages = lang.t("search.languages").split(",") %}
|
{% set languages = lang.t("search.languages").split(",") %}
|
||||||
{% if languages | length and languages[0] != "" %}
|
{% if languages | length and languages[0] != "" %}
|
||||||
{% set path = base_url + "/assets/javascripts/lunr" %}
|
{% set path = base_url + "/assets/javascripts/lunr" %}
|
||||||
|
@ -302,9 +302,8 @@ function initialize(config) { // eslint-disable-line func-style
|
|||||||
|
|
||||||
/* Retrieve all results */
|
/* Retrieve all results */
|
||||||
const links = Array.prototype.slice.call(
|
const links = Array.prototype.slice.call(
|
||||||
document.querySelectorAll("[data-md-component=search] [href]"))
|
document.querySelectorAll(
|
||||||
if (!links.length)
|
"[data-md-component=query], [data-md-component=search] [href]"))
|
||||||
return
|
|
||||||
|
|
||||||
/* Retrieve current active/focused result */
|
/* Retrieve current active/focused result */
|
||||||
const focus = links.find(link => {
|
const focus = links.find(link => {
|
||||||
@ -321,10 +320,10 @@ function initialize(config) { // eslint-disable-line func-style
|
|||||||
) % links.length)
|
) % links.length)
|
||||||
|
|
||||||
/* Set active state and focus */
|
/* Set active state and focus */
|
||||||
if (!(links[index] instanceof HTMLElement))
|
if (links[index]) {
|
||||||
throw new ReferenceError
|
links[index].dataset.mdState = "active"
|
||||||
links[index].dataset.mdState = "active"
|
links[index].focus()
|
||||||
links[index].focus()
|
}
|
||||||
|
|
||||||
/* Prevent scrolling of page */
|
/* Prevent scrolling of page */
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
Loading…
Reference in New Issue
Block a user