diff --git a/samples/columnizer.css b/samples/columnizer.css
new file mode 100644
index 0000000..8221e46
--- /dev/null
+++ b/samples/columnizer.css
@@ -0,0 +1,9 @@
+.columnized .column {
+ width: 24%;
+ float: left;
+ margin: 0 .5%;
+}
+
+.clear {
+ clear: both;
+}
diff --git a/samples/sample1.html b/samples/sample1.html
index 1a319d4..bc43078 100644
--- a/samples/sample1.html
+++ b/samples/sample1.html
@@ -4,6 +4,8 @@
Columnizer JQuery Plugin sample page
+
+
-
+
+
diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js
index b63a410..3039b0e 100644
--- a/src/jquery.columnizer.js
+++ b/src/jquery.columnizer.js
@@ -49,6 +49,8 @@
// previx for all the CSS classes used by this plugin
// default to empty string for backwards compatibility
cssClassPrefix : "",
+ cssClassClear : "clear",
+ cssClassCol : "column",
elipsisText:'...',
debug:0
};
@@ -96,19 +98,25 @@
}
return this.each(function() {
- var $inBox = options.target ? $(options.target) : $(this);
- var maxHeight = $(this).height();
- var $cache = $(''); // this is where we'll put the real content
- var lastWidth = 0;
- var columnizing = false;
- var manualBreaks = options.manualBreaks;
- var cssClassPrefix = defaults.cssClassPrefix;
+ var $inBox = options.target ? $(options.target) : $(this),
+ maxHeight = $(this).height(),
+ $cache = $(''), // this is where we'll put the real content
+ lastWidth = adjustment = 0,
+ columnizing = false,
+ manualBreaks = options.manualBreaks,
+ cssClassPrefix = defaults.cssClassPrefix,
+ cssClassClear = defaults.cssClassClear,
+ cssClassCol = defaults.cssClassCol;
+
if(typeof(options.cssClassPrefix) == "string"){
cssClassPrefix = options.cssClassPrefix;
}
-
-
- var adjustment = 0;
+ if(typeof(options.cssClassClear) == "string"){
+ cssClassClear = options.cssClassClear;
+ }
+ if(typeof(options.cssClassCol) == "string"){
+ cssClassCol = options.cssClassCol;
+ }
appendSafe($cache, $(this).contents().clone(true));
@@ -136,7 +144,7 @@
}
}
- $inBox.empty();
+ $inBox.empty().addClass('columnized');
columnizeIt();
@@ -200,8 +208,8 @@
if($putInHere[0].childNodes.length === 0) return;
// now we're too tall, so undo the last one
- var kids = $putInHere[0].childNodes;
- var lastKid = kids[kids.length-1];
+ var kids = $putInHere[0].childNodes,
+ lastKid = kids[kids.length-1];
$putInHere[0].removeChild(lastKid);
var $item = $(lastKid);
@@ -209,12 +217,13 @@
// to fit as much of it as we can into this column
if($item[0].nodeType == 3){
// it's a text node, split it up
- var oText = $item[0].nodeValue;
- var counter2 = options.width / 18;
- if(options.accuracy)
- counter2 = options.accuracy;
- var columnText;
- var latestTextNode = null;
+ var oText = $item[0].nodeValue,
+ counter2 = options.width / 18,
+ columnText,
+ latestTextNode = null;
+
+ if(options.accuracy) counter2 = options.accuracy;
+
while($parentColumn.height() < targetHeight && oText.length){
//
// it's been brought up that this won't work for chinese
@@ -374,8 +383,8 @@
$inBox.append($("")); //"
+ + prefixTheClassName(cssClassCol) + " "
+ + "'>")); //"
$col = $inBox.children().eq($inBox.children().length-1);
$destroyable = $cache.clone(true);
if(options.overflow){
@@ -392,8 +401,8 @@
$destroyable.prepend($lastKid);
}
- var html = "";
- var div = document.createElement('DIV');
+ var html = "",
+ div = document.createElement('DIV');
while($destroyable[0].childNodes.length > 0){
var kid = $destroyable[0].childNodes[0];
if(kid.attributes){
@@ -478,10 +487,10 @@
maxHeight = $col.height();
$inBox.empty();
- var targetHeight = maxHeight / numCols;
- var firstTime = true;
- var maxLoops = 3;
- var scrollHorizontally = false;
+ var targetHeight = maxHeight / numCols,
+ firstTime = true,
+ maxLoops = 3,
+ scrollHorizontally = false;
if(options.overflow){
maxLoops = 1;
targetHeight = options.overflow.height;
@@ -513,9 +522,9 @@
for (var i = 0; i < numCols; i++) {
/* create column */
className = (i === 0) ? prefixTheClassName("first") : "";
- className += " " + prefixTheClassName("column");
+ className += (className != "" ? " " : "") + prefixTheClassName(cssClassCol);
className = (i == numCols - 1) ? (prefixTheClassName("last") + " " + className) : className;
- $inBox.append($("")); //"
+ $inBox.append($("")); //"
}
// fill all but the last column (unless overflowing)
@@ -523,7 +532,7 @@
while(i < numCols - (options.overflow ? 0 : 1) || scrollHorizontally && $destroyable.contents().length){
if($inBox.children().length <= i){
// we ran out of columns, make another
- $inBox.append($("")); //"
+ $inBox.append($("")); //"
}
$col = $inBox.children().eq(i);
if(scrollHorizontally){
@@ -579,8 +588,8 @@
@*/
var IE7 = (document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1);
if(IE6 || IE7){
- var html = "";
- var div = document.createElement('DIV');
+ var html = "",
+ div = document.createElement('DIV');
while($destroyable[0].childNodes.length > 0){
var kid = $destroyable[0].childNodes[0];
for(i=0;i
"));
+ $inBox.append($(""));
}
- $inBox.find(prefixTheClassName("column", true)).find(":first" + prefixTheClassName("removeiffirst", true)).remove();
- $inBox.find(prefixTheClassName("column", true)).find(':last' + prefixTheClassName("removeiflast", true)).remove();
+ $inBox.find(prefixTheClassName(cssClassCol, true)).find(":first" + prefixTheClassName("removeiffirst", true)).remove();
+ $inBox.find(prefixTheClassName(cssClassCol, true)).find(':last' + prefixTheClassName("removeiflast", true)).remove();
$inBox.find(prefixTheClassName("split", true)).find(":first" + prefixTheClassName("removeiffirst", true)).remove();
$inBox.find(prefixTheClassName("split", true)).find(':last' + prefixTheClassName("removeiflast", true)).remove();
$inBox.data("columnizing", false);
diff --git a/src/jquery.columnizer.min.js b/src/jquery.columnizer.min.js
index b6b5da1..d7cca5b 100644
--- a/src/jquery.columnizer.min.js
+++ b/src/jquery.columnizer.min.js
@@ -1,90 +1 @@
-
-(function($){$.fn.columnize=function(options){this.cols=[];this.offset=0;this.before=[];this.lastOther=0;this.prevMax=0;this.debug=0;this.setColumnStart=null;this.elipsisText='';var defaults={width:400,columns:false,buildOnce:false,overflow:false,doneFunc:function(){},target:false,ignoreImageLoading:true,columnFloat:"left",lastNeverTallest:false,accuracy:false,precise:false,manualBreaks:false,cssClassPrefix:"",elipsisText:'...',debug:0};options=$.extend(defaults,options);if(typeof(options.width)=="string"){options.width=parseInt(options.width,10);if(isNaN(options.width)){options.width=defaults.width;}}
-if(typeof options.setColumnStart=='function'){this.setColumnStart=options.setColumnStart;}
-if(typeof options.elipsisText=='string'){this.elipsisText=options.elipsisText;}
-if(options.debug){this.debug=options.debug;}
-if(!options.setWidth){if(options.precise){options.setWidth=function(numCols){return 100/numCols;};}else{options.setWidth=function(numCols){return Math.floor(100/numCols);};}}
-function appendSafe($target,$elem){try{$target.append($elem);}catch(e){$target[0].appendChild($elem[0]);}}
-return this.each(function(){var $inBox=options.target?$(options.target):$(this);var maxHeight=$(this).height();var $cache=$('');var lastWidth=0;var columnizing=false;var manualBreaks=options.manualBreaks;var cssClassPrefix=defaults.cssClassPrefix;if(typeof(options.cssClassPrefix)=="string"){cssClassPrefix=options.cssClassPrefix;}
-var adjustment=0;appendSafe($cache,$(this).contents().clone(true));if(!options.ignoreImageLoading&&!options.target){if(!$inBox.data("imageLoaded")){$inBox.data("imageLoaded",true);if($(this).find("img").length>0){var func=function($inBox,$cache){return function(){if(!$inBox.data("firstImageLoaded")){$inBox.data("firstImageLoaded","true");appendSafe($inBox.empty(),$cache.children().clone(true));$inBox.columnize(options);}};}($(this),$cache);$(this).find("img").one("load",func);$(this).find("img").one("abort",func);return;}}}
-$inBox.empty();columnizeIt();if(!options.buildOnce){$(window).resize(function(){if(!options.buildOnce){if($inBox.data("timeout")){clearTimeout($inBox.data("timeout"));}
-$inBox.data("timeout",setTimeout(columnizeIt,200));}});}
-function prefixTheClassName(className,withDot){var dot=withDot?".":"";if(cssClassPrefix.length){return dot+cssClassPrefix+"-"+className;}
-return dot+className;}
-function columnize($putInHere,$pullOutHere,$parentColumn,targetHeight){while((manualBreaks||$parentColumn.height()counter2&&indexOfSpace!=-1){oText=oText.substring(indexOfSpace);}else{oText="";}}
-if($parentColumn.height()>=targetHeight&&latestTextNode!==null){$putInHere[0].removeChild(latestTextNode);oText=latestTextNode.nodeValue+oText;}
-if(oText.length){$item[0].nodeValue=oText;}else{return false;}}
-if($pullOutHere.contents().length){$pullOutHere.prepend($item);}else{appendSafe($pullOutHere,$item);}
-return $item[0].nodeType==3;}
-function split($putInHere,$pullOutHere,$parentColumn,targetHeight){if($putInHere.contents(":last").find(prefixTheClassName("columnbreak",true)).length){return;}
-if($putInHere.contents(":last").hasClass(prefixTheClassName("columnbreak"))){return;}
-if($pullOutHere.contents().length){var $cloneMe=$pullOutHere.contents(":first");if(typeof $cloneMe.get(0)=='undefined'||$cloneMe.get(0).nodeType!=1)return;var $clone=$cloneMe.clone(true);if($cloneMe.hasClass(prefixTheClassName("columnbreak"))){appendSafe($putInHere,$clone);$cloneMe.remove();}else if(manualBreaks){appendSafe($putInHere,$clone);$cloneMe.remove();}else if($clone.get(0).nodeType==1&&!$clone.hasClass(prefixTheClassName("dontend"))){appendSafe($putInHere,$clone);if($clone.is("img")&&$parentColumn.height()"));$col=$inBox.children().eq($inBox.children().length-1);$destroyable=$cache.clone(true);if(options.overflow){targetHeight=options.overflow.height;columnize($col,$destroyable,$col,targetHeight);if(!$destroyable.contents().find(":first-child").hasClass(prefixTheClassName("dontend"))){split($col,$destroyable,$col,targetHeight);}
-while($col.contents(":last").length&&checkDontEndColumn($col.contents(":last").get(0))){var $lastKid=$col.contents(":last");$lastKid.remove();$destroyable.prepend($lastKid);}
-var html="";var div=document.createElement('DIV');while($destroyable[0].childNodes.length>0){var kid=$destroyable[0].childNodes[0];if(kid.attributes){for(var i=0;i<=1){return singleColumnizeIt();}
-if($inBox.data("columnizing"))return;$inBox.data("columnized",true);$inBox.data("columnizing",true);$inBox.empty();$inBox.append($(""));$col=$inBox.children(":last");appendSafe($col,$cache.clone());maxHeight=$col.height();$inBox.empty();var targetHeight=maxHeight/numCols;var firstTime=true;var maxLoops=3;var scrollHorizontally=false;if(options.overflow){maxLoops=1;targetHeight=options.overflow.height;}else if(optionHeight&&optionWidth){maxLoops=1;targetHeight=optionHeight;scrollHorizontally=true;}
-for(var loopCount=0;loopCount<20;loopCount++){$inBox.empty();var $destroyable,className,$col,$lastKid;try{$destroyable=$cache.clone(true);}catch(e){$destroyable=$cache.clone();}
-$destroyable.css("visibility","hidden");for(var i=0;i"));}
-i=0;while(i<=i){$inBox.append($(""));}
-$col=$inBox.children().eq(i);if(scrollHorizontally){$col.width(optionWidth+"px");}
-columnize($col,$destroyable,$col,targetHeight);split($col,$destroyable,$col,targetHeight);while($col.contents(":last").length&&checkDontEndColumn($col.contents(":last").get(0))){$lastKid=$col.contents(":last");$lastKid.remove();$destroyable.prepend($lastKid);}
-i++;if($col.contents().length===0&&$destroyable.contents().length){$col.append($destroyable.contents(":first"));}else if(i==numCols-(options.overflow?0:1)&&!options.overflow){if($destroyable.find(prefixTheClassName("columnbreak",true)).length){numCols++;}}}
-if(options.overflow&&!scrollHorizontally){var IE6=false;var IE7=(document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1);if(IE6||IE7){var html="";var div=document.createElement('DIV');while($destroyable[0].childNodes.length>0){var kid=$destroyable[0].childNodes[0];for(i=0;imax){max=h;lastIsMax=true;}
-if(h30){targetHeight=avgH+30;}else if(Math.abs(avgH-targetHeight)>20){targetHeight=avgH;}else{loopCount=maxLoops;}}else{$inBox.children().each(function(i){$col=$inBox.children().eq(i);$col.width(optionWidth+"px");if(i===0){$col.addClass(prefixTheClassName("first"));}else if(i==$inBox.children().length-1){$col.addClass(prefixTheClassName("last"));}else{$col.removeClass(prefixTheClassName("first"));$col.removeClass(prefixTheClassName("last"));}});$inBox.width($inBox.children().length*optionWidth+"px");}
-$inBox.append($("
"));}
-$inBox.find(prefixTheClassName("column",true)).find(":first"+prefixTheClassName("removeiffirst",true)).remove();$inBox.find(prefixTheClassName("column",true)).find(':last'+prefixTheClassName("removeiflast",true)).remove();$inBox.find(prefixTheClassName("split",true)).find(":first"+prefixTheClassName("removeiffirst",true)).remove();$inBox.find(prefixTheClassName("split",true)).find(':last'+prefixTheClassName("removeiflast",true)).remove();$inBox.data("columnizing",false);if(options.overflow){options.overflow.doneFunc();}
-options.doneFunc();}});};$.fn.renumberByJS=function($searchTag,$colno,$targetId,$targetClass){this.setList=function($cols,$list,$tag1){var $parents=this.before.parents();var $rest;$rest=$($cols[this.offset-1]).find('>*');if(($rest.last())[0].tagName!=$tag1.toUpperCase()){if(this.debug){console.log("Last item in previous column, isn't a list...");}
-return 0;}
-$rest=$rest.length;var $tint=1;if(this.lastOther<=0){$tint=this.before.children().length+1;}else{$tint=$($parents[this.lastOther]).children().length+1;}
-if($($cols[this.offset]).find($tag1+':first li.split').length){var $whereElipsis=$($cols[this.offset-1]).find($tag1+':last li:last');if(this.elipsisText===''||$($cols[this.offset-1]).find($tag1+':last ~ div').length||$($cols[this.offset-1]).find($tag1+':last ~ p').length){;}else{if($($whereElipsis).find('ul, ol, dl').length==0){var $txt=$whereElipsis.last().text();var $len=$txt.length;if($txt.substring($len-1)==';'){if($txt.substring($len-4)!=this.elipsisText+';'){$txt=$txt.substring(0,$len-1)+this.elipsisText+';';}}else{if($txt.substring($len-3)!=this.elipsisText){$txt+=this.elipsisText;}}
-$whereElipsis.last().text($txt);}}
-if($($cols[this.offset]).find($tag1+':first >li.split >'+$tag1).length==0){$tint--;}}
-if($rest==1){$tint+=this.prevMax;}
-if(this.nest>1){if(this.debug){console.log("Supposed to be a nested list...decr");}
-$tint--;var $tt=$($cols[this.offset-1]).find($tag1+':first li.split:first');if($tt.length>0){if(this.debug){console.log("Previous column started with a split item, so that count is one less than expected");}
-$tint--;}
-$tt=$($cols[this.offset]).find($tag1+':first li:first').clone();$tt.children().remove();if($.trim($tt.text()).length>0){if(this.debug){console.log("If that was a complete list in the previous column, don't decr.");}
-$tint++;if($($cols[this.offset-1]).find(">"+$tag1+':last ').children().length==0){if(this.debug){console.log("unless that was empty, in which case revert");}
-$tint--;}}}else{var $tt=$($cols[this.offset]).find($tag1+':first li:first '+$tag1+".split li.split");if($tt.length>0){if(this.debug){console.log("[Nested] Column started with a split item, so that count is one less than expected");}
-$tint--;}}
-if(this.debug){console.log("Setting the start value to "+$tint+" ("+this.prevMax+")");}
-if($tint>0){if(typeof this.setColumnStart=='function'){this.setColumnStart($list,$tint);}else{$list.attr('start',$tint);}}
-return 0;}
-if(typeof $targetId==='undefined'){$targetId=false;}
-if(typeof $targetClass==='undefined'){$targetClass=false;}
-if(!$targetId&&!$targetClass){throw"renumberByJS(): Bad param, must pass an id or a class";}
-var $target='';this.prevMax=1;if($targetClass){$target="."+$targetClass;}else{$target="#"+$targetId;}
-var $tag1=$searchTag.toLowerCase();var $tag2=$searchTag.toUpperCase();this.cols=$($target);if(this.debug){console.log("There are "+this.cols.length+" items, looking for "+$tag1);}
-this.before=$(this.cols[0]).find($tag1+':last');this.prevMax=this.before.children().length;for(this.offset=1;this.offset"+$tag1+':first li '+$tag1+":first").length){this.nest=2;}
-this.setList(this.cols,$list,$tag1);this.lastOther--;$list=$(this.cols[this.offset]).find($tag1+':first li '+$tag1+":first");if($list.length){this.before=$(this.cols[this.offset-1]).find(">"+$tag1+':last li '+$tag1+":last");this.prevMax=0;this.nest=1;this.setList(this.cols,$list,$tag1);}
-var $reset=$(this.cols[this.offset-1]).find(">"+$tag1+':last');this.prevMax=$reset.children().length;}}
-return 0;};})(jQuery);
\ No newline at end of file
+!function(e){e.fn.columnize=function(t){function s(e,t){try{e.append(t)}catch(s){e[0].appendChild(t[0])}}this.cols=[],this.offset=0,this.before=[],this.lastOther=0,this.prevMax=0,this.debug=0,this.setColumnStart=null,this.elipsisText="";var i={width:400,columns:!1,buildOnce:!1,overflow:!1,doneFunc:function(){},target:!1,ignoreImageLoading:!0,columnFloat:"left",lastNeverTallest:!1,accuracy:!1,precise:!1,manualBreaks:!1,cssClassPrefix:"",cssClassClear:"clear",cssClassCol:"column",elipsisText:"...",debug:0};return t=e.extend(i,t),"string"==typeof t.width&&(t.width=parseInt(t.width,10),isNaN(t.width)&&(t.width=i.width)),"function"==typeof t.setColumnStart&&(this.setColumnStart=t.setColumnStart),"string"==typeof t.elipsisText&&(this.elipsisText=t.elipsisText),t.debug&&(this.debug=t.debug),t.setWidth||(t.setWidth=t.precise?function(e){return 100/e}:function(e){return Math.floor(100/e)}),this.each(function(){function n(e,t){var s=t?".":"";return m.length?s+m+"-"+e:s+e}function l(i,l,o,r){for(;(g||o.height()m&&-1!=p?u.substring(p):""}if(o.height()>=r&&null!==v&&(i[0].removeChild(v),u=v.nodeValue+u),!u.length)return!1;f[0].nodeValue=u}return l.contents().length?l.prepend(f):s(l,f),3==f[0].nodeType}}function o(e,t,i,r){if(!e.contents(":last").find(n("columnbreak",!0)).length&&!e.contents(":last").hasClass(n("columnbreak"))&&t.contents().length){var a=t.contents(":first");if("undefined"==typeof a.get(0)||1!=a.get(0).nodeType)return;var h=a.clone(!0);if(a.hasClass(n("columnbreak")))s(e,h),a.remove();else if(g)s(e,h),a.remove();else if(1==h.get(0).nodeType&&!h.hasClass(n("dontend")))if(s(e,h),h.is("img")&&i.height()")),$col=d.children().eq(d.children().length-1),$destroyable=c.clone(!0),t.overflow){for(targetHeight=t.overflow.height,l($col,$destroyable,$col,targetHeight),$destroyable.contents().find(":first-child").hasClass(n("dontend"))||o($col,$destroyable,$col,targetHeight);$col.contents(":last").length&&a($col.contents(":last").get(0));){var i=$col.contents(":last");i.remove(),$destroyable.prepend(i)}for(var r="",h=document.createElement("DIV");$destroyable[0].childNodes.length>0;){var f=$destroyable[0].childNodes[0];if(f.attributes)for(var u=0;u=i)return r();if(!d.data("columnizing")){d.data("columnized",!0),d.data("columnizing",!0),d.empty(),d.append(e("")),N=d.children(":last"),s(N,c.clone()),f=N.height(),d.empty();var b=f/i,C=3,y=!1;t.overflow?(C=1,b=t.overflow.height):m&&h&&(C=1,b=m,y=!0);for(var w=0;C>w&&20>w;w++){d.empty();var x,T,N,O;try{x=c.clone(!0)}catch(L){x=c.clone()}x.css("visibility","hidden");for(var $=0;i>$;$++)T=0===$?n("first"):"",T+=(""!=T?" ":"")+n(p),T=$==i-1?n("last")+" "+T:T,d.append(e(""));for($=0;$<=$&&d.append(e("")),N=d.children().eq($),y&&N.width(h+"px"),l(N,x,N,b),o(N,x,N,b);N.contents(":last").length&&a(N.contents(":last").get(0));)O=N.contents(":last"),O.remove(),x.prepend(O);$++,0===N.contents().length&&x.contents().length?N.append(x.contents(":first")):$!=i-(t.overflow?0:1)||t.overflow||x.find(n("columnbreak",!0)).length&&i++}if(t.overflow&&!y){var M=!1,k=document.all&&-1!=navigator.appVersion.indexOf("MSIE 7.");if(M||k){for(var I="",S=document.createElement("DIV");x[0].childNodes.length>0;){var z=x[0].childNodes[0];for($=0;$max&&(max=l,V=!0),F>l&&(F=l),numberOfColumnsThatDontEndInAColumnBreak++}}}(d));var E=B/numberOfColumnsThatDontEndInAColumnBreak;0===B?w=C:t.lastNeverTallest&&V?(adjustment+=5,b+=30,w==C-1&&C++):max-F>30?b=E+30:Math.abs(E-b)>20?b=E:w=C}d.append(e(""))}d.find(n(p,!0)).find(":first"+n("removeiffirst",!0)).remove(),d.find(n(p,!0)).find(":last"+n("removeiflast",!0)).remove(),d.find(n("split",!0)).find(":first"+n("removeiffirst",!0)).remove(),d.find(n("split",!0)).find(":last"+n("removeiflast",!0)).remove(),d.data("columnizing",!1),t.overflow&&t.overflow.doneFunc(),t.doneFunc()}}}var d=e(t.target?t.target:this),f=e(this).height(),c=e(""),u=adjustment=0,g=t.manualBreaks,m=i.cssClassPrefix,v=i.cssClassClear,p=i.cssClassCol;if("string"==typeof t.cssClassPrefix&&(m=t.cssClassPrefix),"string"==typeof t.cssClassClear&&(v=t.cssClassClear),"string"==typeof t.cssClassCol&&(p=t.cssClassCol),s(c,e(this).contents().clone(!0)),!t.ignoreImageLoading&&!t.target&&!d.data("imageLoaded")&&(d.data("imageLoaded",!0),e(this).find("img").length>0)){var b=function(e,i){return function(){e.data("firstImageLoaded")||(e.data("firstImageLoaded","true"),s(e.empty(),i.children().clone(!0)),e.columnize(t))}}(e(this),c);return e(this).find("img").one("load",b),void e(this).find("img").one("abort",b)}d.empty().addClass("columnized"),h(),t.buildOnce||e(window).resize(function(){t.buildOnce||(d.data("timeout")&&clearTimeout(d.data("timeout")),d.data("timeout",setTimeout(h,200)))})})},e.fn.renumberByJS=function(t,s,i,n){if(this.setList=function(t,s,i){var n,l=this.before.parents();if(n=e(t[this.offset-1]).find(">*"),n.last()[0].tagName!=i.toUpperCase())return this.debug&&console.log("Last item in previous column, isn't a list..."),0;n=n.length;var o=1;if(o=this.lastOther<=0?this.before.children().length+1:e(l[this.lastOther]).children().length+1,e(t[this.offset]).find(i+":first li.split").length){var r=e(t[this.offset-1]).find(i+":last li:last");if(""===this.elipsisText||e(t[this.offset-1]).find(i+":last ~ div").length||e(t[this.offset-1]).find(i+":last ~ p").length);else if(0==e(r).find("ul, ol, dl").length){var a=r.last().text(),h=a.length;";"==a.substring(h-1)?a.substring(h-4)!=this.elipsisText+";"&&(a=a.substring(0,h-1)+this.elipsisText+";"):a.substring(h-3)!=this.elipsisText&&(a+=this.elipsisText),r.last().text(a)}0==e(t[this.offset]).find(i+":first >li.split >"+i).length&&o--}if(1==n&&(o+=this.prevMax),this.nest>1){this.debug&&console.log("Supposed to be a nested list...decr"),o--;var d=e(t[this.offset-1]).find(i+":first li.split:first");d.length>0&&(this.debug&&console.log("Previous column started with a split item, so that count is one less than expected"),o--),d=e(t[this.offset]).find(i+":first li:first").clone(),d.children().remove(),e.trim(d.text()).length>0&&(this.debug&&console.log("If that was a complete list in the previous column, don't decr."),o++,0==e(t[this.offset-1]).find(">"+i+":last ").children().length&&(this.debug&&console.log("unless that was empty, in which case revert"),o--))}else{var d=e(t[this.offset]).find(i+":first li:first "+i+".split li.split");d.length>0&&(this.debug&&console.log("[Nested] Column started with a split item, so that count is one less than expected"),o--)}return this.debug&&console.log("Setting the start value to "+o+" ("+this.prevMax+")"),o>0&&("function"==typeof this.setColumnStart?this.setColumnStart(s,o):s.attr("start",o)),0},"undefined"==typeof i&&(i=!1),"undefined"==typeof n&&(n=!1),!i&&!n)throw"renumberByJS(): Bad param, must pass an id or a class";var l="";this.prevMax=1,l=n?"."+n:"#"+i;var o=t.toLowerCase(),r=t.toUpperCase();for(this.cols=e(l),this.debug&&console.log("There are "+this.cols.length+" items, looking for "+o),this.before=e(this.cols[0]).find(o+":last"),this.prevMax=this.before.children().length,this.offset=1;this.offset"+o+":first li "+o+":first").length&&(this.nest=2),this.setList(this.cols,a,o),this.lastOther--,a=e(this.cols[this.offset]).find(o+":first li "+o+":first"),a.length&&(this.before=e(this.cols[this.offset-1]).find(">"+o+":last li "+o+":last"),this.prevMax=0,this.nest=1,this.setList(this.cols,a,o));var c=e(this.cols[this.offset-1]).find(">"+o+":last");this.prevMax=c.children().length}}else this.debug&&console.log("First column (in theory..)"),this.prevMax=1;return 0}}(jQuery);