jQuery.fn.jetmenu = function (i) { function n() { window.innerWidth <= 991 ? (s(), d()) : (o(), e()) } function e() { navigator.userAgent.match(/Mobi/i) || window.navigator.msMaxTouchPoints > 0 ? ($(l).find("a").on("click touchstart", function (i) { i.stopPropagation(), i.preventDefault(), window.location.href = $(this).attr("href"), $(this).parent("li").siblings("li").find(".dropdown, .megamenu").stop(!0, !0).fadeOut(h.speed), "none" == $(this).siblings(".dropdown, .megamenu").css("display") ? $(this).siblings(".dropdown, .megamenu").stop(!0, !0).fadeIn(h.speed) : ($(this).siblings(".dropdown, .megamenu").stop(!0, !0).fadeOut(h.speed), $(this).siblings(".dropdown").find(".dropdown").stop(!0, !0).fadeOut(h.speed)) }), 1 == h.hideClickOut && $(document).bind("click.menu touchstart.menu", function (i) { 0 == $(i.target).closest(l).length && $(l).find(".dropdown, .megamenu").fadeOut(h.speed) })) : $(l).find("li").bind("mouseenter", function () { $(this).children(".dropdown, .megamenu").stop(!0, !0).fadeIn(h.speed) }).bind("mouseleave", function () { $(this).children(".dropdown, .megamenu").stop(!0, !0).fadeOut(h.speed) }) } function d() { $(l).find("li:not(.showhide)").each(function () { $(this).children(".dropdown, .megamenu").length > 0 && $(this).children("a").bind("click", function () { $(this).siblings(".dropdown, .megamenu").hasClass("menu-visible") ? ($(this).siblings(".dropdown, .megamenu").slideUp(h.speed), $(this).siblings(".dropdown, .megamenu").removeClass("menu-visible")) : ($(this).siblings(".dropdown, .megamenu").slideDown(h.speed), $(this).siblings(".dropdown, .megamenu").addClass("menu-visible"), firstItemClick = 1) }) }) } function s() { $(l).children("li:not(.showhide)").hide(0), $(l).children("li.showhide").show(0), $(l).children("li.showhide").bind("click", function () { $(l).children("li").is(":hidden") ? ($(l).children("li").slideDown(h.speed), $(l).children("li.showhide").detach().addClass("shown").insertAfter(".menu-for-publishers")) : ($(l).children("li:not(.showhide)").slideUp(h.speed), $(l).children("li.showhide").show(0), $(l).children("li.showhide").detach().removeClass("shown").insertBefore(".jetmenu li:first-child")) }) } function o() { $(l).children("li").show(0), $(l).children("li.showhide").hide(0) } function t() { $(l).find("li, a").unbind(), $(document).unbind("click.menu touchstart.menu"), $(l).find(".dropdown, .megamenu").hide(0) } var h = { indicator: !0, speed: 300, hideClickOut: !0 }; $.extend(h, i); var l = $(".jetmenu"), a = window.innerWidth; 1 == h.indicator && $(l).find("a").each(function () { $(this).siblings(".dropdown, .megamenu").length > 0 && $(this).append("<span class='indicator'>+</span>") }), $(l).prepend("<li class='showhide'><span class='title'>MENU</span><span class='icon'><em></em><em></em><em></em><em></em></span></li>"), n(), $(window).resize(function () { 991 >= a && window.innerWidth > 991 && (t(), o(), e()), a > 991 && window.innerWidth <= 991 && (t(), s(), d()), a = window.innerWidth }) };