Sha256: 6d6813ecb40c3352682054db8e2fd6c7d0a845eea0149d1bd9cb33466f7e7b27

Contents?: true

Size: 884 Bytes

Versions: 4

Compression:

Stored size: 884 Bytes

Contents

(function () {
  'use strict';

  document.addEventListener('DOMContentLoaded', function() {
    var sidebarItemLinks = document.querySelectorAll('nav > ul.nav a'),
        sidebarItemLinkCount = sidebarItemLinks.length,
        currentUrl = String(window.location).split('?')[0];

    for (var i = 0; i < sidebarItemLinkCount; i += 1) {
      var item = sidebarItemLinks[i],
          parentLists = item.parentNode.querySelectorAll('ul'),
          parentListLength = parentLists.length;

      if (currentUrl.substr(currentUrl.length - 1) == '#') {
        currentUrl = currentUrl.slice(0, -1);
      }

      if (currentUrl.lastIndexOf(item.href, 0) === 0) {
        item.classList.add('active');

        for (var j = 0; j < parentListLength; j += 1) {
          var linkItem = parentLists[i];

          linkItem.parentclassList.add('open');
        }
      }
    }

  });
}());

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
archangel-0.0.5 app/themes/default/assets/javascripts/default/common/navigation.js
archangel-0.0.4 app/themes/default/assets/javascripts/default/common/navigation.js
archangel-0.0.3 app/themes/default/assets/javascripts/default/common/navigation.js
archangel-0.0.2 app/themes/default/assets/javascripts/default/common/navigation.js