mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed uncaught reference error when search plugin is disabled
This commit is contained in:
parent
4b5c45c656
commit
4f5677d584
File diff suppressed because one or more lines are too long
1
material/assets/javascripts/application.cb27f861.js
Normal file
1
material/assets/javascripts/application.cb27f861.js
Normal file
File diff suppressed because one or more lines are too long
@ -167,7 +167,7 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block scripts %}
|
||||
<script src="{{ base_url }}/assets/javascripts/application.5f9a6f1b.js"></script>
|
||||
<script src="{{ base_url }}/assets/javascripts/application.cb27f861.js"></script>
|
||||
{% if lang.t("search.language") != "en" %}
|
||||
{% set languages = lang.t("search.language").split(",") %}
|
||||
{% if languages | length and languages[0] != "" %}
|
||||
|
@ -1 +1 @@
|
||||
<script>!function(e,a,t,n,o,c,i){e.GoogleAnalyticsObject=o,e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,c=a.createElement(t),i=a.getElementsByTagName(t)[0],c.async=1,c.src="https://www.google-analytics.com/analytics.js",i.parentNode.insertBefore(c,i)}(window,document,"script",0,"ga"),ga("create","{{ config.google_analytics[0] }}","{{ config.google_analytics[1] }}"),ga("set","anonymizeIp",!0),ga("send","pageview");var links=document.getElementsByTagName("a");Array.prototype.map.call(links,function(e){e.host!=document.location.host&&e.addEventListener("click",function(){var a=e.getAttribute("data-md-action")||"follow";ga("send","event","outbound",a,e.href)})});var query=document.forms.search.query;query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})</script>
|
||||
<script>!function(e,a,t,n,o,c,i){e.GoogleAnalyticsObject=o,e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,c=a.createElement(t),i=a.getElementsByTagName(t)[0],c.async=1,c.src="https://www.google-analytics.com/analytics.js",i.parentNode.insertBefore(c,i)}(window,document,"script",0,"ga"),ga("create","{{ config.google_analytics[0] }}","{{ config.google_analytics[1] }}"),ga("set","anonymizeIp",!0),ga("send","pageview");var links=document.getElementsByTagName("a");if(Array.prototype.map.call(links,function(e){e.host!=document.location.host&&e.addEventListener("click",function(){var a=e.getAttribute("data-md-action")||"follow";ga("send","event","outbound",a,e.href)})}),document.forms.search){var query=document.forms.search.query;query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}</script>
|
||||
|
@ -276,6 +276,9 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
"[data-md-component=navigation] [data-md-toggle]", "change",
|
||||
new Material.Nav.Scrolling("[data-md-component=navigation] nav")))
|
||||
|
||||
/* Initialize search, if available */
|
||||
if (document.querySelector("[data-md-component=search]")) {
|
||||
|
||||
/* Component: search body lock for mobile */
|
||||
new Material.Event.MatchMedia("(max-width: 959px)",
|
||||
new Material.Event.Listener("[data-md-toggle=search]", "change",
|
||||
@ -298,45 +301,6 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
})
|
||||
})).listen()
|
||||
|
||||
/* Listener: handle tabbing context for better accessibility */
|
||||
new Material.Event.Listener(document.body, "keydown", ev => {
|
||||
if (ev.keyCode === 9) {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[for]:not([tabindex])")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
if (label.offsetHeight)
|
||||
label.tabIndex = 0
|
||||
})
|
||||
}
|
||||
}).listen()
|
||||
|
||||
/* Listener: reset tabbing behavior */
|
||||
new Material.Event.Listener(document.body, "mousedown", () => {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[tabindex]")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
label.removeAttribute("tabIndex")
|
||||
})
|
||||
}).listen()
|
||||
|
||||
document.body.addEventListener("click", () => {
|
||||
if (document.body.dataset.mdState === "tabbing")
|
||||
document.body.dataset.mdState = ""
|
||||
})
|
||||
|
||||
/* Listener: close drawer when anchor links are clicked */
|
||||
new Material.Event.MatchMedia("(max-width: 959px)",
|
||||
new Material.Event.Listener("[data-md-component=navigation] [href^='#']",
|
||||
"click", () => {
|
||||
const toggle = document.querySelector("[data-md-toggle=drawer]")
|
||||
if (!(toggle instanceof HTMLInputElement))
|
||||
throw new ReferenceError
|
||||
if (toggle.checked) {
|
||||
toggle.checked = false
|
||||
toggle.dispatchEvent(new CustomEvent("change"))
|
||||
}
|
||||
}))
|
||||
|
||||
/* Listener: focus input after form reset */
|
||||
new Material.Event.Listener("[data-md-component=reset]", "click", () => {
|
||||
setTimeout(() => {
|
||||
@ -479,6 +443,46 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
query.focus()
|
||||
}
|
||||
}).listen()
|
||||
}
|
||||
|
||||
/* Listener: handle tabbing context for better accessibility */
|
||||
new Material.Event.Listener(document.body, "keydown", ev => {
|
||||
if (ev.keyCode === 9) {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[for]:not([tabindex])")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
if (label.offsetHeight)
|
||||
label.tabIndex = 0
|
||||
})
|
||||
}
|
||||
}).listen()
|
||||
|
||||
/* Listener: reset tabbing behavior */
|
||||
new Material.Event.Listener(document.body, "mousedown", () => {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[tabindex]")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
label.removeAttribute("tabIndex")
|
||||
})
|
||||
}).listen()
|
||||
|
||||
document.body.addEventListener("click", () => {
|
||||
if (document.body.dataset.mdState === "tabbing")
|
||||
document.body.dataset.mdState = ""
|
||||
})
|
||||
|
||||
/* Listener: close drawer when anchor links are clicked */
|
||||
new Material.Event.MatchMedia("(max-width: 959px)",
|
||||
new Material.Event.Listener("[data-md-component=navigation] [href^='#']",
|
||||
"click", () => {
|
||||
const toggle = document.querySelector("[data-md-toggle=drawer]")
|
||||
if (!(toggle instanceof HTMLInputElement))
|
||||
throw new ReferenceError
|
||||
if (toggle.checked) {
|
||||
toggle.checked = false
|
||||
toggle.dispatchEvent(new CustomEvent("change"))
|
||||
}
|
||||
}))
|
||||
|
||||
/* Retrieve facts for the given repository type */
|
||||
;(() => {
|
||||
|
@ -49,6 +49,7 @@
|
||||
});
|
||||
|
||||
/* Register handler to log search on blur */
|
||||
if (document.forms.search) {
|
||||
var query = document.forms.search.query;
|
||||
query.addEventListener("blur", function() {
|
||||
if (this.value) {
|
||||
@ -56,4 +57,5 @@
|
||||
ga("send", "pageview", path + "?q=" + this.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user