EduardET

Untitled

Mar 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. (function($) {
  3.      
  4.     function setup_collapsible_submenus() {
  5.         var $menu = $('#mobile_menu'),
  6.             top_level_link = '#mobile_menu .menu-item-has-children > a';
  7.              
  8.         $menu.find('a').each(function() {
  9.             $(this).off('click');
  10.              
  11.             if ( $(this).is(top_level_link) ) {
  12.                 $(this).attr('href', '#');
  13.             }
  14.              
  15.             if ( ! $(this).siblings('.sub-menu').length ) {
  16.                 $(this).on('click', function(event) {
  17.                     $(this).parents('.mobile_nav').trigger('click');
  18.                 });
  19.             } else {
  20.                 $(this).on('click', function(event) {
  21.                     event.preventDefault();
  22.                     $(this).parent().toggleClass('visible');
  23.                 });
  24.             }
  25.         });
  26.     }
  27.      
  28.     $(window).load(function() {
  29.         setTimeout(function() {
  30.             setup_collapsible_submenus();
  31.         }, 700);
  32.     });
  33.  
  34. })(jQuery);
  35. </script>
Add Comment
Please, Sign In to add comment