!function(a){"use strict";function b(b,c,d){var h;this.options={group:c},a.extend(this.options,g,d),this.$element=b instanceof a?b:a(b),this.uid=++k,this.setup(),h=this.$element.data(e),f[this.options.group]||(f[this.options.group]={}),h||(h={}),h[this.options.group]||(f[this.options.group][this.uid]=this,h[this.options.group]=this,this.$element.data(e,h),this.bind(),this.init())}var c=[13,32],d=["a","div","figure","p","pre","blockquote","img","ins","del","output","span","summary"],e="contentToggle",f={},g={},h=a(document),i=navigator.userAgent.match(/iPad|iPhone/i),j=/[^a-z0-9_-]/gi,k=0;g={defaultState:null,globalClose:!1,independent:!1,noSelfClosing:!1,beforeCallback:null,triggerSelector:".js-contentToggle__trigger",triggerSelectorContext:!0,labelSelector:null,labelSelectorContext:!0,contentSelector:".js-contentToggle__content",contentSelectorContext:!0,elementClass:"is-open",triggerClass:"is-active",openedLabel:null,closedLabel:null,toggleProperties:["height"],toggleOptions:{duration:0}},b.prototype.setup=function(){this.setupDataOptions(),this.options.group&&(this.options.group=this.options.group.toString().replace(j,"")),"string"==typeof this.options.toggleProperties&&(this.options.toggleProperties=JSON.parse(this.options.toggleProperties)),"string"==typeof this.options.toggleOptions&&(this.options.toggleOptions=JSON.parse(this.options.toggleOptions)),this.options.triggerSelectorContext?this.$triggers=a(this.options.triggerSelector,this.$element):this.$triggers=a(this.options.triggerSelector),0===this.$triggers.length&&(this.$triggers=this.$element),this.options.labelSelector?this.options.labelSelectorContext?this.$labels=a(this.options.labelSelector,this.$element):this.$labels=a(this.options.labelSelector):this.$labels=this.$triggers,this.options.contentSelectorContext?this.$contents=a(this.options.contentSelector,this.$element):this.$contents=a(this.options.contentSelector),"string"==typeof this.options.beforeCallback&&window[this.options.beforeCallback]&&"function"==typeof window[this.options.beforeCallback]?this.options.beforeCallback=window[this.options.beforeCallback].bind(this):"function"==typeof this.options.beforeCallback&&(this.options.beforeCallback=this.options.beforeCallback.bind(this))},b.prototype.setupDataOptions=function(){a.each(this.$element.data(),function(a,b){a in g&&(this.options[a]=b)}.bind(this))},b.prototype.bind=function(){var b="."+e+"."+this.options.group,d=i&&this.options.globalClose?"touchstart":"click",f=this.$element.add(this.$triggers).add(this.$contents);f.on("destroy"+b,this.destroy.bind(this)),f.on("toggle"+b,a.proxy(this.toggle,this,null)),f.on("close"+b,a.proxy(this.toggle,this,!1)),f.on("open"+b,a.proxy(this.toggle,this,!0)),f.on("isOpen"+b,function(){return this.isOpen}.bind(this)),this.$triggers.on(d+b,function(a){a.preventDefault(),a.originalEvent.mozInputSource&&a.originalEvent.mozInputSource===MouseEvent.MOZ_SOURCE_KEYBOARD||this.toggle(null,a)}.bind(this)),this.$triggers.on("keydown"+b,function(b){-1!==a.inArray(b.keyCode,c)&&(b.preventDefault(),this.toggle(null,b))}.bind(this)),this.$contents.on(d+b,function(a){a.stopPropagation()})},b.prototype.init=function(){this.tid=[],this.$triggers.each(a.proxy(this.initId,this,this.tid,"contentToggle__trigger")),this.cid=[],this.$contents.each(a.proxy(this.initId,this,this.cid,"contentToggle__content")),this.$triggers.each(function(b,c){var e=this.$triggers.eq(b);e.attr("role")||-1===a.inArray(c.tagName.toLowerCase(),d)||e.attr("role","button"),e.attr("tabindex")||e.attr("tabindex","0")}.bind(this)),this.$triggers.attr("aria-controls",this.cid.join(" ")),-1!==a.inArray(this.options.defaultState,["open","close"])?this.$element.trigger(this.options.defaultState+"."+e):(this.isOpen=this.$contents.is(":visible"),this.update())},b.prototype.initId=function(b,c,d,e){var f=a(e);b[d]=f.attr("id"),b[d]||(b[d]=c+"-"+this.uid+"-"+d,f.attr("id",b[d]))},b.prototype.toggle=function(b,c){c.stopPropagation(),"boolean"!=typeof b&&(b=!this.isOpen),this.$currentTrigger=null,this.$triggers.is(c.currentTarget)&&(this.$currentTrigger=a(c.currentTarget)),(!this.options.beforeCallback||"function"==typeof this.options.beforeCallback&&this.options.beforeCallback(c))&&(b?this.open():this.options.noSelfClosing||this.close())},b.prototype.open=function(){var a;this.isOpen!==!0&&(this.isOpen=!0,this["do"](),this.closeAll(!0),this.options.globalClose&&(a=i?"touchstart":"click",h.on(a+"."+e+this.uid,function(){this.closeAll()}.bind(this))))},b.prototype.close=function(){this.isOpen!==!1&&(this.isOpen=!1,this["do"](),h.off("."+e+this.uid))},b.prototype.closeAll=function(b){this.options.independent||a.each(f[this.options.group],function(a,b){a!==this.uid&&b.close()}.bind(this)),b||this.close()},b.prototype["do"]=function(){var b={},c=this.isOpen?"show":"hide";this.update(),a.each(this.options.toggleProperties,function(a,d){b[d]=c}),this.$contents.stop().animate(b,this.options.toggleOptions)},b.prototype.update=function(){this.isOpen?(this.$element.addClass(this.options.elementClass),this.$contents.attr("aria-hidden",!1),this.$triggers.attr("aria-expanded",!0),this.$currentTrigger?this.$currentTrigger.addClass(this.options.triggerClass):this.$triggers.addClass(this.options.triggerClass),"string"==typeof this.options.openedLabel&&this.$labels.html(this.options.openedLabel)):(this.$element.removeClass(this.options.elementClass),this.$contents.attr("aria-hidden",!0),this.$triggers.attr("aria-expanded",!1),this.$triggers.removeClass(this.options.triggerClass),"string"==typeof this.options.closedLabel&&this.$labels.html(this.options.closedLabel))},b.prototype.destroy=function(){this.$element.removeData(e),this.$element.off("."+e),this.$triggers.off("."+e),this.$contents.off("."+e),h.off("."+e+this.uid)},a.fn[e]=function(a){var c=this.selector;return this.each(function(){new b(this,c,a)})}}(jQuery);