mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +01:00
Reset meta text to placeholder if input is cleared
This commit is contained in:
parent
931465af9f
commit
c732082a1c
File diff suppressed because one or more lines are too long
3
material/assets/javascripts/application-cc8bbd29c0.js
Normal file
3
material/assets/javascripts/application-cc8bbd29c0.js
Normal file
File diff suppressed because one or more lines are too long
@ -151,7 +151,7 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ base_url }}/assets/javascripts/application-3e4827aebb.js"></script>
|
||||
<script src="{{ base_url }}/assets/javascripts/application-cc8bbd29c0.js"></script>
|
||||
<script>app.initialize({url:{base:"{{ base_url }}"}})</script>
|
||||
{% for path in extra_javascript %}
|
||||
<script src="{{ path }}"></script>
|
||||
|
@ -232,8 +232,13 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
/* Search is open */
|
||||
if (toggle.checked) {
|
||||
|
||||
/* Enter: prevent form submission */
|
||||
if (ev.key === "Enter") {
|
||||
if (query === document.activeElement)
|
||||
ev.preventDefault()
|
||||
|
||||
/* Escape: close search */
|
||||
if (ev.key === "Escape") {
|
||||
} else if (ev.key === "Escape") {
|
||||
toggle.checked = false
|
||||
toggle.dispatchEvent(new CustomEvent("change"))
|
||||
query.blur()
|
||||
|
@ -63,6 +63,7 @@ export default class Result {
|
||||
|
||||
/* Load messages for metadata display */
|
||||
this.message_ = {
|
||||
placeholder: this.meta_.textContent,
|
||||
none: this.meta_.dataset.mdLangResultNone,
|
||||
one: this.meta_.dataset.mdLangResultOne,
|
||||
other: this.meta_.dataset.mdLangResultOther
|
||||
@ -154,8 +155,8 @@ export default class Result {
|
||||
if (!(target instanceof HTMLInputElement))
|
||||
throw new ReferenceError
|
||||
|
||||
/* Abort early, if input hasn't changed */
|
||||
if (target.value === this.value_)
|
||||
/* Abort early, if index is not build or input hasn't changed */
|
||||
if (!this.index_ || target.value === this.value_)
|
||||
return
|
||||
|
||||
/* Clear current list */
|
||||
@ -164,8 +165,10 @@ export default class Result {
|
||||
|
||||
/* Abort early, if search input is empty */
|
||||
this.value_ = target.value
|
||||
if (this.value_.length === 0)
|
||||
if (this.value_.length === 0) {
|
||||
this.meta_.textContent = this.message_.placeholder
|
||||
return
|
||||
}
|
||||
|
||||
/* Perform search on index and group sections by document */
|
||||
const result = this.index_
|
||||
|
Loading…
Reference in New Issue
Block a user