Guest User

Untitled

a guest
Mar 7th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         /* ------------------------------------------------------------------------ */
  2.         /*  NAV
  3.         /* ------------------------------------------------------------------------ */
  4.         $('.nav-toggle').click(function(){
  5.             $('.main-sidebar').toggleClass('toggle-on');
  6.             $('.section-wrapper').toggleClass('toggle-on');
  7.         });
  8.        
  9.         function initNav() {
  10.             var navSpaceHeight = getNavSpaceHeight();
  11.             $('.top-line').css('height', navSpaceHeight);
  12.             $('.bottom-line').css('height', navSpaceHeight);
  13.         }
  14.         initNav();
  15.        
  16.         $(window).on('resize', function () {
  17.             initNav();      
  18.         });
  19.        
  20.         $('.navigation a').click(function(){
  21.             var target = $(this).data('target');
  22.             $.scrollTo( target, 1300, {easing:'swing'} );
  23.             $('.navigation a').removeClass('current');
  24.             $('.navigation li').removeClass('current');
  25.             $(this).addClass('current');
  26.             $(this).parent('li').addClass('current');
  27.             $('.nav-toggle').trigger('click'); // Add this line
  28.         });
  29.        
  30.         // Window scroll
  31.         $(window).scroll(function() {
  32.             var windscroll = $(window).scrollTop();
  33.             if (windscroll >= 100) {
  34.                 $('body section').each(function(i) {
  35.                     if ($(this).position().top <= windscroll - 0) {
  36.                         $('.navigation a.current').parent('li').removeClass('current');
  37.                         $('.navigation a.current').removeClass('current');
  38.                         $('.navigation a').eq(i).addClass('current');
  39.                         $('.navigation a.current').parent('li').addClass('current');
  40.                     }
  41.                 });
  42.             } else {
  43.                 $('.navigation a.current').removeClass('current');
  44.                 $('.navigation a.current').parent('li').removeClass('current');
  45.                 $('.navigation a:first').parent('li').addClass('current');
  46.                 $('.navigation a:first').addClass('current');
  47.             }
  48.         }).scroll();
  49.        
  50.         $(document).keydown(function(e) {
  51.             var code = e.keyCode || e.which;
  52.             if(code == 38) { // Up
  53.            
  54.                 var $next = $( '.navigation' ).find( '.current' ).prev( 'li' ).find('a');
  55.  
  56.                 // If there isn't one, go to the beginning
  57.                 if ( ! $next.length ) {
  58.                     $next = $( '.navigation' ).find( 'li' ).last().find('a')
  59.                 }
  60.                
  61.                 // Trigger the click
  62.                 $next.trigger( 'click' );
  63.                
  64.             } else if(code == 40) { // Down
  65.            
  66.                 var $next = $( '.navigation' ).find( '.current' ).next( 'li' ).find('a');
  67.  
  68.                 // If there isn't one, go to the beginning
  69.                 if ( ! $next.length ) {
  70.                     $next = $( '.navigation' ).find( 'li' ).first().find('a')
  71.                 }
  72.            
  73.                 // Trigger the click
  74.                 $next.trigger( 'click' );
  75.                
  76.             }
  77.         });
Advertisement
Add Comment
Please, Sign In to add comment