From 828404c2853002c9e93a9da9a1aff180bed13bdf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 30 Jul 2016 16:41:30 -0400 Subject: [PATCH] Add a back-to-top button --- docs/assets/style.css | 8 ++++++++ docs/template.html | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/assets/style.css b/docs/assets/style.css index ec4e3c24f..f5f3853c8 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -423,6 +423,14 @@ blockquote { vertical-align: -2px; padding-left: 8px; } +.back-to-contents { + position: fixed; + bottom: calc(66% - 34px); + right: 0; + background: #363637; + padding: 5px 0 4px; + z-index: 90; +} .icon-improve { color: #bdbdb5; padding: 2px 9px 0 10px; diff --git a/docs/template.html b/docs/template.html index e7c245b36..55e7b4d08 100644 --- a/docs/template.html +++ b/docs/template.html @@ -122,6 +122,14 @@ vertical-align: -2px; padding-left: 8px; } + .back-to-contents { + position: fixed; + bottom: calc(66% - 34px); + right: 0; + background: #363637; + padding: 5px 0px 4px; + z-index: 90; + } .icon-improve { color: #bdbdb5; padding: 2px 9px 0 10px; @@ -169,6 +177,7 @@
Improve This Doc
+
@@ -188,7 +197,7 @@ Application Management Remote Commands One Off Processes/Cron - Scaling Apps + Process Scaling User Management Zero Downtime Deploy Checks @@ -307,6 +316,7 @@ var tables = document.querySelectorAll('table'), blockquotes = document.querySelectorAll('blockquote'), versionList = document.querySelectorAll('.rst-other-versions dl')[0], + backToContentsEl = document.querySelectorAll('.back-to-contents')[0] currentVersionEl = document.querySelectorAll('.rst-current-version')[0], currentVersion = currentVersionEl.getAttribute('data-ref'), versionContainer = document.querySelectorAll('.rst-versions.rst-badge')[0], @@ -366,6 +376,19 @@ return language; }; + addListener(backToContentsEl, 'click', function(e) { + e.preventDefault(); + var scrollToTop = window.setInterval(function() { + var pos = window.pageYOffset; + if ( pos > 0 ) { + window.scrollTo( 0, pos - 20 ); + } else { + window.clearInterval( scrollToTop ); + } + }, 1); + return false; + }); + var ls2 = { save : function (key, jsonData, expirationMS) { if (typeof (Storage) === 'undefined') { return false; }