(function($){if($.fn.dotdotdot){return}$.fn.dotdotdot=function(o){if(this.length==0){debug(true,'No element found for "'+this.selector+'".');return this}if(this.length>1){return this.each(function(){$(this).dotdotdot(o)})}var $dot=this;if($dot.data('dotdotdot')){$dot.trigger('destroy.dot')}$dot.bind_events=function(){$dot.bind('update.dot',function(e,c){e.preventDefault();e.stopPropagation();opts.maxHeight=(typeof opts.height=='number')?opts.height:getTrueInnerHeight($dot);opts.maxHeight+=opts.tolerance;if(typeof c!='undefined'){if(typeof c=='string'||c instanceof HTMLElement){c=$('
').append(c).contents()}if(c instanceof $){orgContent=c}}$inr=$dot.wrapInner('').children();$inr.empty().append(orgContent.clone(true)).css({'height':'auto','width':'auto','border':'none','padding':0,'margin':0});var after=false,trunc=false;if(conf.afterElement){after=conf.afterElement.clone(true);conf.afterElement.remove()}if(test($inr,opts)){if(opts.wrap=='children'){trunc=children($inr,opts,after)}else{trunc=ellipsis($inr,$dot,$inr,opts,after)}}$inr.replaceWith($inr.contents());$inr=null;if($.isFunction(opts.callback)){opts.callback.call($dot[0],trunc,orgContent)}conf.isTruncated=trunc;return trunc}).bind('isTruncated.dot',function(e,fn){e.preventDefault();e.stopPropagation();if(typeof fn=='function'){fn.call($dot[0],conf.isTruncated)}return conf.isTruncated}).bind('originalContent.dot',function(e,fn){e.preventDefault();e.stopPropagation();if(typeof fn=='function'){fn.call($dot[0],orgContent)}return orgContent}).bind('destroy.dot',function(e){e.preventDefault();e.stopPropagation();$dot.unwatch().unbind_events().empty().append(orgContent).data('dotdotdot',false)});return $dot};$dot.unbind_events=function(){$dot.unbind('.dot');return $dot};$dot.watch=function(){$dot.unwatch();if(opts.watch=='window'){var $window=$(window),_wWidth=$window.width(),_wHeight=$window.height();$window.bind('resize.dot'+conf.dotId,function(){if(_wWidth!=$window.width()||_wHeight!=$window.height()||!opts.windowResizeFix){_wWidth=$window.width();_wHeight=$window.height();if(watchInt){clearInterval(watchInt)}watchInt=setTimeout(function(){$dot.trigger('update.dot')},10)}})}else{watchOrg=getSizes($dot);watchInt=setInterval(function(){var watchNew=getSizes($dot);if(watchOrg.width!=watchNew.width||watchOrg.height!=watchNew.height){$dot.trigger('update.dot');watchOrg=getSizes($dot)}},100)}return $dot};$dot.unwatch=function(){$(window).unbind('resize.dot'+conf.dotId);if(watchInt){clearInterval(watchInt)}return $dot};var orgContent=$dot.contents(),opts=$.extend(true,{},$.fn.dotdotdot.defaults,o),conf={},watchOrg={},watchInt=null,$inr=null;conf.afterElement=getElement(opts.after,$dot);conf.isTruncated=false;conf.dotId=dotId++;$dot.data('dotdotdot',true).bind_events().trigger('update.dot');if(opts.watch){$dot.watch()}return $dot};$.fn.dotdotdot.defaults={'ellipsis':'... ','wrap':'word','lastCharacter':{'remove':[' ',',',';','.','!','?'],'noEllipsis':[]},'tolerance':0,'callback':null,'after':null,'height':null,'watch':false,'windowResizeFix':true,'debug':false};var dotId=1;function children($elem,o,after){var $elements=$elem.children(),isTruncated=false;$elem.empty();for(var a=0,l=$elements.length;a