diff options
author | Josh Rosen <joshrosen@databricks.com> | 2015-06-18 15:10:09 -0700 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2015-06-18 15:10:09 -0700 |
commit | 44c931f006194a833f09517c9e35fb3cdf5852b1 (patch) | |
tree | cd8b704c6143c7584299d8b69b5b871c0f581f7f /docs/js/main.js | |
parent | 9b2002722273f98e193ad6cd54c9626292ab27d1 (diff) | |
download | spark-44c931f006194a833f09517c9e35fb3cdf5852b1.tar.gz spark-44c931f006194a833f09517c9e35fb3cdf5852b1.tar.bz2 spark-44c931f006194a833f09517c9e35fb3cdf5852b1.zip |
[SPARK-8353] [DOCS] Show anchor links when hovering over documentation headers
This patch uses [AnchorJS](https://bryanbraun.github.io/anchorjs/) to show deep anchor links when hovering over headers in the Spark documentation. For example:
![image](https://cloud.githubusercontent.com/assets/50748/8240800/1502f85c-15ba-11e5-819a-97b231370a39.png)
This makes it easier for users to link to specific sections of the documentation.
I also removed some dead Javascript which isn't used in our current docs (it was introduced for the old AMPCamp training, but isn't used anymore).
Author: Josh Rosen <joshrosen@databricks.com>
Closes #6808 from JoshRosen/SPARK-8353 and squashes the following commits:
e59d8a7 [Josh Rosen] Suppress underline on hover
f518b6a [Josh Rosen] Turn on for all headers, since we use H1s in a bunch of places
a9fec01 [Josh Rosen] Add anchor links when hovering over headers; remove some dead JS code
Diffstat (limited to 'docs/js/main.js')
-rwxr-xr-x | docs/js/main.js | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/docs/js/main.js b/docs/js/main.js index f1a90e47e8..f5d66b16f7 100755 --- a/docs/js/main.js +++ b/docs/js/main.js @@ -68,38 +68,11 @@ function codeTabs() { }); } -function makeCollapsable(elt, accordionClass, accordionBodyId, title) { - $(elt).addClass("accordion-inner"); - $(elt).wrap('<div class="accordion ' + accordionClass + '"></div>') - $(elt).wrap('<div class="accordion-group"></div>') - $(elt).wrap('<div id="' + accordionBodyId + '" class="accordion-body collapse"></div>') - $(elt).parent().before( - '<div class="accordion-heading">' + - '<a class="accordion-toggle" data-toggle="collapse" href="#' + accordionBodyId + '">' + - title + - '</a>' + - '</div>' - ); -} - -// Enable "view solution" sections (for exercises) -function viewSolution() { - var counter = 0 - $("div.solution").each(function() { - var id = "solution_" + counter - makeCollapsable(this, "", id, - '<i class="icon-ok-sign" style="text-decoration: none; color: #0088cc">' + - '</i>' + "View Solution"); - counter++; - }); -} // A script to fix internal hash links because we have an overlapping top bar. // Based on https://github.com/twitter/bootstrap/issues/193#issuecomment-2281510 function maybeScrollToHash() { - console.log("HERE"); if (window.location.hash && $(window.location.hash).length) { - console.log("HERE2", $(window.location.hash), $(window.location.hash).offset().top); var newTop = $(window.location.hash).offset().top - 57; $(window).scrollTop(newTop); } @@ -107,7 +80,12 @@ function maybeScrollToHash() { $(function() { codeTabs(); - viewSolution(); + // Display anchor links when hovering over headers. For documentation of the + // configuration options, see the AnchorJS documentation. + anchors.options = { + placement: 'left' + }; + anchors.add(); $(window).bind('hashchange', function() { maybeScrollToHash(); |