Skip to content

Commit

Permalink
Merge pull request #46 from m5o/navigation-section-is-open
Browse files Browse the repository at this point in the history
open navigation section for current page
  • Loading branch information
winstromming committed Jun 3, 2014
2 parents 5183e75 + babd75a commit eba5d2f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasks/data/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,20 @@
iframes[i].height = iframes[i].contentWindow.document.body.scrollHeight;
}
};
var headings = document.querySelectorAll('#nav .heading');
for ( var i = 0; i < headings.length; i++ ){
var list = headings[i].nextElementSibling;
var links = list.querySelectorAll('a');
for ( var j = 0; j < links.length; j++ ){
if ( links[j].href.match('/{{page.href}}') ) {
links[j].classList.toggle('is-active');
links[j].parentNode.parentNode.classList.toggle('is-open');
links[j].parentNode.parentNode.previousElementSibling.classList.toggle('is-open');
}
}
headings[i].addEventListener('click', function () {
this.classList.toggle('is-open');
this.nextElementSibling.classList.toggle('is-open');
Expand Down

0 comments on commit eba5d2f

Please sign in to comment.