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 29 var init = function() { 30 31 // add '.submenu' class 32 33 $('li:has(ul)', menu).addClass('submenu'); 34 35 // append mobile toggle button 36 37 $('li:has(ul)', menu).append('<span class="menu-toggle"></span>'); 38 39 // add '.mfn-megamenu-parent' class 40 41 menu.children('li:has( ul.mfn-megamenu )').addClass('mfn-megamenu-parent'); 42 43 // add '.last-item' class 44 45 $('.submenu ul li:last-child', menu).addClass('last-item'); 46 47 // add '.last' class 48 49 if (options.addLast) { 50 $('> li:last-child', menu).addClass('last') 51 .prev().addClass('last'); 52 } 53 54 // appand submenu arrows 55 56 if (options.arrows) { 57 $('li ul li:has(ul) > a', menu).append('<i class="menu-arrow icon-right-open"></i>'); 58 } 59 60 }; 61 62 var doMenu = function() { 63 64 if ((window.innerWidth >= options.mobileInit) || (!options.responsive)) { 65 66 // desktop 67 68 $('> li, ul:not(.mfn-megamenu) li', menu).on('mouseenter', function() { 69 70 $(this).stop(true, true).addClass(options.hoverClass); 71 72 $(this).children('ul').stop(true, true).fadeIn(options.delay); 73 74 75 }).on('mouseleave', function() { 76 77 $(this).stop(true, true).removeClass(options.hoverClass); 78 79 $(this).children('ul').stop(true, true).fadeOut(options.delay); 80 81 }); 82 83 } else { 84 85 // mobile 86 87 $('li', menu).off('hover'); 88 89 $('li > .menu-toggle', menu).off('click').on('click', function() { 90 91 var el = $(this).closest('li'); 92 93 if (el.hasClass(options.hoverClass)) { 94 95 el.removeClass(options.hoverClass) 96 .children('ul').stop(true, true).fadeOut(options.delay); 97 98 } else { 99 100 el.addClass(options.hoverClass) 101 .children('ul').stop(true, true).fadeIn(options.delay); 102 103 } 104 105 }); 106 107 } 108 109 }; 110 111 $(window).on('resize', doMenu); 112 113 var __constructor = function() { 114 init(); 115 doMenu(); 116 }; 117 118 __constructor(); 119 120 }; 121 122})(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.