Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
187
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.         });
  28.        
  29.         // Window scroll
  30.         $(window).scroll(function() {
  31.             var windscroll = $(window).scrollTop();
  32.             if (windscroll >= 100) {
  33.                 $('body section').each(function(i) {
  34.                     if ($(this).position().top <= windscroll - 0) {
  35.                         $('.navigation a.current').parent('li').removeClass('current');
  36.                         $('.navigation a.current').removeClass('current');
  37.                         $('.navigation a').eq(i).addClass('current');
  38.                         $('.navigation a.current').parent('li').addClass('current');
  39.                     }
  40.                 });
  41.             } else {
  42.                 $('.navigation a.current').removeClass('current');
  43.                 $('.navigation a.current').parent('li').removeClass('current');
  44.                 $('.navigation a:first').parent('li').addClass('current');
  45.                 $('.navigation a:first').addClass('current');
  46.             }
  47.         }).scroll();
  48.        
  49.         $(document).keydown(function(e) {
  50.             var code = e.keyCode || e.which;
  51.             if(code == 38) { // Up
  52.            
  53.                 var $next = $( '.navigation' ).find( '.current' ).prev( 'li' ).find('a');
  54.  
  55.                 // If there isn't one, go to the beginning
  56.                 if ( ! $next.length ) {
  57.                     $next = $( '.navigation' ).find( 'li' ).last().find('a')
  58.                 }
  59.                
  60.                 // Trigger the click
  61.                 $next.trigger( 'click' );
  62.                
  63.             } else if(code == 40) { // Down
  64.            
  65.                 var $next = $( '.navigation' ).find( '.current' ).next( 'li' ).find('a');
  66.  
  67.                 // If there isn't one, go to the beginning
  68.                 if ( ! $next.length ) {
  69.                     $next = $( '.navigation' ).find( 'li' ).first().find('a')
  70.                 }
  71.            
  72.                 // Trigger the click
  73.                 $next.trigger( 'click' );
  74.                
  75.             }
  76.         });
  77.        
  78.        
  79.         /* ------------------------------------------------------------------------ */
  80.         /*  SMOOTH SCROLL
  81.         /* ------------------------------------------------------------------------ */
  82.         var scrollAnimationTime = 1300,
  83.             scrollAnimation = 'swing';
  84.  
  85.         $('a.scrollto').bind('click.smoothscroll',function (event) {
  86.             event.preventDefault();
  87.  
  88.             var target = this.hash;
  89.  
  90.             $('html, body').stop().animate({
  91.                 'scrollTop': $(target).offset().top
  92.             }, scrollAnimationTime, scrollAnimation, function () {
  93.                 window.location.hash = target;
  94.             });
  95.  
  96.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement