From 5df8934c7093e21b3f1ec3ab91ca43d6aab18639 Mon Sep 17 00:00:00 2001 From: Jan Grzegorowski Date: Sat, 7 Jan 2017 14:30:38 +0100 Subject: [PATCH 01/11] feat: add disableSingle option --- src/jquery.columnizer.js | 5 ++++- src/jquery.columnizer.min.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 6e94a29..0df4a09 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -53,6 +53,9 @@ precise : false, // don't automatically layout columns, only use manual columnbreak manualBreaks : false, + // disable single column layout when container width < columnWidth + // (useful for horizontally scrollable columns in mobile view) + disableSingle : false, // previx for all the CSS classes used by this plugin // default to empty string for backwards compatibility cssClassPrefix : "", @@ -471,7 +474,7 @@ // if ($inBox.data("columnized") && numCols == $inBox.children().length) { // return; // } - if(numCols <= 1){ + if(numCols <= 1 && ! options.disableSingle){ return singleColumnizeIt(); } if($inBox.data("columnizing")) return; diff --git a/src/jquery.columnizer.min.js b/src/jquery.columnizer.min.js index a4b6fa8..51f5aad 100644 --- a/src/jquery.columnizer.min.js +++ b/src/jquery.columnizer.min.js @@ -1,5 +1,5 @@ -(function($){var DATA_ORIGINAL_DOM_KEY='columnizer-original-dom';$.fn.columnize=function(options){this.each(function(){var $el=$(this);$el.data(DATA_ORIGINAL_DOM_KEY,$el.clone(true,true));});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;}} +(function($){var DATA_ORIGINAL_DOM_KEY='columnizer-original-dom';$.fn.columnize=function(options){this.each(function(){var $el=$(this);$el.data(DATA_ORIGINAL_DOM_KEY,$el.clone(true,true));});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,disableSingle: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;} @@ -42,7 +42,7 @@ function checkDontEndColumn(dom){if(dom.nodeType==3){if(/^\s+$/.test(dom.nodeVal return false;} if(dom.nodeType!=1)return false;if($(dom).hasClass(prefixTheClassName("dontend")))return true;if(dom.childNodes.length===0)return false;return checkDontEndColumn(dom.childNodes[dom.childNodes.length-1]);} function columnizeIt(){adjustment=0;if(lastWidth==$inBox.width())return;lastWidth=$inBox.width();var numCols=Math.round($inBox.width()/options.width);var optionWidth=options.width;var optionHeight=options.height;if(options.columns)numCols=options.columns;if(manualBreaks){numCols=$cache.find(prefixTheClassName("columnbreak",true)).length+1;optionWidth=false;} -if(numCols<=1){return singleColumnizeIt();} +if(numCols<=1&&!disableSingle){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
"));} @@ -87,4 +87,4 @@ var $parents=this.before.parents();this.lastOther=0;var $found=false;for(;this.l this.nest=1;if($(this.cols[this.offset]).find(">"+$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 +return 0;};})(jQuery); From 5a8a290b06fe003446c677ca23c811245baf137a Mon Sep 17 00:00:00 2001 From: Jan Grzegorowski Date: Sat, 7 Jan 2017 14:38:53 +0100 Subject: [PATCH 02/11] docs: add disableSingle option description --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2ea97f4..4e046a2 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,12 @@ Columnizer will add CSS classes to the columns it creates. Each column will have manualBreaks Defaults to false. Set to true if you only want to create columns with manual column breaks. If true, then width, height, columns options are ignored. + +disableSingle + +Disables single column layout if number of columns is less or equal to 1. Useful to force columns scrolling horizontally on small screens. See demo 5 for an example.. Default is false. + + From 25f3c88c7ce6e3456a3ac6ecac00efa429e320d4 Mon Sep 17 00:00:00 2001 From: simonmeadows Date: Fri, 31 Mar 2017 14:13:25 +0100 Subject: [PATCH 03/11] Added preserving thead and tfoot in tables In the columnize function we can check weather we are in a table by testing the first child of $pullOutHere If we are in a table we can clone a copy of the and if they exist and store thim in the columnize function that is operating on the table. When we get to splitting the last element we add the and back to the table in the content source element $pullOutHere --- src/jquery.columnizer.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 0df4a09..00ee7f5 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -186,6 +186,12 @@ * @param targetHeight, the ideal height for the column, get as close as we can to this height */ function columnize($putInHere, $pullOutHere, $parentColumn, targetHeight){ + + // Variables for dealing with and when splitting tables + // As we split a table we need to keep copies of the and to place on each column + var $thead; + var $tfoot; + // // add as many nodes to the column as we can, // but stop once our height is too tall @@ -205,6 +211,25 @@ // our column is on a column break, so just end here return; } + + // If we enter a element make a copy of and + // to use each time the
splits + if (node.nodeName=='TABLE'){ + // Check if the table has a header and clone it + if ($(node).find('thead').length>0){ + this.$thead = $(node).find('thead').clone(); + } else { + this.$thead = undefined; + } + // Check if the table has a footer and clone it + if ($(node).find('tfoot').length>0){ + this.$tfoot = $(node).find('tfoot').clone(); + } else { + this.$tfoot = undefined; + } + } + + appendSafe($putInHere, $(node)); } if($putInHere[0].childNodes.length === 0) return; @@ -370,6 +395,17 @@ } } } + // If we are in the process of splitting a table, add the and + // clones back to $pullOutHere so they are available to move into the next column + if($pullOutHere.prop('tagName') == 'TABLE'){ + if (this.$thead){ + $pullOutHere.prepend(this.$tfoot); + } + if (this.$thead) { + $pullOutHere.prepend(this.$thead); + } + } + } From 0d20d114748802f5cf854dfc9f9cd17ef393504e Mon Sep 17 00:00:00 2001 From: Simon Meadows Date: Sat, 1 Apr 2017 01:17:02 +0100 Subject: [PATCH 04/11] Added test pages for thead and tfoot --- test/nested_thead_tfoot.html | 1437 ++++++++++++++++++++++++++++++++++ test/thead_tfoot.html | 637 +++++++++++++++ 2 files changed, 2074 insertions(+) create mode 100644 test/nested_thead_tfoot.html create mode 100644 test/thead_tfoot.html diff --git a/test/nested_thead_tfoot.html b/test/nested_thead_tfoot.html new file mode 100644 index 0000000..a83d86d --- /dev/null +++ b/test/nested_thead_tfoot.html @@ -0,0 +1,1437 @@ + + + + + + Columnizer JQuery Plugin thead tfoot test page + + + + + + + + +
+
+

Columnize nested tables with repeating thead and tfoot

+

This is a test page to show how columnizing works with repeating thead and tfoot in nested tables

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-- Header 1 ---- Header 2 ---- Header 3 --
-- Footer 1 ---- Footer 2 ---- Footer 3 --
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Header AHeader BHeader CHeader D
Footer AFooter BFooter CFooter D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-- Header Only X ---- Header Only Y --
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
Column XColumn Y
+
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
Column AColumn BColumn CColumn D
+ + + + +
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
+ + + + + + + \ No newline at end of file diff --git a/test/thead_tfoot.html b/test/thead_tfoot.html new file mode 100644 index 0000000..e30e0de --- /dev/null +++ b/test/thead_tfoot.html @@ -0,0 +1,637 @@ + + + + + + Columnizer JQuery Plugin thead tfoot test page + + + + + + + + +
+
+

Columnize with repeating thead and tfoot

+

This is a test page to show how columnizing works with repeating thead and tfoot

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-- Header 1 ---- Header 2 ---- Header 3 --
-- Footer 1 ---- Footer 2 ---- Footer 3 --
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
Column 1Column 2Column 3
+
+ + +
+ + + \ No newline at end of file From 54dec55cf1610271851d92a4827bd4028b622960 Mon Sep 17 00:00:00 2001 From: Simon Meadows Date: Sat, 1 Apr 2017 01:17:48 +0100 Subject: [PATCH 05/11] Re-Worked to allow for nested tables --- src/jquery.columnizer.js | 83 ++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 00ee7f5..c8bdc39 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -64,6 +64,67 @@ }; options = $.extend(defaults, options); + // Variable array for holding and from each table + // As we split a table we need to keep copies of the and to place on each column + var tables = new Array(); + + // Find all the table elements in the page + $('table').each(function () { + // Check if we have not already saved the and + if (!$(this).hasClass('tableSaved')) { + // Mark the found table by adding the .tableSaved class + $(this).addClass('tableSaved') + // Give the table a unique ID so we can re-add its elements later + $(this).addClass('tableID-' + tables.length) + // Save the tables unique ID, , and as an object in our tables array + tables.push({ + tableID: 'tableID-' + tables.length, + thead: $(this).find('thead:first').clone(), + tfoot: $(this).find('tfoot:first').clone() + }); + } + }); + + // Function to add and to all tables in $pullOutHere + // This function should be called anywhere split() returns as + // that is the point where a column is complete and the remaining content + // is not going to change until the next columnize() is called + function fixTables($pullOutHere) { + // Iterate through all of our saved tables + for (i = 0; i < tables.length; i++) { + // Check if the root element is a table + if ($pullOutHere.is("table")) { + // Check if the root element has any elements and + // is the current table id for this loop + if ($pullOutHere.children('tfoot').length == 0 && + $pullOutHere.hasClass(tables[i].tableID)) { + // Add the to the table + $(tables[i].tfoot).clone().prependTo($pullOutHere); + } + // Check if the root element has any elements and + // is the current table id for this loop + if ($pullOutHere.children('thead').length == 0 && + $pullOutHere.hasClass(tables[i].tableID)) { + // Add the to the table + $(tables[i].thead).clone().prependTo($pullOutHere); + } + } + // Check if there are any child tables to the root element with the current table ID + $pullOutHere.find('table .' + tables[i].tableID).each(function () { + // Check if the child table has no + if ($(this).children('tfoot').length == 0) { + // Add the to the table + $(tables[i].tfoot).clone().prependTo(this); + } + // Check if the child table has no + if ($(this).children('thead').length == 0) { + // Add the to the table + $(tables[i].thead).clone().prependTo(this); + } + }); + } + } + if(typeof(options.width) == "string"){ options.width = parseInt(options.width,10); if(isNaN(options.width)){ @@ -187,11 +248,6 @@ */ function columnize($putInHere, $pullOutHere, $parentColumn, targetHeight){ - // Variables for dealing with and when splitting tables - // As we split a table we need to keep copies of the and to place on each column - var $thead; - var $tfoot; - // // add as many nodes to the column as we can, // but stop once our height is too tall @@ -300,11 +356,15 @@ */ function split($putInHere, $pullOutHere, $parentColumn, targetHeight){ if($putInHere.contents(":last").find(prefixTheClassName("columnbreak", true)).length){ + // Fix any tables that have had their and moved + fixTables($pullOutHere); // // our column is on a column break, so just end here return; } if($putInHere.contents(":last").hasClass(prefixTheClassName("columnbreak"))){ + // Fix any tables that have had their and moved + fixTables($pullOutHere); // // our column is on a column break, so just end here return; @@ -395,17 +455,8 @@ } } } - // If we are in the process of splitting a table, add the and - // clones back to $pullOutHere so they are available to move into the next column - if($pullOutHere.prop('tagName') == 'TABLE'){ - if (this.$thead){ - $pullOutHere.prepend(this.$tfoot); - } - if (this.$thead) { - $pullOutHere.prepend(this.$thead); - } - } - + // Fix any tables that have had their and moved + fixTables($pullOutHere); } From 2cf78b7f30e89afcbcebf43d2518628fa5f161f2 Mon Sep 17 00:00:00 2001 From: Simon Meadows Date: Sat, 1 Apr 2017 01:23:36 +0100 Subject: [PATCH 06/11] moved test to samples --- test/nested_thead_tfoot.html => samples/nested_table_headers.html | 0 test/thead_tfoot.html => samples/table_headers.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/nested_thead_tfoot.html => samples/nested_table_headers.html (100%) rename test/thead_tfoot.html => samples/table_headers.html (100%) diff --git a/test/nested_thead_tfoot.html b/samples/nested_table_headers.html similarity index 100% rename from test/nested_thead_tfoot.html rename to samples/nested_table_headers.html diff --git a/test/thead_tfoot.html b/samples/table_headers.html similarity index 100% rename from test/thead_tfoot.html rename to samples/table_headers.html From ac92a9ca34091a416bc7d91e4b24b5258756d446 Mon Sep 17 00:00:00 2001 From: Simon Meadows Date: Sat, 1 Apr 2017 01:39:27 +0100 Subject: [PATCH 07/11] removed non required bit I missed --- src/jquery.columnizer.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index c8bdc39..4aaf455 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -268,24 +268,6 @@ return; } - // If we enter a element make a copy of and - // to use each time the
splits - if (node.nodeName=='TABLE'){ - // Check if the table has a header and clone it - if ($(node).find('thead').length>0){ - this.$thead = $(node).find('thead').clone(); - } else { - this.$thead = undefined; - } - // Check if the table has a footer and clone it - if ($(node).find('tfoot').length>0){ - this.$tfoot = $(node).find('tfoot').clone(); - } else { - this.$tfoot = undefined; - } - } - - appendSafe($putInHere, $(node)); } if($putInHere[0].childNodes.length === 0) return; From 7b6a532f034c98d9cd6fa3b64533b59391d39a08 Mon Sep 17 00:00:00 2001 From: Daniel Heffner Date: Mon, 19 Aug 2019 11:04:20 -0400 Subject: [PATCH 08/11] master: Fix for jQuery deprecation of event shorthand: resize --- src/jquery.columnizer.js | 2 +- src/jquery.columnizer.min.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 4aaf455..7536e0b 100644 --- a/src/jquery.columnizer.js +++ b/src/jquery.columnizer.js @@ -212,7 +212,7 @@ columnizeIt(); if(!options.buildOnce){ - $(window).resize(function() { + $(window).on('resize', function() { if(!options.buildOnce){ if($inBox.data("timeout")){ clearTimeout($inBox.data("timeout")); diff --git a/src/jquery.columnizer.min.js b/src/jquery.columnizer.min.js index 51f5aad..ea7d311 100644 --- a/src/jquery.columnizer.min.js +++ b/src/jquery.columnizer.min.js @@ -1,5 +1,11 @@ -(function($){var DATA_ORIGINAL_DOM_KEY='columnizer-original-dom';$.fn.columnize=function(options){this.each(function(){var $el=$(this);$el.data(DATA_ORIGINAL_DOM_KEY,$el.clone(true,true));});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,disableSingle: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;}} +(function($){var DATA_ORIGINAL_DOM_KEY='columnizer-original-dom';$.fn.columnize=function(options){this.each(function(){var $el=$(this);$el.data(DATA_ORIGINAL_DOM_KEY,$el.clone(true,true));});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,disableSingle:false,cssClassPrefix:"",elipsisText:'...',debug:0};options=$.extend(defaults,options);var tables=new Array();$('table').each(function(){if(!$(this).hasClass('tableSaved')){$(this).addClass('tableSaved') +$(this).addClass('tableID-'+tables.length) +tables.push({tableID:'tableID-'+tables.length,thead:$(this).find('thead:first').clone(),tfoot:$(this).find('tfoot:first').clone()});}});function fixTables($pullOutHere){for(i=0;i');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.empty();columnizeIt();if(!options.buildOnce){$(window).on('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;} @@ -21,11 +27,12 @@ if($parentColumn.height()>=targetHeight&&latestTextNode!==null){$putInHere[0].re 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;} +function split($putInHere,$pullOutHere,$parentColumn,targetHeight){if($putInHere.contents(":last").find(prefixTheClassName("columnbreak",true)).length){fixTables($pullOutHere);return;} +if($putInHere.contents(":last").hasClass(prefixTheClassName("columnbreak"))){fixTables($pullOutHere);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(":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
"));} @@ -87,4 +94,4 @@ var $parents=this.before.parents();this.lastOther=0;var $found=false;for(;this.l this.nest=1;if($(this.cols[this.offset]).find(">"+$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); +return 0;};})(jQuery); \ No newline at end of file From b2d64e775ae279c04ecb4b450c8ca567a566aea3 Mon Sep 17 00:00:00 2001 From: Adam Wulf Date: Tue, 20 Aug 2019 02:03:31 -0500 Subject: [PATCH 09/11] Proper php tag --- tools/compress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/compress.php b/tools/compress.php index a59c1c7..961856b 100644 --- a/tools/compress.php +++ b/tools/compress.php @@ -1,4 +1,4 @@ - Date: Sun, 11 Apr 2021 00:02:29 -0500 Subject: [PATCH 10/11] github sponsorship --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..854756b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: adamwulf +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 9292f215c1eadb7e41abf39a3c56d73d7ae82083 Mon Sep 17 00:00:00 2001 From: Adam Wulf Date: Sun, 11 Apr 2021 00:41:16 -0500 Subject: [PATCH 11/11] updated readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4e046a2..cd1970e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +## Support + +Has Columnizer saved you hours? Become a [Github Sponsor](https://github.com/sponsors/adamwulf) and buy me a coffee ☕️ 😄 + ## Documentation ### CSS Classes for Created Columns