(function($,undef) {if($.fn.dotdotdot) {return;} $.fn.dotdotdot=function(o) {if(this.length==0) {$.fn.dotdotdot.debug('No element found for "'+this.selector+'".');return this;} if(this.length>1) {return this.each(function() {$(this).dotdotdot(o);});} var $dot=this;var orgContent=$dot.contents();if($dot.data('dotdotdot')) {$dot.trigger('destroy.html');} $dot.data('dotdotdot-style',$dot.attr('style')||'');$dot.css('word-wrap','break-word');if($dot.css('white-space')==='nowrap') {$dot.css('white-space','normal');} $dot.bind_events=function() {$dot.bind('update.html',function(e,c) {$dot.removeClass("is-truncated");e.preventDefault();e.stopPropagation();switch(typeof opts.height) {case'number':opts.maxHeight=opts.height;break;case'function':opts.maxHeight=opts.height.call($dot[0]);break;default:opts.maxHeight=getTrueInnerHeight($dot);break;} opts.maxHeight+=opts.tolerance;if(typeof c!='undefined') {if(typeof c=='string'||('nodeType'in c&&c.nodeType===1)) {c=$('
').append(c).contents();} if(c instanceof $) {orgContent=c;}} $inr=$dot.wrapInner('
').children();$inr.contents().detach().end().append(orgContent.clone(true)).find('br').replaceWith('
').end().css({'height':'auto','width':'auto','border':'none','padding':0,'margin':0});var after=false,trunc=false;if(conf.afterElement) {after=conf.afterElement.clone(true);after.show();conf.afterElement.detach();} 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.html',function(e,fn) {e.preventDefault();e.stopPropagation();if(typeof fn=='function') {fn.call($dot[0],conf.isTruncated);} return conf.isTruncated;}).bind('originalContent.html',function(e,fn) {e.preventDefault();e.stopPropagation();if(typeof fn=='function') {fn.call($dot[0],orgContent);} return orgContent;}).bind('destroy.html',function(e) {e.preventDefault();e.stopPropagation();$dot.unwatch().unbind_events().contents().detach().end().append(orgContent).attr('style',$dot.data('dotdotdot-style')||'').removeClass('is-truncated').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.html'+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.html');},100);}});} else {watchOrg=getSizes($dot);watchInt=setInterval(function() {if($dot.is(':visible')) {var watchNew=getSizes($dot);if(watchOrg.width!=watchNew.width||watchOrg.height!=watchNew.height) {$dot.trigger('update.html');watchOrg=watchNew;}}},500);} return $dot;};$dot.unwatch=function() {$(window).unbind('resize.html'+conf.dotId);if(watchInt) {clearInterval(watchInt);} return $dot;};var opts=$.extend(true,{},$.fn.dotdotdot.defaults,o),conf={},watchOrg={},watchInt=null,$inr=null;if(!(opts.lastCharacter.remove instanceof Array)) {opts.lastCharacter.remove=$.fn.dotdotdot.defaultArrays.lastCharacter.remove;} if(!(opts.lastCharacter.noEllipsis instanceof Array)) {opts.lastCharacter.noEllipsis=$.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis;} conf.afterElement=getElement(opts.after,$dot);conf.isTruncated=false;conf.dotId=dotId++;$dot.data('dotdotdot',true).bind_events().trigger('update.html');if(opts.watch) {$dot.watch();} return $dot;};$.fn.dotdotdot.defaults={'ellipsis':'... ','wrap':'word','fallbackToLetter':true,'lastCharacter':{},'tolerance':0,'callback':null,'after':null,'height':null,'watch':false,'windowResizeFix':true};$.fn.dotdotdot.defaultArrays={'lastCharacter':{'remove':[' ','\u3000',',',';','.','!','?'],'noEllipsis':[]}};$.fn.dotdotdot.debug=function(msg){};var dotId=1;function children($elem,o,after) {var $elements=$elem.children(),isTruncated=false;$elem.empty();for(var a=0,l=$elements.length;aafterLength) {e=findLastTextNode($w.contents().eq(-1-afterLength),$d);} else {e=findLastTextNode($w,$d,true);if(!afterLength) {$w.detach();}} if(e) {txt=addEllipsis(getTextContent(e),o);setTextContent(e,txt);if(afterLength&&after) {var $parent=after.parent();$(e).parent().append(after);if(!$.trim($parent.html())) {$parent.remove();}}}} return true;} function test($i,o) {return $i.innerHeight()>o.maxHeight;} function addEllipsis(txt,o) {while($.inArray(txt.slice(-1),o.lastCharacter.remove)>-1) {txt=txt.slice(0,-1);} if($.inArray(txt.slice(-1),o.lastCharacter.noEllipsis)<0) {txt+=o.ellipsis;} return txt;} function getSizes($d) {return{'width':$d.innerWidth(),'height':$d.innerHeight()};} function setTextContent(e,content) {if(e.innerText) {e.innerText=content;} else if(e.nodeValue) {e.nodeValue=content;} else if(e.textContent) {e.textContent=content;}} function getTextContent(e) {if(e.innerText) {return e.innerText;} else if(e.nodeValue) {return e.nodeValue;} else if(e.textContent) {return e.textContent;} else {return"";}} function getPrevNode(n) {do {n=n.previousSibling;} while(n&&n.nodeType!==1&&n.nodeType!==3);return n;} function findLastTextNode($el,$top,excludeCurrent) {var e=$el&&$el[0],p;if(e) {if(!excludeCurrent) {if(e.nodeType===3) {return e;} if($.trim($el.text())) {return findLastTextNode($el.contents().last(),$top);}} p=getPrevNode(e);while(!p) {$el=$el.parent();if($el.is($top)||!$el.length) {return false;} p=getPrevNode($el[0]);} if(p) {return findLastTextNode($(p),$top);}} return false;} function getElement(e,$i) {if(!e) {return false;} if(typeof e==='string') {e=$(e,$i);return(e.length)?e:false;} return!e.jquery?false:e;} function getTrueInnerHeight($el) {var h=$el.innerHeight(),a=['paddingTop','paddingBottom'];for(var z=0,l=a.length;z').text(str).html();return this.trigger('update',[str]);} return _orgText.apply(this,arguments);};})(jQuery);jQuery(document).ready(function($){$(".dot-ellipsis").each(function(){var watch_window=$(this).hasClass("dot-resize-update");var watch_timer=$(this).hasClass("dot-timer-update");var height=0;var classList=$(this).attr('class').split(/\s+/);$.each(classList,function(index,item){var matchResult=item.match(/^dot-height-(\d+)$/);if(matchResult!==null) height=Number(matchResult[1]);});var x=new Object();if(watch_timer) x.watch=true;if(watch_window) x.watch='window';if(height>0) x.height=height;$(this).dotdotdot(x);});});jQuery(window).on('load',function(){jQuery(".dot-ellipsis.dot-load-update").trigger("update.html");});