Files
dvc/docs/js/layout.js
T
George Vyshnya c87ea669ce I!: added the initial version of DVC product documentation
The documentation pack comprises the elements below
- doc.rst - the source file with DVC product documentation in the format of RST text markup
- doc.html - the final HTML form of the documentation (ready to redistribute or publish on the site)
- cmd.bat - the command file that uses pandoc to convert doc.rst -> doc.html
- header.html - the HTML file with the code fragment to insert into HEADER tag of doc.html
- footer.html - the HTML file with the code fragment to insert into doc.html after the output produced by pandoc and before </body> tag
- top.html - the HTML file with the code fragment to insert into doc.html just after <body> tag, before the output generated by pandoc
- files in auxiliary folders (js, css, imaged) are used to create the appropriate look and feel of doc.html (they shall be redistributed along with doc.html)
-- Note: css/style.css is the place to edit major styles for DVC product documentation
-
2017-09-28 05:13:42 +03:00

84 lines
2.4 KiB
JavaScript

$(document).ready(function () {
var AFFIX_TOP_LIMIT = 300;
var AFFIX_OFFSET = 49;
$('#menu-left').localScroll({hash:true, onAfterFirst:function(){$('html, body').scrollTo( {top:'-=25px'}, 'fast' );}});
var $menu = $("#menu"),
$btn = $("#menu-toggle");
$("#menu-toggle").on("click", function () {
$menu.toggleClass("open");
return false;
});
$(".docs-nav").each(function () {
var $affixNav = $(this),
$container = $affixNav.parent(),
affixNavfixed = false,
originalClassName = this.className,
current = null,
$links = $affixNav.find("a");
function getClosestHeader(top) {
var last = $links.first();
if (top < AFFIX_TOP_LIMIT) {
return last;
}
for (var i = 0; i < $links.length; i++) {
var $link = $links.eq(i),
href = $link.attr("href");
if (href.charAt(0) === "#" && href.length > 1) {
var $anchor = $(href).first();
if ($anchor.length > 0) {
var offset = $anchor.offset();
if (top < offset.top - AFFIX_OFFSET) {
return last;
}
last = $link;
}
}
}
return last;
}
$(window).on("scroll", function (evt) {
var top = window.scrollY,
height = $affixNav.outerHeight(),
max_bottom = $container.offset().top + $container.outerHeight(),
bottom = top + height + AFFIX_OFFSET;
if (affixNavfixed) {
if (top <= AFFIX_TOP_LIMIT) {
$affixNav.removeClass("fixed");
$affixNav.css("top", 0);
affixNavfixed = false;
} else if (bottom > max_bottom) {
$affixNav.css("top", (max_bottom - height) - top);
} else {
$affixNav.css("top", AFFIX_OFFSET);
}
} else if (top > AFFIX_TOP_LIMIT) {
$affixNav.addClass("fixed");
affixNavfixed = true;
}
var $current = getClosestHeader(top);
if (current !== $current) {
$affixNav.find(".active").removeClass("active");
$current.addClass("active");
current = $current;
}
});
});
prettyPrint();
});