diff options
| author | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
| commit | 686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch) | |
| tree | a5b5e50237cef70e12f0745371896e96f5f6d578 /node_modules/mocha/lib/reporters/templates/script.html | |
ok
Diffstat (limited to 'node_modules/mocha/lib/reporters/templates/script.html')
| -rw-r--r-- | node_modules/mocha/lib/reporters/templates/script.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/node_modules/mocha/lib/reporters/templates/script.html b/node_modules/mocha/lib/reporters/templates/script.html new file mode 100644 index 0000000..7df9bcd --- /dev/null +++ b/node_modules/mocha/lib/reporters/templates/script.html @@ -0,0 +1,34 @@ +<script> + +headings = []; + +onload = function(){ + headings = document.querySelectorAll('h2'); +}; + +onscroll = function(e){ + var heading = find(window.scrollY); + if (!heading) return; + var links = document.querySelectorAll('#menu a') + , link; + + for (var i = 0, len = links.length; i < len; ++i) { + link = links[i]; + link.className = link.getAttribute('href') == '#' + heading.id + ? 'active' + : ''; + } +}; + +function find(y) { + var i = headings.length + , heading; + + while (i--) { + heading = headings[i]; + if (y > heading.offsetTop) { + return heading; + } + } +} +</script>
\ No newline at end of file |
