(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else if(typeof exports==="object"){module.exports=e(require("jquery"))}else{e(jQuery)}})(function(d){"use strict";var n="readmore",i={speed:100,collapsedHeight:200,heightMargin:16,moreLink:'<a href="#">Read More</a>',lessLink:'<a href="#">Close</a>',embedCSS:true,blockCSS:"display: block; width: 100%;",startOpen:false,blockProcessed:function(){},beforeToggle:function(){},afterToggle:function(){}},o={},a=0;function e(n,a,s){var r;return function(){var e=this,t=arguments;var i=function(){r=null;if(!s){n.apply(e,t)}};var o=s&&!r;clearTimeout(r);r=setTimeout(i,a);if(o){n.apply(e,t)}}}function s(e){var t=++a;return String(!e?"rmjs-":e)+t}function r(e){var t=e.clone().css({height:"auto",width:e.width(),maxHeight:"none",overflow:"hidden"}).insertAfter(e),i=t.outerHeight(),o=parseInt(t.css({maxHeight:""}).css("max-height").replace(/[^-\d\.]/g,""),10),n=e.data("defaultHeight");t.remove();var a=o||e.data("collapsedHeight")||n;e.data({expandedHeight:i,maxHeight:o,collapsedHeight:a}).css({maxHeight:"none"})}var l=e(function(){d("[data-readmore]").each(function(){var e=d(this),t=e.attr("aria-expanded")==="true";r(e);e.css({height:e.data(t?"expandedHeight":"collapsedHeight")})})},100);function h(e){if(!o[e.selector]){var t=" ";if(e.embedCSS&&e.blockCSS!==""){t+=e.selector+" + [data-readmore-toggle], "+e.selector+"[data-readmore]{"+e.blockCSS+"}"}t+=e.selector+"[data-readmore]{"+"transition: height "+e.speed+"ms;"+"overflow: hidden;"+"}";(function(e,t){var i=e.createElement("style");i.type="text/css";if(i.styleSheet){i.styleSheet.cssText=t}else{i.appendChild(e.createTextNode(t))}e.getElementsByTagName("head")[0].appendChild(i)})(document,t);o[e.selector]=true}}function c(e,t){this.element=e;this.options=d.extend({},i,t);this.options=d.extend(this.options,d(this.element).data()||{});h(this.options);this._defaults=i;this._name=n;this.init();if(window.addEventListener){window.addEventListener("load",l);window.addEventListener("resize",l)}else{window.attachEvent("load",l);window.attachEvent("resize",l)}}c.prototype={init:function(){var i=d(this.element);i.data({defaultHeight:this.options.collapsedHeight,heightMargin:this.options.heightMargin});r(i);var e=i.data("collapsedHeight"),t=i.data("heightMargin");if(i.outerHeight(true)<=e+t){if(this.options.blockProcessed&&typeof this.options.blockProcessed==="function"){this.options.blockProcessed(i,false)}return true}else{var o=i.attr("id")||s(),n=this.options.startOpen?typeof this.options.startOpen=="function"?this.options.startOpen.apply(this,[i]):true:false,a=n?this.options.lessLink:this.options.moreLink;i.attr({"data-readmore":"","aria-expanded":n,id:o});i.after(d(a).on("click",function(t){return function(e){t.toggle(this,i[0],e)}}(this)).attr({"data-readmore-toggle":o,"aria-controls":o}));if(!n){i.css({height:e})}if(this.options.blockProcessed&&typeof this.options.blockProcessed==="function"){this.options.blockProcessed(i,true)}}},toggle:function(t,i,e){if(e){e.preventDefault()}if(!t){t=d('[aria-controls="'+this.element.id+'"]')[0]}if(!i){i=this.element}var o=d(i),n="",a="",s=false,r=o.data("collapsedHeight");if(o.height()<=r){n=o.data("expandedHeight")+"px";a="lessLink";s=true}else{n=r;a="moreLink"}if(this.options.beforeToggle&&typeof this.options.beforeToggle==="function"){this.options.beforeToggle(t,o,!s)}o.css({height:n});o.on("transitionend",function(e){return function(){if(e.options.afterToggle&&typeof e.options.afterToggle==="function"){e.options.afterToggle(t,o,s)}d(this).attr({"aria-expanded":s}).off("transitionend")}}(this));d(t).replaceWith(d(this.options[a]).on("click",function(t){return function(e){t.toggle(this,i,e)}}(this)).attr({"data-readmore-toggle":o.attr("id"),"aria-controls":o.attr("id")}))},destroy:function(){d(this.element).each(function(){var e=d(this);e.attr({"data-readmore":null,"aria-expanded":null}).css({maxHeight:"",height:""}).next("[data-readmore-toggle]").remove();e.removeData()})}};d.fn.readmore=function(t){var i=arguments,o=this.selector;t=t||{};if(typeof t==="object"){return this.each(function(){if(d.data(this,"plugin_"+n)){var e=d.data(this,"plugin_"+n);e.destroy.apply(e)}t.selector=o;d.data(this,"plugin_"+n,new c(this,t))})}else if(typeof t==="string"&&t[0]!=="_"&&t!=="init"){return this.each(function(){var e=d.data(this,"plugin_"+n);if(e instanceof c&&typeof e[t]==="function"){e[t].apply(e,Array.prototype.slice.call(i,1))}})}}});