Advertisement
Guest User

Untitled

a guest
Jun 1st, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function($){
  2.  
  3.     /* Responsive Menu */
  4.     $('.hide-menu').hide();
  5.     $('#learn-now').click(function(event){
  6.         event.preventDefault();
  7.         if ($('.post-container').offset()) {
  8.             $('html,body').animate({scrollTop: $('.post-container').offset().top}, 500);
  9.         }
  10.     });
  11.    
  12.     /* Main menu toggle and expand */
  13.     $('#toggle-menu').click(function(){
  14.        
  15.         // Grab the menu container
  16.         var el = $('#menu-container');
  17.        
  18.         // If the menu is currently expanded
  19.         if(el.height() > 10)
  20.         {
  21.             // Shrink the menu to 1px. The 1px is to show the border
  22.             curHeight = el.height();
  23.             el.height(curHeight).animate({height: '1px'}, 300);
  24.             // Toggle the menu toggle text
  25.             $('#toggle-menu .show-menu').show();
  26.             $('#toggle-menu .hide-menu').hide();
  27.         }
  28.         else
  29.         {
  30.             // Expand the menu to its normal height
  31.             curHeight = el.height();
  32.             autoHeight = el.css('height', 'auto').height();
  33.             el.height(curHeight).animate({height: autoHeight}, 300);
  34.             // Toggle the menu toggle text
  35.             $('#toggle-menu .show-menu').hide();
  36.             $('#toggle-menu .hide-menu').show();
  37.         }
  38.     });
  39.    
  40.     // Grab the initial window width
  41.     var windowWidth = $(window).width();
  42.    
  43.     window.onresize = function() {
  44.        
  45.         // If the window has been resized to a mobile size from a desktop size
  46.         if ($(window).width() < 767 && windowWidth >= 767) {
  47.            
  48.             // Update window width
  49.             windowWidth = $(window).width();
  50.            
  51.             // Hide the menu toggle and set the menu's height to hide it
  52.             $('#menu-container').css('height', '1px');
  53.             $('#toggle-menu .show-menu').show();
  54.             $('#toggle-menu .hide-menu').hide();
  55.         }
  56.         else if($(window).width() >= 767 && windowWidth < 767) {
  57.        
  58.             // Update window width
  59.             windowWidth = $(window).width();
  60.            
  61.             // Reset the menu height
  62.             $('#menu-container').css('height', 'auto');
  63.         }
  64.     };
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement