You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. jQuery(document).ready(function($){
  2. var $lateral_menu_trigger = $('.nav-trigger'),
  3. $content_wrapper = $('.main');
  4. //open-close lateral menu clicking on the menu icon
  5. $lateral_menu_trigger.on('click', function(event){
  6. event.preventDefault();
  7. $lateral_menu_trigger.toggleClass('is-active');
  8. $content_wrapper.toggleClass('is-active').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
  9. // firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden
  10. $('body').toggleClass('overflow-hidden');
  11. });
  12. $('#nav-menu').toggleClass('is-active');
  13. //check if transitions are not supported - i.e. in IE9
  14. if($('html').hasClass('no-csstransitions')) {
  15. $('body').toggleClass('overflow-hidden');
  16. }
  17. });
  18. //close lateral menu clicking outside the menu itself
  19. $content_wrapper.on('mouseover', function(event){
  20. if( !$(event.target).is('.nav-trigger, .nav-trigger span') ) {
  21. $lateral_menu_trigger.removeClass('is-active');
  22. $content_wrapper.removeClass('is-active').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
  23. $('body').removeClass('overflow-hidden');
  24. });
  25. $('#nav-menu').removeClass('is-active');
  26. //check if transitions are not supported
  27. if($('html').hasClass('no-csstransitions')) {
  28. $('body').removeClass('overflow-hidden');
  29. }
  30. }
  31. });
  32. });