Skip to content

Instantly share code, notes, and snippets.

@wpexplorer
Created July 29, 2021 20:45
Show Gist options
  • Save wpexplorer/95ad7b5e5779fc68a8816c323f5f9976 to your computer and use it in GitHub Desktop.
Save wpexplorer/95ad7b5e5779fc68a8816c323f5f9976 to your computer and use it in GitHub Desktop.
!function(n){"use strict";var e,s,r,o,t,i,a,h,l,p,f,u,c,d,v,m,y,C=(r="sf-breadcrumb",o="sf-js-enabled",t="sf-with-ul",i="sf-arrows",(s=/iPhone|iPad|iPod/i.test(navigator.userAgent))&&n("html").css("cursor","pointer").on("click",n.noop),a=s,h="behavior"in(e=document.documentElement.style)&&"fill"in e&&/iemobile/i.test(navigator.userAgent),l=function(e,s){var t=o;s.cssArrows&&(t+=" "+i),e.toggleClass(t)},p=function(e){e.children("a").toggleClass(t)},f=function(e){var s=e.css("ms-touch-action");s="pan-y"===s?"auto":"pan-y",e.css("ms-touch-action",s)},u=function(e){var s=n(this),t=s.siblings(e.data.popUpSelector);0<t.length&&t.is(":hidden")&&(s.one("click.superfish",!1),"MSPointerDown"===e.type?s.trigger("focus"):n.proxy(c,s.parent("li"))())},c=function(){var e=n(this),s=y(e);clearTimeout(s.sfTimer),e.siblings().superfish("hide").end().superfish("show")},d=function(){var e=n(this),s=y(e);a?n.proxy(v,e,s)():(clearTimeout(s.sfTimer),s.sfTimer=setTimeout(n.proxy(v,e,s),s.delay))},v=function(e){e.retainPath=-1<n.inArray(this[0],e.$path),this.superfish("hide"),this.parents("."+e.hoverClass).length||(e.onIdle.call(m(this)),e.$path.length&&n.proxy(c,e.$path)())},m=function(e){return e.closest("."+o)},y=function(e){return m(e).data("sf-options")},{hide:function(e){if(this.length){var s=y(this);if(!s)return this;var t=!0===s.retainPath?s.$path:"",o=this.find("li."+s.hoverClass).add(this).not(t).removeClass(s.hoverClass).children(s.popUpSelector),i=s.speedOut;e&&(o.show(),i=0),s.retainPath=!1,s.onBeforeHide.call(o),o.stop(!0,!0).animate(s.animationOut,i,function(){var e=n(this);s.onHide.call(e)})}return this},show:function(){var e=y(this);if(!e)return this;var s=this.addClass(e.hoverClass).children(e.popUpSelector);return e.onBeforeShow.call(s),s.stop(!0,!0).animate(e.animation,e.speed,function(){e.onShow.call(s)}),this},destroy:function(){return this.each(function(){var e,s=n(this),t=s.data("sf-options");if(!t)return!1;e=s.find(t.popUpSelector).parent("li"),clearTimeout(t.sfTimer),l(s,t),p(e),f(s),s.off(".superfish").off(".hoverIntent"),e.children(t.popUpSelector).attr("style",function(e,s){return s.replace(/display[^;]+;?/g,"")}),t.$path.removeClass(t.hoverClass+" "+r).addClass(t.pathClass),s.find("."+t.hoverClass).removeClass(t.hoverClass),t.onDestroy.call(s),s.removeData("sf-options")})},init:function(i){return this.each(function(){var e=n(this);if(e.data("sf-options"))return!1;var s,t=n.extend({},n.fn.superfish.defaults,i),o=e.find(t.popUpSelector).parent("li");t.$path=(s=t,e.find("li."+s.pathClass).slice(0,s.pathLevels).addClass(s.hoverClass+" "+r).filter(function(){return n(this).children(s.popUpSelector).hide().show().length}).removeClass(s.pathClass)),e.data("sf-options",t),l(e,t),p(o),f(e),function(e,s){var t="li:has("+s.popUpSelector+")";n.fn.hoverIntent&&!s.disableHI?e.hoverIntent(c,d,t):e.on("mouseenter.superfish",t,c).on("mouseleave.superfish",t,d);var o="MSPointerDown.superfish";a||(o+=" touchend.superfish"),h&&(o+=" mousedown.superfish"),e.on("focusin.superfish","li",c).on("focusout.superfish","li",d).on(o,"a",s,u)}(e,t),o.not("."+r).superfish("hide",!0),t.onInit.call(this)})}});n.fn.superfish=function(e,s){return C[e]?C[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?n.error("Method "+e+" does not exist on jQuery.fn.superfish"):C.init.apply(this,arguments)},n.fn.superfish.defaults={popUpSelector:"ul,.sf-mega",hoverClass:"sfHover",pathClass:"overrideThisToUse",pathLevels:1,delay:800,animation:{opacity:"show"},animationOut:{opacity:"hide"},speed:"normal",speedOut:"fast",cssArrows:!0,disableHI:!1,onInit:n.noop,onBeforeShow:n.noop,onShow:n.noop,onBeforeHide:n.noop,onHide:n.noop,onIdle:n.noop,onDestroy:n.noop},n.fn.extend({hideSuperfishUl:C.hide,showSuperfishUl:C.show})}(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment