Repository: flink Updated Branches: refs/heads/master f6e6924eb -> 5fbedff01
[FLINK-3577] [docs] Display anchor links when hovering over headers. This closes #1762 Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/5fbedff0 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/5fbedff0 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/5fbedff0 Branch: refs/heads/master Commit: 5fbedff0148b8793885ce99204cbc86bd7aef400 Parents: f6e6924 Author: Jark Wu <[email protected]> Authored: Fri Mar 4 18:53:10 2016 +0800 Committer: Stephan Ewen <[email protected]> Committed: Thu Mar 10 20:28:25 2016 +0100 ---------------------------------------------------------------------- LICENSE | 1 + docs/_layouts/base.html | 3 +- docs/page/css/flink.css | 11 ++++ docs/page/js/codetabs.js | 121 --------------------------------------- docs/page/js/flink.js | 128 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 142 insertions(+), 122 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/5fbedff0/LICENSE ---------------------------------------------------------------------- diff --git a/LICENSE b/LICENSE index c9292d1..f97195f 100644 --- a/LICENSE +++ b/LICENSE @@ -233,6 +233,7 @@ The Apache Flink project bundles the following files under the MIT License: - moment.js v2.10.6 (http://momentjs.com/docs/) - Copyright (c) 2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors - moment-duration-format v1.3.0 (https://github.com/jsmreese/moment-duration-format) - Copyright (c) 2013 John Madhavan-Reese - qtip2 v2.2.1 (http://qtip2.com) - Copyright (c) 2012 Craig Michael Thompson + - AnchorJS (https://github.com/bryanbraun/anchorjs) - Copyright (c) 2013 Craig Michael Thompson All rights reserved. http://git-wip-us.apache.org/repos/asf/flink/blob/5fbedff0/docs/_layouts/base.html ---------------------------------------------------------------------- diff --git a/docs/_layouts/base.html b/docs/_layouts/base.html index 8c10eed..690d2af 100644 --- a/docs/_layouts/base.html +++ b/docs/_layouts/base.html @@ -73,7 +73,8 @@ under the License. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> - <script src="{{ site.baseurl }}/page/js/codetabs.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.1.0/anchor.min.js"></script> + <script src="{{ site.baseurl }}/page/js/flink.js"></script> <!-- Google Analytics --> <script> http://git-wip-us.apache.org/repos/asf/flink/blob/5fbedff0/docs/page/css/flink.css ---------------------------------------------------------------------- diff --git a/docs/page/css/flink.css b/docs/page/css/flink.css index bcc398a..98d0979 100644 --- a/docs/page/css/flink.css +++ b/docs/page/css/flink.css @@ -225,3 +225,14 @@ th { td { padding: 5px; } + +/*============================================================================= + AnchorJS (anchor links when hovering over headers) +=============================================================================*/ + +.anchorjs-link:hover { + text-decoration: none; +} +*:hover > .anchorjs-link { + transition: color .25s linear; +} http://git-wip-us.apache.org/repos/asf/flink/blob/5fbedff0/docs/page/js/codetabs.js ---------------------------------------------------------------------- diff --git a/docs/page/js/codetabs.js b/docs/page/js/codetabs.js deleted file mode 100644 index 878aa32..0000000 --- a/docs/page/js/codetabs.js +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Note: This file is originally from the Apache Spark project. */ - -/* Custom JavaScript code in the MarkDown docs */ - -// Enable language-specific code tabs -function codeTabs() { - var counter = 0; - var langImages = { - "scala": "img/scala-sm.png", - "python": "img/python-sm.png", - "java": "img/java-sm.png" - }; - $("div.codetabs").each(function() { - $(this).addClass("tab-content"); - - // Insert the tab bar - var tabBar = $('<ul class="nav nav-tabs" data-tabs="tabs"></ul>'); - $(this).before(tabBar); - - // Add each code sample to the tab bar: - var codeSamples = $(this).children("div"); - codeSamples.each(function() { - $(this).addClass("tab-pane"); - var lang = $(this).data("lang"); - var image = $(this).data("image"); - var notabs = $(this).data("notabs"); - var capitalizedLang = lang.substr(0, 1).toUpperCase() + lang.substr(1); - var id = "tab_" + lang + "_" + counter; - $(this).attr("id", id); - if (image != null && langImages[lang]) { - var buttonLabel = "<img src='" +langImages[lang] + "' alt='" + capitalizedLang + "' />"; - } else if (notabs == null) { - var buttonLabel = "<b>" + capitalizedLang + "</b>"; - } else { - var buttonLabel = "" - } - tabBar.append( - '<li><a class="tab_' + lang + '" href="#' + id + '">' + buttonLabel + '</a></li>' - ); - }); - - codeSamples.first().addClass("active"); - tabBar.children("li").first().addClass("active"); - counter++; - }); - $("ul.nav-tabs a").click(function (e) { - // Toggling a tab should switch all tabs corresponding to the same language - // while retaining the scroll position - e.preventDefault(); - var scrollOffset = $(this).offset().top - $(document).scrollTop(); - $("." + $(this).attr('class')).tab('show'); - $(document).scrollTop($(this).offset().top - scrollOffset); - }); -} - -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); - } -} - -$(function() { - codeTabs(); - viewSolution(); - - $(window).bind('hashchange', function() { - maybeScrollToHash(); - }); - - // Scroll now too in case we had opened the page on a hash, but wait a bit because some browsers - // will try to do *their* initial scroll after running the onReady handler. - $(window).load(function() { setTimeout(function() { maybeScrollToHash(); }, 25); }); -}); http://git-wip-us.apache.org/repos/asf/flink/blob/5fbedff0/docs/page/js/flink.js ---------------------------------------------------------------------- diff --git a/docs/page/js/flink.js b/docs/page/js/flink.js new file mode 100644 index 0000000..fdf972c --- /dev/null +++ b/docs/page/js/flink.js @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Note: This file is originally from the Apache Spark project. */ + +/* Custom JavaScript code in the MarkDown docs */ + +// Enable language-specific code tabs +function codeTabs() { + var counter = 0; + var langImages = { + "scala": "img/scala-sm.png", + "python": "img/python-sm.png", + "java": "img/java-sm.png" + }; + $("div.codetabs").each(function() { + $(this).addClass("tab-content"); + + // Insert the tab bar + var tabBar = $('<ul class="nav nav-tabs" data-tabs="tabs"></ul>'); + $(this).before(tabBar); + + // Add each code sample to the tab bar: + var codeSamples = $(this).children("div"); + codeSamples.each(function() { + $(this).addClass("tab-pane"); + var lang = $(this).data("lang"); + var image = $(this).data("image"); + var notabs = $(this).data("notabs"); + var capitalizedLang = lang.substr(0, 1).toUpperCase() + lang.substr(1); + var id = "tab_" + lang + "_" + counter; + $(this).attr("id", id); + if (image != null && langImages[lang]) { + var buttonLabel = "<img src='" +langImages[lang] + "' alt='" + capitalizedLang + "' />"; + } else if (notabs == null) { + var buttonLabel = "<b>" + capitalizedLang + "</b>"; + } else { + var buttonLabel = "" + } + tabBar.append( + '<li><a class="tab_' + lang + '" href="#' + id + '">' + buttonLabel + '</a></li>' + ); + }); + + codeSamples.first().addClass("active"); + tabBar.children("li").first().addClass("active"); + counter++; + }); + $("ul.nav-tabs a").click(function (e) { + // Toggling a tab should switch all tabs corresponding to the same language + // while retaining the scroll position + e.preventDefault(); + var scrollOffset = $(this).offset().top - $(document).scrollTop(); + $("." + $(this).attr('class')).tab('show'); + $(document).scrollTop($(this).offset().top - scrollOffset); + }); +} + +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); + } +} + +$(function() { + codeTabs(); + viewSolution(); + + // Display anchor links when hovering over headers. For documentation of the + // configuration options, see the AnchorJS documentation. + anchors.options = { + placement: 'right' + }; + anchors.add(); + + $(window).bind('hashchange', function() { + maybeScrollToHash(); + }); + + // Scroll now too in case we had opened the page on a hash, but wait a bit because some browsers + // will try to do *their* initial scroll after running the onReady handler. + $(window).load(function() { setTimeout(function() { maybeScrollToHash(); }, 25); }); +});
