Created
March 17, 2016 08:28
-
-
Save chriskonnertz/2899629644af05a4592c to your computer and use it in GitHub Desktop.
frontend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() | |
{ | |
var navKey = 'navIndex'; | |
var navIndex= sessionStorage.getItem(navKey); | |
var $nav = $('#header nav'); | |
if (typeof navIndex === 'undefined') { | |
navIndex = 0; | |
} | |
if (window.location.pathname == '/') { | |
navIndex = 0; | |
sessionStorage.setItem(navKey, 0); | |
} | |
if (navIndex > 0) { | |
$nav.find('a').removeClass('active'); | |
$nav.find('a:eq(' + navIndex + ')').addClass('active'); | |
} | |
$nav.find('a').click(function(event) | |
{ | |
sessionStorage.setItem(navKey, $(this).parent().index() - 1); // -1 because of icon li | |
}); | |
$('#header nav .icon').click(function(event) | |
{ | |
$nav.toggleClass('max'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment