/*jQuery collapser v3.0.1 - (c) 2020 Aakash Chakravarthy*/ !function(f){var t="collapser",a={mode:"words",speed:"slow",truncate:10,ellipsis:" ... ",controlBtn:null,showText:"Show more",hideText:"Hide text",showClass:"show-class",hideClass:"hide-class",atStart:"hide",blockTarget:"next",blockEffect:"fade",lockHide:!1,changeText:!1,beforeShow:null,afterShow:null,beforeHide:null,afterHide:null};function o(e,t){var o=this;o.o=f.extend({},a,t),o.e=f(e),o.init()}o.prototype={init:function(){var e=this;e.mode=e.o.mode,e.remaining=null,e.ctrlButton=f.isFunction(e.o.controlBtn)?e.o.controlBtn.call(e.e):f(''),"lines"==e.mode&&e.e.wrapInner("
");var t=f.isFunction(e.o.atStart)?e.o.atStart.call(e.e):e.o.atStart;"hide"==(t=void 0!==e.e.attr("data-start")?e.e.attr("data-start"):t)?e.hide(0):e.show(0)},show:function(e){var t=this,o=t.e;t.collapsed=!1,void 0===e&&(e=t.o.speed),f.isFunction(t.o.beforeShow)&&t.o.beforeShow.call(t.e,t);function a(){f.isFunction(t.o.afterShow)&&t.o.afterShow.call(t.e,t)}if(o.find("[data-ctrl]").remove(),"block"==t.mode)t.blockMode(o,"show",e,a);else{var n="lines"==t.mode?o.children("div"):o,i=n.height();if("lines"==t.mode)n.height("auto");else{var l=n.data("collHTML");void 0!==l&&n.html(l)}var s=n.height();n.height(i),n.animate({height:s},e,function(){n.height("auto"),a()}),o.removeClass(t.o.hideClass).addClass(t.o.showClass),f.isFunction(t.o.controlBtn)||o.append(t.ctrlButton),t.ctrlButton.html(t.o.hideText)}t.bindEvent(),t.o.lockHide&&t.ctrlButton.remove()},hide:function(e){var t=this,o=t.e;t.collapsed=!0,void 0===e&&(e=t.o.speed),f.isFunction(t.o.beforeHide)&&t.o.beforeHide.call(t.e,t);function a(){f.isFunction(t.o.afterHide)&&t.o.afterHide.call(t.e,t)}if(o.find("[data-ctrl]").remove(),"chars"==t.mode||"words"==t.mode){var n=o.html(),i=t.getCollapsedHTML(n,t.mode,t.o.truncate);if(i){var l=o.text();t.remaining=l.split("words"==t.mode?" ":"").length-t.o.truncate,o.data("collHTML",n),o.html(i)}else t.remaining=0}if("lines"==t.mode){var s=o.children("div"),r=s.outerHeight();if(0==(c=s.find("[data-col-char]")).length){var c=f('.');s.prepend(c)}var d=c.height(),h=d*t.o.truncate+d/4;r<=h?(h="auto",t.remaining=0):t.remaining=parseInt(Math.ceil((r-h)/d)),s.css({overflow:"hidden",height:h})}"block"==t.mode&&t.blockMode(o,"hide",e,a),a(),"block"!=t.mode&&(o.removeClass(t.o.showClass).addClass(t.o.hideClass),!f.isFunction(t.o.controlBtn)&&0"==char&&(a=!1),n==o){i=s,l=!1;break}a||("words"==t&&" "==char&&n++,"chars"==t&&n++)}if(l)return!1;var r=e.slice(0,i);return this.balanceTags(r)+''+this.o.ellipsis+""},balanceTags:function(e){e.lastIndexOf("<")>e.lastIndexOf(">")&&(e=e.substring(0,e.lastIndexOf("<")));var t=e.match(/<[^>]+>/g),o=new Array;for(tag in t)t[tag].search("/")<=0?o.push(t[tag]):1==t[tag].search("/")&&o.pop();for(;0]/)))+">"}return e},bindEvent:function(){var t=this;("block"==t.mode?t.e:t.ctrlButton).off("click").on("click",function(e){e.preventDefault(),t.collapsed?t.show():t.hide()})}},f.fn[t]=function(e){return this.each(function(){f.data(this,t)||f.data(this,t,new o(this,e))})}}(jQuery,(window,document));