node-ldapjs/docs/branding/footer.html.in

50 lines
1.4 KiB
HTML
Raw Normal View History

2011-08-24 19:38:23 +00:00
<script type="text/javascript" charset="utf-8">
2015-10-16 05:25:49 +00:00
$(function() {
var headerHeight = $("#header").height();
var offsets = [];
var current = -1;
function endpoint(scrollDistance) {
if (scrollDistance < offsets[0]) {
return -1;
2011-08-24 19:38:23 +00:00
} else {
2015-10-16 05:25:49 +00:00
for (var id = offsets.length; id > 0; id--) {
if (scrollDistance > offsets[id - 1]) {
return id - 1;
break;
}
}
2011-08-24 19:38:23 +00:00
}
2015-10-16 05:25:49 +00:00
}
2015-10-16 05:25:49 +00:00
$("h2").each(function(i) {
offsets.push($(this).offset().top - headerHeight)
});
2015-10-16 05:25:49 +00:00
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
var fixed_h2 = $("h2.fixed");
var fixed_span = $("h2.fixed span");
$("#content").scroll(function() {
var scrollDistance = $("#content").attr('scrollTop');
var now = endpoint(scrollDistance);
if (now !== current) {
$("#sidebar li").removeClass("current");
current = now;
if (current < 0) {
fixed_h2.hide();
} else if (current >= 0) {
var heading = $($("h2 span")[current]).text();
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
fixed_span.text(heading);
fixed_h2.show();
}
}
});
2011-08-24 19:38:23 +00:00
});
</script>
</body>
</html>