提交 97e743ac 编写于 作者: D Daniel P. Berrangé

docs: move javascript logic into a standalone file

Instead of duplicating javascript in every single page, put it in a
standalone file which can be cached by the browser.
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 db3d4f96
...@@ -56,6 +56,7 @@ css = \ ...@@ -56,6 +56,7 @@ css = \
main.css main.css
javascript = \ javascript = \
js/main.js \
js/jquery-3.1.1.min.js \ js/jquery-3.1.1.min.js \
js/jquery.rss.min.js \ js/jquery.rss.min.js \
js/moment.min.js js/moment.min.js
......
function pageload() {
window.addEventListener('scroll', function(e){
var distanceY = window.pageYOffset || document.documentElement.scrollTop
var shrinkOn = 94
home = document.getElementById("home");
links = document.getElementById("jumplinks");
search = document.getElementById("search");
body = document.getElementById("body");
if (distanceY > shrinkOn) {
if (home.className != "navhide") {
body.className = "navhide"
home.className = "navhide"
links.className = "navhide"
search.className = "navhide"
}
} else {
if (home.className == "navhide") {
body.className = ""
home.className = ""
links.className = ""
search.className = ""
}
}
});
}
...@@ -99,40 +99,11 @@ ...@@ -99,40 +99,11 @@
<meta name="description" content="libvirt, virtualization, virtualization API"/> <meta name="description" content="libvirt, virtualization, virtualization API"/>
<xsl:apply-templates select="/html:html/html:head/*" mode="content"/> <xsl:apply-templates select="/html:html/html:head/*" mode="content"/>
<script type="text/javascript"> <script type="text/javascript" src="{$href_base}js/main.js">
<xsl:comment> <xsl:comment>// forces non-empty element</xsl:comment>
<![CDATA[
function init() {
window.addEventListener('scroll', function(e){
var distanceY = window.pageYOffset || document.documentElement.scrollTop,
shrinkOn = 94
home = document.getElementById("home");
links = document.getElementById("jumplinks");
search = document.getElementById("search");
body = document.getElementById("body");
if (distanceY > shrinkOn) {
if (home.className != "navhide") {
body.className = "navhide"
home.className = "navhide"
links.className = "navhide"
search.className = "navhide"
}
} else {
if (home.className == "navhide") {
body.className = ""
home.className = ""
links.className = ""
search.className = ""
}
}
});
}
window.onload = init();
]]>
</xsl:comment>
</script> </script>
</head> </head>
<body> <body onload="pageload()">
<xsl:if test="html:html/html:body/@class"> <xsl:if test="html:html/html:body/@class">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="html:html/html:body/@class"/> <xsl:value-of select="html:html/html:body/@class"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册