Sha256: de33e5ebc37a8b6e88cad7b411cc6872975b3d1a9953f0b7e4c648844af7c67d

Contents?: true

Size: 606 Bytes

Versions: 10

Compression:

Stored size: 606 Bytes

Contents

<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>

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stylus-source-0.29.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.28.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.28.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.28.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.27.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.27.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.27.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.26.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.26.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.25.0 vendor/node_modules/mocha/lib/reporters/templates/script.html