foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 6.01 kB
JavaScript
((e,t)=>{"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.util.motion")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.util.mediaQuery","./foundation.util.motion"],t):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=t(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.util.motion")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.responsiveToggle"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery,e.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],e.__FOUNDATION_EXTERNAL__["foundation.util.motion"]))})(self,function(t,o,n,i){return u={"./js/foundation.responsiveToggle.js":function(e,t,o){o.r(t),o.d(t,{ResponsiveToggle:function(){return n}});var t=o("jquery"),i=o.n(t),r=o("./foundation.util.mediaQuery"),u=o("./foundation.util.motion"),t=o("./foundation.core");function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(e=>(e=((e,t)=>{if("object"!=a(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);if("object"!=a(o=o.call(e,t||"default")))return o;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==a(e)?e:e+""))(n.key),n)}}function f(e,t,o){t=d(t);var n=e,t=l()?Reflect.construct(t,o||[],d(e).constructor):t.apply(e,o);if(!t||"object"!=a(t)&&"function"!=typeof t){if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(t=n))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var n=(e=>{function o(){var e=this,t=o;if(e instanceof t)return f(this,o,arguments);throw new TypeError("Cannot call a class as a function")}var t,n=o;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&c(n,e),n=o,(e=[{key:"_setup",value:function(e,t){this.$element=i()(e),this.options=i().extend({},o.defaults,this.$element.data(),t),this.className="ResponsiveToggle",this._init(),this._events()}},{key:"_init",value:function(){r.MediaQuery._init();var e,t=this.$element.data("responsive-toggle");t||console.error("Your tab bar needs an ID of a Menu as the value of data-tab-bar."),this.$targetMenu=i()("#".concat(t)),this.$toggler=this.$element.find("[data-toggle]").filter(function(){var e=i()(this).data("toggle");return e===t||""===e}),this.options=i().extend({},this.options,this.$targetMenu.data()),this.options.animate&&(e=this.options.animate.split(" "),this.animationIn=e[0],this.animationOut=e[1]||null),this._update()}},{key:"_events",value:function(){this._updateMqHandler=this._update.bind(this),i()(window).on("changed.zf.mediaquery",this._updateMqHandler),this.$toggler.on("click.zf.responsiveToggle",this.toggleMenu.bind(this))}},{key:"_update",value:function(){r.MediaQuery.atLeast(this.options.hideFor)?(this.$element.hide(),this.$targetMenu.show()):(this.$element.show(),this.$targetMenu.hide())}},{key:"toggleMenu",value:function(){var e=this;r.MediaQuery.atLeast(this.options.hideFor)||(this.options.animate?this.$targetMenu.is(":hidden")?u.Motion.animateIn(this.$targetMenu,this.animationIn,function(){e.$element.trigger("toggled.zf.responsiveToggle"),e.$targetMenu.find("[data-mutate]").triggerHandler("mutateme.zf.trigger")}):u.Motion.animateOut(this.$targetMenu,this.animationOut,function(){e.$element.trigger("toggled.zf.responsiveToggle")}):(this.$targetMenu.toggle(0),this.$targetMenu.find("[data-mutate]").trigger("mutateme.zf.trigger"),this.$element.trigger("toggled.zf.responsiveToggle")))}},{key:"_destroy",value:function(){this.$element.off(".zf.responsiveToggle"),this.$toggler.off(".zf.responsiveToggle"),i()(window).off("changed.zf.mediaquery",this._updateMqHandler)}}])&&s(n.prototype,e),t&&s(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n})(t.Plugin);n.defaults={hideFor:"medium",animate:!1}},"./foundation.core":function(e){e.exports=t},"./foundation.util.mediaQuery":function(e){e.exports=n},"./foundation.util.motion":function(e){e.exports=i},jquery:function(e){e.exports=o}},a={},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f={},(r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(f),r.d(f,{Foundation:function(){return e.Foundation},ResponsiveToggle:function(){return s.ResponsiveToggle}}),e=r("./foundation.core"),s=r("./js/foundation.responsiveToggle.js"),e.Foundation.plugin(s.ResponsiveToggle,"ResponsiveToggle"),f;function r(e){var t=a[e];return void 0!==t||(t=a[e]={exports:{}},u[e](t,t.exports,r)),t.exports}var u,a,e,s,f});
//# sourceMappingURL=foundation.responsiveToggle.min.js.map