foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 9.79 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.accordion"),require("./foundation.core"),require("./foundation.tabs"),require("./foundation.util.mediaQuery"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.accordion","./foundation.core","./foundation.tabs","./foundation.util.mediaQuery","jquery"],e):"object"==typeof exports?exports["foundation.responsiveAccordionTabs"]=e(require("./foundation.accordion"),require("./foundation.core"),require("./foundation.tabs"),require("./foundation.util.mediaQuery"),require("jquery")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.responsiveAccordionTabs"]=e(t.__FOUNDATION_EXTERNAL__["foundation.accordion"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.tabs"],t.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],t.jQuery))}(window,function(n,o,r,i,a){return u={"./foundation.accordion":function(t,e){t.exports=n},"./foundation.core":function(t,e){t.exports=o},"./foundation.tabs":function(t,e){t.exports=r},"./foundation.util.mediaQuery":function(t,e){t.exports=i},"./js/entries/plugins/foundation.responsiveAccordionTabs.js":function(t,e,n){"use strict";n.r(e);var o=n("./foundation.core");n.d(e,"Foundation",function(){return o.Foundation});var r=n("./js/foundation.responsiveAccordionTabs.js");n.d(e,"ResponsiveAccordionTabs",function(){return r.ResponsiveAccordionTabs}),o.Foundation.plugin(r.ResponsiveAccordionTabs,"ResponsiveAccordionTabs")},"./js/foundation.responsiveAccordionTabs.js":function(t,e,n){"use strict";n.r(e),n.d(e,"ResponsiveAccordionTabs",function(){return y});var o=n("jquery"),c=n.n(o),i=n("./foundation.util.mediaQuery"),l=n("./foundation.core"),e=n("./foundation.accordion"),o=n("./foundation.tabs");function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(n){var o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=p(n);return d(this,o?(t=p(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function d(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h={tabs:{cssClass:"tabs",plugin:o.Tabs,open:function(t,e){return t.selectTab(e)},close:null,toggle:null},accordion:{cssClass:"accordion",plugin:e.Accordion,open:function(t,e){return t.down(c()(e))},close:function(t,e){return t.up(c()(e))},toggle:function(t,e){return t.toggle(c()(e))}}},y=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(r,l["Plugin"]);var t,e,n,o=u(r);function r(t,e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),d(e=o.call(this,t,e),e.options.reflow&&e.storezfData||f(e))}return t=r,(e=[{key:"_setup",value:function(t,e){this.$element=c()(t),this.$element.data("zfPluginBase",this),this.options=c.a.extend({},r.defaults,this.$element.data(),e),this.rules=this.$element.data("responsive-accordion-tabs"),this.currentMq=null,this.currentRule=null,this.currentPlugin=null,this.className="ResponsiveAccordionTabs",this.$element.attr("id")||this.$element.attr("id",Object(l.GetYoDigits)(6,"responsiveaccordiontabs")),this._init(),this._events()}},{key:"_init",value:function(){if(i.MediaQuery._init(),"string"==typeof this.rules){for(var t={},e=this.rules.split(" "),n=0;n<e.length;n++){var o=e[n].split("-"),r=1<o.length?o[0]:"small",o=1<o.length?o[1]:o[0];null!==h[o]&&(t[r]=h[o])}this.rules=t}this._getAllOptions(),c.a.isEmptyObject(this.rules)||this._checkMediaQueries()}},{key:"_getAllOptions",value:function(){for(var t in this.allOptions={},h)if(h.hasOwnProperty(t)){var e=h[t];try{var n,o,r=c()("<ul></ul>"),i=new e.plugin(r,this.options);for(n in i.options)i.options.hasOwnProperty(n)&&"zfPlugin"!==n&&(o=i.options[n],this.allOptions[n]=o);i.destroy()}catch(t){console.warn("Warning: Problems getting Accordion/Tab options: ".concat(t))}}}},{key:"_events",value:function(){this._changedZfMediaQueryHandler=this._checkMediaQueries.bind(this),c()(window).on("changed.zf.mediaquery",this._changedZfMediaQueryHandler)}},{key:"_checkMediaQueries",value:function(){var e,n=this;c.a.each(this.rules,function(t){i.MediaQuery.atLeast(t)&&(e=t)}),e&&(this.currentPlugin instanceof this.rules[e].plugin||(c.a.each(h,function(t,e){n.$element.removeClass(e.cssClass)}),this.$element.addClass(this.rules[e].cssClass),this.currentPlugin&&(!this.currentPlugin.$element.data("zfPlugin")&&this.storezfData&&this.currentPlugin.$element.data("zfPlugin",this.storezfData),this.currentPlugin.destroy()),this._handleMarkup(this.rules[e].cssClass),this.currentRule=this.rules[e],this.currentPlugin=new this.currentRule.plugin(this.$element,this.options),this.storezfData=this.currentPlugin.$element.data("zfPlugin")))}},{key:"_handleMarkup",value:function(t){var e,i,a,s,u,n=this,o="accordion",r=c()("[data-tabs-content="+this.$element.attr("id")+"]");(o=r.length?"tabs":o)!==t&&(e=n.allOptions.linkClass||"tabs-title",i=n.allOptions.panelClass||"tabs-panel",this.$element.removeAttr("role"),a=this.$element.children("."+e+",[data-accordion-item]").removeClass(e).removeClass("accordion-item").removeAttr("data-accordion-item"),s=a.children("a").removeClass("accordion-title"),"tabs"===o?(r=r.children("."+i).removeClass(i).removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby")).children("a").removeAttr("role").removeAttr("aria-controls").removeAttr("aria-selected"):r=a.children("[data-tab-content]").removeClass("accordion-content"),r.css({display:"",visibility:""}),a.css({display:"",visibility:""}),"accordion"===t?r.each(function(t,e){c()(e).appendTo(a.get(t)).addClass("accordion-content").attr("data-tab-content","").removeClass("is-active").css({height:""}),c()("[data-tabs-content="+n.$element.attr("id")+"]").after('<div id="tabs-placeholder-'+n.$element.attr("id")+'"></div>').detach(),a.addClass("accordion-item").attr("data-accordion-item",""),s.addClass("accordion-title")}):"tabs"===t&&(u=c()("[data-tabs-content="+n.$element.attr("id")+"]"),(t=c()("#tabs-placeholder-"+n.$element.attr("id"))).length?(u=c()('<div class="tabs-content"></div>').insertAfter(t).attr("data-tabs-content",n.$element.attr("id")),t.remove()):u=c()('<div class="tabs-content"></div>').insertAfter(n.$element).attr("data-tabs-content",n.$element.attr("id")),r.each(function(t,e){var n=c()(e).appendTo(u).addClass(i),o=s.get(t).hash.slice(1),r=c()(e).attr("id")||Object(l.GetYoDigits)(6,"accordion");o!==r&&(""!==o?c()(e).attr("id",o):(o=r,c()(e).attr("id",o),c()(s.get(t)).attr("href",c()(s.get(t)).attr("href").replace("#","")+"#"+o))),c()(a.get(t)).hasClass("is-active")&&n.addClass("is-active")}),a.addClass(e)))}},{key:"open",value:function(){var t;if(this.currentRule&&"function"==typeof this.currentRule.open)return(t=this.currentRule).open.apply(t,[this.currentPlugin].concat(Array.prototype.slice.call(arguments)))}},{key:"close",value:function(){var t;if(this.currentRule&&"function"==typeof this.currentRule.close)return(t=this.currentRule).close.apply(t,[this.currentPlugin].concat(Array.prototype.slice.call(arguments)))}},{key:"toggle",value:function(){var t;if(this.currentRule&&"function"==typeof this.currentRule.toggle)return(t=this.currentRule).toggle.apply(t,[this.currentPlugin].concat(Array.prototype.slice.call(arguments)))}},{key:"_destroy",value:function(){this.currentPlugin&&this.currentPlugin.destroy(),c()(window).off("changed.zf.mediaquery",this._changedZfMediaQueryHandler)}}])&&a(t.prototype,e),n&&a(t,n),r}();y.defaults={}},11:function(t,e,n){t.exports=n("./js/entries/plugins/foundation.responsiveAccordionTabs.js")},jquery:function(t,e){t.exports=a}},c={},s.m=u,s.c=c,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)s.d(n,o,function(t){return e[t]}.bind(null,o));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=11);function s(t){if(c[t])return c[t].exports;var e=c[t]={i:t,l:!1,exports:{}};return u[t].call(e.exports,e,e.exports,s),e.l=!0,e.exports}var u,c});
//# sourceMappingURL=foundation.responsiveAccordionTabs.min.js.map