mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Add ESC handler to search modal
This commit is contained in:
parent
9d4a8409f9
commit
4ed0b1328f
File diff suppressed because one or more lines are too long
@ -110,7 +110,7 @@
|
|||||||
<script src="https://cdn.mathjax.org/{{ path }}"></script>
|
<script src="https://cdn.mathjax.org/{{ path }}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<script src="{{ base_url }}/assets/javascripts/application-7481d5412b.js"></script>
|
<script src="{{ base_url }}/assets/javascripts/application-5c0b7e9d97.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/* Configuration for application */
|
/* Configuration for application */
|
||||||
var config = {
|
var config = {
|
||||||
|
@ -183,6 +183,19 @@ export default class Application {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
/* Listener: disable search when ESC key is pressed */
|
||||||
|
new Material.Event.Listener(window, "keyup", ev => {
|
||||||
|
const code = ev.keyCode || ev.which
|
||||||
|
if (code === 27) {
|
||||||
|
const toggle = document.querySelector("[data-md-toggle=search]")
|
||||||
|
if (toggle.checked) {
|
||||||
|
toggle.checked = false
|
||||||
|
dispatch(toggle, "change")
|
||||||
|
document.forms.search.query.blur()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).listen()
|
||||||
|
|
||||||
/* Listener: fix unclickable toggle due to blur handler */
|
/* Listener: fix unclickable toggle due to blur handler */
|
||||||
new Material.Event.MatchMedia("(min-width: 960px)",
|
new Material.Event.MatchMedia("(min-width: 960px)",
|
||||||
new Material.Event.Listener("[data-md-toggle=search]", "click",
|
new Material.Event.Listener("[data-md-toggle=search]", "click",
|
||||||
|
Loading…
Reference in New Issue
Block a user