Skip to content

Commit 6719469

Browse files
authored
Merge pull request ldapjs#706 from UziTech/highlight-code-docs
2 parents 2ee04b1 + 7a5251b commit 6719469

13 files changed

+1314
-1114
lines changed

docs/branding/footer.html.in

+2-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,7 @@
11
</div><!-- end #content -->
22

3-
<script type="text/javascript" charset="utf-8">
4-
$(function() {
5-
var headerHeight = $("#header").height();
6-
var offsets = [];
7-
var current = -1;
8-
9-
function endpoint(scrollDistance) {
10-
if (scrollDistance < offsets[0]) {
11-
return -1;
12-
} else {
13-
for (var id = offsets.length; id > 0; id--) {
14-
if (scrollDistance > offsets[id - 1]) {
15-
return id - 1;
16-
break;
17-
}
18-
}
19-
}
20-
}
21-
22-
$("h2").each(function(i) {
23-
offsets.push($(this).offset().top - headerHeight)
24-
});
25-
26-
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
27-
var fixed_h2 = $("h2.fixed");
28-
var fixed_span = $("h2.fixed span");
29-
30-
$("#content").scroll(function() {
31-
var scrollDistance = $("#content").attr('scrollTop');
32-
var now = endpoint(scrollDistance);
33-
34-
if (now !== current) {
35-
$("#sidebar li").removeClass("current");
36-
current = now;
37-
if (current < 0) {
38-
fixed_h2.hide();
39-
} else if (current >= 0) {
40-
var heading = $($("h2 span")[current]).text();
41-
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
42-
fixed_span.text(heading);
43-
fixed_h2.show();
44-
}
45-
}
46-
});
47-
});
48-
</script>
3+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
4+
<script type="text/javascript" src="media/js/script.js"></script>
495

506
</body>
517
</html>

docs/branding/header.html.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>%(title)s</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
66
<link rel="stylesheet" type="text/css" href="media/css/style.css">
7-
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
7+
<link rel="stylesheet" type="text/css" href="media/css/highlight.css">
88
</head>
99
<body>
1010
<div id="header">

docs/branding/media/js/script.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
/* eslint-disable */
3+
4+
$(function() {
5+
var headerHeight = $("#header").height();
6+
var offsets = [];
7+
var current = -1;
8+
9+
function endpoint(scrollDistance) {
10+
if (scrollDistance < offsets[0]) {
11+
return -1;
12+
} else {
13+
for (var id = offsets.length; id > 0; id--) {
14+
if (scrollDistance > offsets[id - 1]) {
15+
return id - 1;
16+
break;
17+
}
18+
}
19+
}
20+
}
21+
22+
$("h2").each(function(i) {
23+
offsets.push($(this).offset().top - headerHeight)
24+
});
25+
26+
$("#content").append('<h2 class="fixed" style="display: none"><span>&nbsp;</span></h2>');
27+
var fixed_h2 = $("h2.fixed");
28+
var fixed_span = $("h2.fixed span");
29+
30+
$("#content").scroll(function() {
31+
var scrollDistance = $("#content").attr('scrollTop');
32+
var now = endpoint(scrollDistance);
33+
34+
if (now !== current) {
35+
$("#sidebar li").removeClass("current");
36+
current = now;
37+
if (current < 0) {
38+
fixed_h2.hide();
39+
} else if (current >= 0) {
40+
var heading = $($("h2 span")[current]).text();
41+
$("#sidebar a[href|=#" + heading.replace(' ', '-') + "]").parent().addClass("current");
42+
fixed_span.text(heading);
43+
fixed_h2.show();
44+
}
45+
}
46+
});
47+
});

0 commit comments

Comments
 (0)