3 lines
9.9 KiB
JavaScript
3 lines
9.9 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.imageLoader"),require("./foundation.util.keyboard"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","./foundation.core.plugin","./foundation.core.utils","./foundation.util.imageLoader","./foundation.util.keyboard","jquery"],e):"object"==typeof exports?exports["foundation.tabs"]=e(require("./foundation.core"),require("./foundation.core.plugin"),require("./foundation.core.utils"),require("./foundation.util.imageLoader"),require("./foundation.util.keyboard"),require("jquery")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.tabs"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.core"],t.__FOUNDATION_EXTERNAL__["foundation.util.imageLoader"],t.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"],t.jQuery))}(window,function(n,i,o,a,s,r){return function(n){var i={};function o(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}return o.m=n,o.c=i,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=18)}({"./foundation.core":function(t,e){t.exports=n},"./foundation.core.plugin":function(t,e){t.exports=i},"./foundation.core.utils":function(t,e){t.exports=o},"./foundation.util.imageLoader":function(t,e){t.exports=a},"./foundation.util.keyboard":function(t,e){t.exports=s},"./js/entries/plugins/foundation.tabs.js":function(t,e,n){"use strict";n.r(e);var i=n("./foundation.core");n.d(e,"Foundation",function(){return i.Foundation});var o=n("./js/foundation.tabs.js");n.d(e,"Tabs",function(){return o.Tabs}),i.Foundation.plugin(o.Tabs,"Tabs")},"./js/foundation.tabs.js":function(t,e,n){"use strict";n.r(e),n.d(e,"Tabs",function(){return o});var i=n("jquery"),r=n.n(i),l=n("./foundation.core.utils"),s=n("./foundation.util.keyboard"),c=n("./foundation.util.imageLoader"),a=n("./foundation.core.plugin");function u(t){return(u="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 f(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function d(t,e){return!e||"object"!==u(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var o=function(t){function n(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),d(this,h(n).apply(this,arguments))}var e,i,o;return 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&&p(t,e)}(n,a["Plugin"]),e=n,(i=[{key:"_setup",value:function(t,e){this.$element=t,this.options=r.a.extend({},n.defaults,this.$element.data(),e),this.className="Tabs",this._init(),s.Keyboard.register("Tabs",{ENTER:"open",SPACE:"open",ARROW_RIGHT:"next",ARROW_UP:"previous",ARROW_DOWN:"next",ARROW_LEFT:"previous"})}},{key:"_init",value:function(){var a=this,s=this;if(this._isInitializing=!0,this.$element.attr({role:"tablist"}),this.$tabTitles=this.$element.find(".".concat(this.options.linkClass)),this.$tabContent=r()('[data-tabs-content="'.concat(this.$element[0].id,'"]')),this.$tabTitles.each(function(){var t=r()(this),e=t.find("a"),n=t.hasClass("".concat(s.options.linkActiveClass)),i=e.attr("data-tabs-target")||e[0].hash.slice(1),o=e[0].id?e[0].id:"".concat(i,"-label"),a=r()("#".concat(i));t.attr({role:"presentation"}),e.attr({role:"tab","aria-controls":i,"aria-selected":n,id:o,tabindex:n?"0":"-1"}),a.attr({role:"tabpanel","aria-labelledby":o}),n&&(s._initialAnchor="#".concat(i)),n||a.attr("aria-hidden","true"),n&&s.options.autoFocus&&(s.onLoadListener=Object(l.onLoad)(r()(window),function(){r()("html, body").animate({scrollTop:t.offset().top},s.options.deepLinkSmudgeDelay,function(){e.focus()})}))}),this.options.matchHeight){var t=this.$tabContent.find("img");t.length?Object(c.onImagesLoaded)(t,this._setHeight.bind(this)):this._setHeight()}this._checkDeepLink=function(){var t=window.location.hash;if(!t.length){if(a._isInitializing)return;a._initialAnchor&&(t=a._initialAnchor)}var e=t&&r()(t),n=t&&a.$element.find('[href$="'+t+'"]'),i=!(!e.length||!n.length);if(e&&e.length&&n&&n.length?a.selectTab(e,!0):a._collapse(),i){if(a.options.deepLinkSmudge){var o=a.$element.offset();r()("html, body").animate({scrollTop:o.top},a.options.deepLinkSmudgeDelay)}a.$element.trigger("deeplink.zf.tabs",[n,e])}},this.options.deepLink&&this._checkDeepLink(),this._events(),this._isInitializing=!1}},{key:"_events",value:function(){this._addKeyHandler(),this._addClickHandler(),this._setHeightMqHandler=null,this.options.matchHeight&&(this._setHeightMqHandler=this._setHeight.bind(this),r()(window).on("changed.zf.mediaquery",this._setHeightMqHandler)),this.options.deepLink&&r()(window).on("hashchange",this._checkDeepLink)}},{key:"_addClickHandler",value:function(){var e=this;this.$element.off("click.zf.tabs").on("click.zf.tabs",".".concat(this.options.linkClass),function(t){t.preventDefault(),t.stopPropagation(),e._handleTabChange(r()(this))})}},{key:"_addKeyHandler",value:function(){var a=this;this.$tabTitles.off("keydown.zf.tabs").on("keydown.zf.tabs",function(t){if(9!==t.which){var e,n,i=r()(this),o=i.parent("ul").children("li");o.each(function(t){r()(this).is(i)&&(n=a.options.wrapOnKeys?(e=0===t?o.last():o.eq(t-1),t===o.length-1?o.first():o.eq(t+1)):(e=o.eq(Math.max(0,t-1)),o.eq(Math.min(t+1,o.length-1))))}),s.Keyboard.handleKey(t,"Tabs",{open:function(){i.find('[role="tab"]').focus(),a._handleTabChange(i)},previous:function(){e.find('[role="tab"]').focus(),a._handleTabChange(e)},next:function(){n.find('[role="tab"]').focus(),a._handleTabChange(n)},handled:function(){t.stopPropagation(),t.preventDefault()}})}})}},{key:"_handleTabChange",value:function(t,e){if(t.hasClass("".concat(this.options.linkActiveClass)))this.options.activeCollapse&&this._collapse();else{var n=this.$element.find(".".concat(this.options.linkClass,".").concat(this.options.linkActiveClass)),i=t.find('[role="tab"]'),o=i.attr("data-tabs-target"),a=o&&o.length?"#".concat(o):i[0].hash,s=this.$tabContent.find(a);this._collapseTab(n),this._openTab(t),this.options.deepLink&&!e&&(this.options.updateHistory?history.pushState({},"",a):history.replaceState({},"",a)),this.$element.trigger("change.zf.tabs",[t,s]),s.find("[data-mutate]").trigger("mutateme.zf.trigger")}}},{key:"_openTab",value:function(t){var e=t.find('[role="tab"]'),n=e.attr("data-tabs-target")||e[0].hash.slice(1),i=this.$tabContent.find("#".concat(n));t.addClass("".concat(this.options.linkActiveClass)),e.attr({"aria-selected":"true",tabindex:"0"}),i.addClass("".concat(this.options.panelActiveClass)).removeAttr("aria-hidden")}},{key:"_collapseTab",value:function(t){var e=t.removeClass("".concat(this.options.linkActiveClass)).find('[role="tab"]').attr({"aria-selected":"false",tabindex:-1});r()("#".concat(e.attr("aria-controls"))).removeClass("".concat(this.options.panelActiveClass)).attr({"aria-hidden":"true"})}},{key:"_collapse",value:function(){var t=this.$element.find(".".concat(this.options.linkClass,".").concat(this.options.linkActiveClass));t.length&&(this._collapseTab(t),this.$element.trigger("collapse.zf.tabs",[t]))}},{key:"selectTab",value:function(t,e){var n;(n="object"===u(t)?t[0].id:t).indexOf("#")<0&&(n="#".concat(n));var i=this.$tabTitles.has('[href$="'.concat(n,'"]'));this._handleTabChange(i,e)}},{key:"_setHeight",value:function(){var i=0,o=this;this.$tabContent.find(".".concat(this.options.panelClass)).css("height","").each(function(){var t=r()(this),e=t.hasClass("".concat(o.options.panelActiveClass));e||t.css({visibility:"hidden",display:"block"});var n=this.getBoundingClientRect().height;e||t.css({visibility:"",display:""}),i=i<n?n:i}).css("height","".concat(i,"px"))}},{key:"_destroy",value:function(){this.$element.find(".".concat(this.options.linkClass)).off(".zf.tabs").hide().end().find(".".concat(this.options.panelClass)).hide(),this.options.matchHeight&&null!=this._setHeightMqHandler&&r()(window).off("changed.zf.mediaquery",this._setHeightMqHandler),this.options.deepLink&&r()(window).off("hashchange",this._checkDeepLink),this.onLoadListener&&r()(window).off(this.onLoadListener)}}])&&f(e.prototype,i),o&&f(e,o),n}();o.defaults={deepLink:!1,deepLinkSmudge:!1,deepLinkSmudgeDelay:300,updateHistory:!1,autoFocus:!1,wrapOnKeys:!0,matchHeight:!1,activeCollapse:!1,linkClass:"tabs-title",linkActiveClass:"is-active",panelClass:"tabs-panel",panelActiveClass:"is-active"}},18:function(t,e,n){t.exports=n("./js/entries/plugins/foundation.tabs.js")},jquery:function(t,e){t.exports=r}})});
|
|
//# sourceMappingURL=foundation.tabs.min.js.map
|