Sha256: d9271107b9969bf6190de5102d1bad3ad560c2f0ae57532126706fa52ef796b0

Contents?: true

Size: 608 Bytes

Versions: 34

Compression:

Stored size: 608 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

34 entries across 34 versions & 2 rubygems

Version Path
epuber-stylus-source-0.56.0 vendor/node_modules/jscoverage/reporter/templates/script.ejs
epuber-stylus-source-0.54.8 vendor/node_modules/jscoverage/reporter/templates/script.ejs
stylus-source-0.49.3 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.42.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.42.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.42.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.41.3 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.41.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.41.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.41.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.40.3 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.40.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.40.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.40.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.39.4 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.39.3 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.39.2 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.39.1 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.39.0 vendor/node_modules/mocha/lib/reporters/templates/script.html
stylus-source-0.38.0 vendor/node_modules/mocha/lib/reporters/templates/script.html