From 97e743ac1497057dcee4f7fbe0437eff4ca53b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 5 Apr 2019 13:59:31 +0100 Subject: [PATCH] docs: move javascript logic into a standalone file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of duplicating javascript in every single page, put it in a standalone file which can be cached by the browser. Reviewed-by: Andrea Bolognani Signed-off-by: Daniel P. Berrangé --- docs/Makefile.am | 1 + docs/js/main.js | 25 +++++++++++++++++++++++++ docs/page.xsl | 35 +++-------------------------------- 3 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 docs/js/main.js diff --git a/docs/Makefile.am b/docs/Makefile.am index 2a9d99071c..29b0761a2b 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -56,6 +56,7 @@ css = \ main.css javascript = \ + js/main.js \ js/jquery-3.1.1.min.js \ js/jquery.rss.min.js \ js/moment.min.js diff --git a/docs/js/main.js b/docs/js/main.js new file mode 100644 index 0000000000..723e2fb16d --- /dev/null +++ b/docs/js/main.js @@ -0,0 +1,25 @@ +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 = "" + } + } + }); +} diff --git a/docs/page.xsl b/docs/page.xsl index beb864f26b..136f3106e4 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -99,40 +99,11 @@ - - + -- GitLab