(function(d,x){function y(a,b,m,c,h){var l=!1;a.contents().detach().each(function(){var g=d(this);if("undefined"==typeof this||3==this.nodeType&&0==d.trim(this.data).length)return!0;if(g.is("script"))a.append(g);else{if(l)return!0;a.append(g);if(h)a[a.is("table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style")?"after":"append"](h);if(m.innerHeight()>c.maxHeight){if(3==this.nodeType){var k=g[0];if(k){var p=z(k),
f=-1!==p.indexOf(" ")?" ":"\u3000",f="letter"==c.wrap?"":f,e=p.split(f),v=-1,n=-1,q=0,r=e.length-1;c.fallbackToLetter&&0==q&&0==r&&(f="",e=p.split(f),r=e.length-1);for(;q<=r&&(0!=q||0!=r);){p=Math.floor((q+r)/2);if(p==n)break;n=p;t(k,e.slice(0,n+1).join(f)+c.ellipsis);m.innerHeight()>c.maxHeight?(r=n,c.fallbackToLetter&&0==q&&0==r&&(f="",e=e[0].split(f),n=v=-1,q=0,r=e.length-1)):q=v=n}-1==v||1==e.length&&0==e[0].length?(p=g.parent(),g.detach(),f=h&&h.closest(p).length?h.length:0,p.contents().length>
f?k=u(p.contents().eq(-1-f),b):(k=u(p,b,!0),f||p.detach()),k&&(p=A(z(k),c),t(k,p),f&&h&&d(k).parent().append(h))):(p=A(e.slice(0,v+1).join(f),c),t(k,p));l=!0}else l=!1}else l=y(g,b,m,c,h);l||(g.detach(),l=!0)}l||h&&h.detach()}});return l}function A(a,b){for(;-1<d.inArray(a.slice(-1),b.lastCharacter.remove);)a=a.slice(0,-1);0>d.inArray(a.slice(-1),b.lastCharacter.noEllipsis)&&(a+=b.ellipsis);return a}function w(a){return{width:a.innerWidth(),height:a.innerHeight()}}function t(a,b){a.innerText?a.innerText=
b:a.nodeValue?a.nodeValue=b:a.textContent&&(a.textContent=b)}function z(a){return a.innerText?a.innerText:a.nodeValue?a.nodeValue:a.textContent?a.textContent:""}function B(a){do a=a.previousSibling;while(a&&1!==a.nodeType&&3!==a.nodeType);return a}function u(a,b,m){var c=a&&a[0];if(c){if(!m){if(3===c.nodeType)return c;if(d.trim(a.text()))return u(a.contents().last(),b)}for(m=B(c);!m;){a=a.parent();if(a.is(b)||!a.length)return!1;m=B(a[0])}if(m)return u(d(m),b)}return!1}function C(a,b){return a?"string"===
typeof a?(a=d(a,b),a.length?a:!1):a.jquery?a:!1:!1}if(!d.fn.dotdotdot){d.fn.dotdotdot=function(a){if(0==this.length)return d.fn.dotdotdot.debug('No element found for "'+this.selector+'".'),this;if(1<this.length)return this.each(function(){d(this).dotdotdot(a)});var b=this;b.data("dotdotdot")&&b.trigger("destroy.dot");b.data("dotdotdot-style",b.attr("style")||"");b.css("word-wrap","break-word");"nowrap"===b.css("white-space")&&b.css("white-space","normal");b.bind_events=function(){b.bind("update.dot",
function(a,f){a.preventDefault();a.stopPropagation();var e=c,g;if("number"==typeof c.height)g=c.height;else{g=b.innerHeight();for(var n=["paddingTop","paddingBottom"],q=0,l=n.length;q<l;q++){var s=parseInt(b.css(n[q]),10);isNaN(s)&&(s=0);g-=s}}e.maxHeight=g;c.maxHeight+=c.tolerance;if("undefined"!=typeof f){if("string"==typeof f||f instanceof HTMLElement)f=d("<div />").append(f).contents();f instanceof d&&(m=f)}k=b.wrapInner('<div class="dotdotdot" />').children();k.contents().detach().end().append(m.clone(!0)).find("br").replaceWith("  <br />  ").end().css({height:"auto",
width:"auto",border:"none",padding:0,margin:0});e=n=!1;h.afterElement&&(n=h.afterElement.clone(!0),n.show(),h.afterElement.detach());if(k.innerHeight()>c.maxHeight)if("children"==c.wrap){e=k;g=c;q=e.children();l=!1;e.empty();for(var s=0,u=q.length;s<u;s++){var t=q.eq(s);e.append(t);n&&e.append(n);if(e.innerHeight()>g.maxHeight){t.remove();l=!0;break}else n&&n.detach()}e=l}else e=y(k,b,k,c,n);k.replaceWith(k.contents());k=null;d.isFunction(c.callback)&&c.callback.call(b[0],e,m);return h.isTruncated=
e}).bind("isTruncated.dot",function(a,c){a.preventDefault();a.stopPropagation();"function"==typeof c&&c.call(b[0],h.isTruncated);return h.isTruncated}).bind("originalContent.dot",function(a,c){a.preventDefault();a.stopPropagation();"function"==typeof c&&c.call(b[0],m);return m}).bind("destroy.dot",function(a){a.preventDefault();a.stopPropagation();b.unwatch().unbind_events().contents().detach().end().append(m).attr("style",b.data("dotdotdot-style")||"").data("dotdotdot",!1)});return b};b.unbind_events=
function(){b.unbind(".dot");return b};b.watch=function(){b.unwatch();if("window"==c.watch){var a=d(window),f=a.width(),e=a.height();a.bind("resize.dot"+h.dotId,function(){f==a.width()&&e==a.height()&&c.windowResizeFix||(f=a.width(),e=a.height(),g&&clearInterval(g),g=setTimeout(function(){b.trigger("update.dot")},10))})}else l=w(b),g=setInterval(function(){var a=w(b);if(l.width!=a.width||l.height!=a.height)b.trigger("update.dot"),l=w(b)},100);return b};b.unwatch=function(){d(window).unbind("resize.dot"+
h.dotId);g&&clearInterval(g);return b};var m=b.contents(),c=d.extend(!0,{},d.fn.dotdotdot.defaults,a),h={},l={},g=null,k=null;c.lastCharacter.remove instanceof Array||(c.lastCharacter.remove=d.fn.dotdotdot.defaultArrays.lastCharacter.remove);c.lastCharacter.noEllipsis instanceof Array||(c.lastCharacter.noEllipsis=d.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis);h.afterElement=C(c.after,b);h.isTruncated=!1;h.dotId=D++;b.data("dotdotdot",!0).bind_events().trigger("update.dot");c.watch&&b.watch();
return b};d.fn.dotdotdot.defaults={ellipsis:"... ",wrap:"word",fallbackToLetter:!0,lastCharacter:{},tolerance:0,callback:null,after:null,height:null,watch:!1,windowResizeFix:!0};d.fn.dotdotdot.defaultArrays={lastCharacter:{remove:" \u3000,;.!?".split(""),noEllipsis:[]}};d.fn.dotdotdot.debug=function(a){};var D=1,E=d.fn.html;d.fn.html=function(a){return a!=x&&!d.isFunction(a)&&this.data("dotdotdot")?this.trigger("update",[a]):E.apply(this,arguments)};var F=d.fn.text;d.fn.text=function(a){return a!=
x&&!d.isFunction(a)&&this.data("dotdotdot")?(a=d("<div />").text(a).html(),this.trigger("update",[a])):F.apply(this,arguments)}}})(jQuery);
