!function(t,e,i){function n(t){return t.replace(/\s*$/,"")}function s(t,e){if(t.innerText)t.innerText=e;else if(t.nodeValue)t.nodeValue=e;else{if(!t.textContent)return!1;t.textContent=e}}function o(t,e,i,n){var o,h=t.parent();t.remove();var r=i?i.length:0;if(h.contents().length>r)return o=h.contents().eq(-1-r),a(o,e,i,n);var l=h.prev();return o=l.contents().eq(-1),!!o.length&&(s(o[0],o.text()+n.ellipsis),h.remove(),i.length&&l.append(i),!0)}function h(t,e,i,h){for(var r,l,a=t[0],p=t.text(),d="",c=0,u=p.length;c<=u;)r=c+(u-c>>1),l=h.ellipsis+n(p.substr(r-1,p.length)),s(a,l),e.height()>h.maxHeight?c=r+1:(u=r-1,d=d.length>l.length?d:l);return d.length>0?(s(a,d),!0):o(t,e,i,h)}function r(t,e,i,h){for(var r,l,a=t[0],p=t.text(),d="",c=0,u=p.length;c<=u;)r=c+(u-c>>1),l=n(p.substr(0,r+1))+h.ellipsis,s(a,l),e.height()>h.maxHeight?u=r-1:(c=r+1,d=d.length>l.length?d:l);return d.length>0?(s(a,d),!0):o(t,e,i,h)}function l(t,e,i,h){for(var r,l,a=t[0],p=t.text(),d="",c=0,u=p.length,g=u>>1;c<=g;)r=c+(g-c>>1),l=n(p.substr(0,r))+h.ellipsis+p.substr(u-r,u-r),s(a,l),e.height()>h.maxHeight?g=r-1:(c=r+1,d=d.length>l.length?d:l);return d.length>0?(s(a,d),!0):o(t,e,i,h)}function a(t,e,i,n){return"end"===n.position?r(t,e,i,n):"start"===n.position?h(t,e,i,n):l(t,e,i,n)}function p(t,i,n,s){var o,h,r=t[0],l=t.contents(),p=l.length,d=p-1,u=!1;for(t.empty();d>=0&&!u;d--)o=l.eq(d),h=o[0],8!==h.nodeType&&(r.insertBefore(h,r.firstChild),n.length&&(e.inArray(r.tagName.toLowerCase(),g)>=0?t.after(n):t.append(n)),i.height()>s.maxHeight&&(u=3===h.nodeType?a(o,i,n,s):c(o,i,n,s)),!u&&n.length&&n.remove());return u}function d(t,i,n,s){var o,h,r=t[0],l=t.contents(),p=0,d=l.length,u=!1;for(t.empty();p=0?t.after(n):t.append(n)),i.height()>s.maxHeight&&(u=3===h.nodeType?a(o,i,n,s):c(o,i,n,s)),!u&&n.length&&n.remove());return u}function c(t,e,i,n){return"end"===n.position?d(t,e,i,n):"start"===n.position?p(t,e,i,n):d(t,e,i,n)}function u(t,i){this.element=t,this.$element=e(t),this._name="truncate",this._defaults={lines:1,ellipsis:"…",showMore:"",showLess:"",position:"end",lineHeight:"auto"},this.config(i),this.original=this.cached=t.innerHTML,this.isTruncated=!1,this.isCollapsed=!0,this.update()}var g=["table","thead","tbody","tfoot","tr","col","colgroup","object","embed","param","ol","ul","dl","blockquote","select","optgroup","option","textarea","script","style"];u.prototype={config:function(t){if(this.options=e.extend({},this._defaults,t),"auto"===this.options.lineHeight){var n=this.$element.css("line-height"),s=18;"normal"!==n&&(s=parseInt(n,10)),this.options.lineHeight=s}this.options.maxHeight===i&&(this.options.maxHeight=parseInt(this.options.lines,10)*parseInt(this.options.lineHeight,10)),"start"!==this.options.position&&"middle"!==this.options.position&&"end"!==this.options.position&&(this.options.position="end"),this.$clipNode=e(e.parseHTML(this.options.showMore),this.$element),this.original&&this.update()},update:function(t){var e=!this.isCollapsed;"undefined"!=typeof t?this.original=this.element.innerHTML=t:this.isCollapsed&&this.element.innerHTML===this.cached&&(this.element.innerHTML=this.original);var i=this.$element.wrapInner("
").children();i.css({border:"none",margin:0,padding:0,width:"auto",height:"auto","word-wrap":"break-word"}),this.isTruncated=!1,i.height()>this.options.maxHeight?(this.isTruncated=c(i,i,this.$clipNode,this.options),this.isExplicitlyCollapsed&&(this.isCollapsed=!0,e=!1)):this.isCollapsed=!1,i.replaceWith(i.contents()),this.cached=this.element.innerHTML,e&&(this.element.innerHTML=this.original)},expand:function(){var t=!0;this.isExplicitlyCollapsed&&(this.isExplicitlyCollapsed=!1,t=!1),this.isCollapsed&&(this.isCollapsed=!1,this.element.innerHTML=this.isTruncated?this.original+(t?this.options.showLess:""):this.original)},collapse:function(t){this.isExplicitlyCollapsed=!0,this.isCollapsed||(this.isCollapsed=!0,t=t||!1,t?this.update():this.element.innerHTML=this.cached)}},e.fn.truncate=function(t){var i=e.makeArray(arguments).slice(1);return this.each(function(){var n=e.data(this,"jquery-truncate");n?"function"==typeof n[t]&&n[t].apply(n,i):e.data(this,"jquery-truncate",new u(this,t))})},t.Truncate=u}(this,jQuery);