1( function( $ ) { 2 var CLASS_TOGGLE_ITEM = 'dcmm-menu-toggle', 3 CLASS_MENU_ENABLED = 'dcmm-collapsible', 4 CLASS_SUBMENU_OPENED = 'dcmm-visible'; 5 6 7 // Sets up the mobile menu to be collapsible 8 function setup_collapsible_submenus() { 9 $( '#mobile_menu' ) 10 .addClass( CLASS_MENU_ENABLED ) 11 .find( '.menu-item-has-children > a' ) 12 // For parent items with no link, make the entire link a toggle click target 13 // NOTE: Do this first so `off()` does not remove the toggle handler below 14 .filter( '[href="#"]' ) 15 .off( 'click' ) // removing Divi's handler that closes the menu 16 .on ( 'click', function( event ) { 17 event.preventDefault(); 18 event.stopPropagation(); 19 20 $( this ).children( '.' + CLASS_TOGGLE_ITEM ).trigger( 'click' ); 21 } ) 22 .end() 23 // ...now add the toggle element and handler 24 .append( '<span class="' + CLASS_TOGGLE_ITEM + '"></span>' ) 25 .on( 'click', '.' + CLASS_TOGGLE_ITEM, function( event ) { 26 event.preventDefault(); 27 event.stopPropagation(); 28 29 $( this ).closest( '.menu-item' ).toggleClass( CLASS_SUBMENU_OPENED ); 30 } ); 31 } 32 33 // Wait until after the Divi mobile menu has been initialized 34 $( window ).on( 'load', function() { 35 setTimeout( function() { 36 setup_collapsible_submenus(); 37 }, 700 ); 38 } ); 39} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.