UNPKG

foundation-sites

Version:

The most advanced responsive front-end framework in the world.

3 lines (2 loc) 9.37 kB
((t,e)=>{"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.accordion"),require("./foundation.tabs")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery","./foundation.util.mediaQuery","./foundation.accordion","./foundation.tabs"],e):"object"==typeof exports?exports.__FOUNDATION_EXTERNAL__=e(require("./foundation.core"),require("jquery"),require("./foundation.util.mediaQuery"),require("./foundation.accordion"),require("./foundation.tabs")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.responsiveAccordionTabs"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery,t.__FOUNDATION_EXTERNAL__["foundation.util.mediaQuery"],t.__FOUNDATION_EXTERNAL__["foundation.accordion"],t.__FOUNDATION_EXTERNAL__["foundation.tabs"]))})(self,function(e,n,o,r,i){return s={"./js/foundation.responsiveAccordionTabs.js":function(t,e,n){n.r(e),n.d(e,{ResponsiveAccordionTabs:function(){return o}});var e=n("jquery"),c=n.n(e),i=n("./foundation.util.mediaQuery"),l=n("./foundation.core"),e=n("./foundation.accordion"),n=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,(t=>(t=((t,e)=>{if("object"!=r(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);if("object"!=r(n=n.call(t,e||"default")))return n;throw new TypeError("@@toPrimitive must return a primitive value.")})(t,"string"),"symbol"==r(t)?t:t+""))(o.key),o)}}function s(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");e=t;if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(u=function(){return!!t})()}function d(t){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}var p={tabs:{cssClass:"tabs",plugin:n.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))}}},o=(t=>{function o(t,e){var n;if(this instanceof o)return n=this,t=[t,e],e=d(e=o),e=s(n,u()?Reflect.construct(e,t||[],d(n).constructor):e.apply(n,t)),s(e,e.options.reflow&&e.storezfData||e);throw new TypeError("Cannot call a class as a function")}var e,n=o;if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),t&&f(n,t),n=o,(t=[{key:"_setup",value:function(t,e){this.$element=c()(t),this.$element.data("zfPluginBase",this),this.options=c().extend({},o.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",(0,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!==p[o]&&(t[r]=p[o])}this.rules=t}this._getAllOptions(),c().isEmptyObject(this.rules)||this._checkMediaQueries()}},{key:"_getAllOptions",value:function(){for(var t in this.allOptions={},p)if(p.hasOwnProperty(t)){t=p[t];try{var e,n,o=c()("<ul></ul>"),r=new t.plugin(o,this.options);for(e in r.options)r.options.hasOwnProperty(e)&&"zfPlugin"!==e&&(n=r.options[e],this.allOptions[e]=n);r.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().each(this.rules,function(t){i.MediaQuery.atLeast(t)&&(e=t)}),!e||this.currentPlugin instanceof this.rules[e].plugin||(c().each(p,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")+"]"),(o=c()("#tabs-placeholder-"+n.$element.attr("id"))).length?(u=c()('<div class="tabs-content"></div>').insertAfter(o).attr("data-tabs-content",n.$element.attr("id")),o.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")||(0,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(n.prototype,t),e&&a(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n})(l.Plugin);o.defaults={}},"./foundation.accordion":function(t){t.exports=r},"./foundation.core":function(t){t.exports=e},"./foundation.tabs":function(t){t.exports=i},"./foundation.util.mediaQuery":function(t){t.exports=o},jquery:function(t){t.exports=n}},u={},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l={},(a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})})(l),a.d(l,{Foundation:function(){return t.Foundation},ResponsiveAccordionTabs:function(){return c.ResponsiveAccordionTabs}}),t=a("./foundation.core"),c=a("./js/foundation.responsiveAccordionTabs.js"),t.Foundation.plugin(c.ResponsiveAccordionTabs,"ResponsiveAccordionTabs"),l;function a(t){var e=u[t];return void 0!==e||(e=u[t]={exports:{}},s[t](e,e.exports,a)),e.exports}var s,u,t,c,l}); //# sourceMappingURL=foundation.responsiveAccordionTabs.min.js.map