1/** 2 * MuffinMenu 3 * 4 * Horizontal Multilevel Menu with WP MegaMenu Support 5 * 3.0 | Muffin Group 6 */ 7 8(function($) { 9 10 /* globals jQuery */ 11 12 "use strict"; 13 14 $.fn.mfnMenu = function(options) { 15 16 var menu = $(this); 17 18 var defaults = { 19 addLast: false, 20 arrows: false, 21 delay: 100, 22 hoverClass: 'hover', 23 mobileInit: 768, 24 responsive: true 25 }; 26 options = $.extend(defaults, options); 27 28 var init = function() { 29 30 // add '.submenu' class 31 32 $('li:has(ul)', menu).addClass('submenu'); 33 34 // append mobile toggle button 35 36 $('li:has(ul)', menu).append('<a class="menu-toggle" href="#" aria-label="'+ mfn.accessibility.translation.toggleSubmenu +'"></a>').on('click', '.menu-toggle', function(e){ 37 38 e.preventDefault(); 39 40 // FIX | Header Creative dropdown scroll - nicescroll init 41 if( $('#Header_creative.dropdown.scroll').length ){ 42 $('#Header_creative').css('overflow-y','visible').css('overflow-y','hidden'); 43 } 44 }); 45 46 // add '.mfn-megamenu-parent' class 47 48 menu.children('li:has( ul.mfn-megamenu )').addClass('mfn-megamenu-parent'); 49 50 // add '.last-item' class 51 52 $('.submenu ul li:last-child', menu).addClass('last-item'); 53 54 // add '.last' class 55 56 if (options.addLast) { 57 $('> li:last-child', menu).addClass('last') 58 .prev().addClass('last'); 59 } 60 61 // appand submenu arrows 62 63 if (options.arrows) { 64 $('li ul li:has(ul) > a', menu).append('<i class="menu-arrow icon-right-open"></i>'); 65 } 66 67 }; 68 69 var doMenu = function() { 70 71 if ((window.innerWidth >= options.mobileInit) || (!options.responsive)) { 72 73 // desktop 74 75 $('> li, ul:not(.mfn-megamenu) li', menu).on('mouseenter', function() { 76 77 $(this).stop(true, true).addClass(options.hoverClass); 78 79 $(this).children('ul').stop(true, true).fadeIn(options.delay); 80 81 82 }).on('mouseleave', function() { 83 84 $(this).stop(true, true).removeClass(options.hoverClass); 85 86 $(this).children('ul').stop(true, true).fadeOut(options.delay); 87 88 }); 89 90 } else { 91 92 // mobile 93 94 $('li', menu).off('hover'); 95 96 $('li > .menu-toggle', menu).off('click').on('click', function(e) { 97 98 e.preventDefault(); 99 100 var el = $(this).closest('li'); 101 102 if (el.hasClass(options.hoverClass)) { 103 104 el.removeClass(options.hoverClass) 105 .children('ul').stop(true, true).fadeOut(options.delay); 106 107 } else { 108 109 el.addClass(options.hoverClass) 110 .children('ul').stop(true, true).fadeIn(options.delay); 111 112 } 113 114 }); 115 116 } 117 118 }; 119 120 $(window).on('resize', doMenu); 121 122 var __constructor = function() { 123 init(); 124 doMenu(); 125 }; 126 127 __constructor(); 128 129 }; 130 131})(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.