1jQuery(document).ready(function($) { 2 3 4 /** 5 * Create container for menu link and append sub menu toggle button. (container needed to be able to center position the icon) 6 */ 7 $('.menu-item-has-children > a').wrap( '<div class="link-toggle-container"></div>'); 8 $('.link-toggle-container').append( '<button class="sub-menu-toggle"></button>'); 9 10 11 /** 12 * Action to take when sub menu button is clicked 13 */ 14 $( ".sub-menu-toggle" ).click(function() { 15 16 $(this).parent().toggleClass( 'activated' ); //* Add class to link-toggle-container for styling 17 $(this).parent().next( '.sub-menu' ).slideToggle( 'fast' ); //* Slide Toggle this menu item's sub menu. 18 19 //* Find sibling menu items so we can close their sub menu at the same time this menu items sub-menu is opened 20 var othermenus = $(this).closest( '.menu-item' ).siblings(); 21 22 othermenus.find( '.link-toggle-container' ).removeClass( 'activated' ); //* Remove the class that was added for styling 23 othermenus.find( '.sub-menu' ).slideUp( 'fast' ); //* Slide up sub-menus. 24 }); 25 26 /** 27 * Prevent styles breaking when changing window size 28 */ 29 $(window).resize(function() { 30 31 $( ".sub-menu" ).removeAttr("style"); 32 33 }); 34 35 /** 36 * Retrieve the color of the responsive menu links set in Oxygen (by adding fake element then removing, so we can use to make toggle buttons the same color 37 */ 38 var menuid = $(".oxy-nav-menu-responsive-dropdowns").attr('id'), //get the id of responsive menu 39 fakeelement = $("<div class='fake oxy-nav-menu oxy-nav-menu-open'><div class='menu-item'><a></a></div></div>"); //add fake element with same classes open menu items so JS can extract the color set by Oxygen. 40 41 fakeelement.appendTo('body'); //Add fake element 42 fakeelement.attr("id",menuid); // Give it the ID of menu 43 var color = $('.fake a').css('color'); // Retrieve the color that is added by Oxygen 44 fakeelement.remove(); // Remove fake element 45 46 $( ".sub-menu-toggle" ).css("color", color); // Give sub menu toggle this color, so it can be inherited. 47 48});
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.