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'] diff --git a/README.md b/README.md index 2ea97f4..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 @@ -67,6 +71,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. + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..aba52f2 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "jquery-columnizer", + "version": "1.6.3", + "description": "The Columnizer jQuery Plugin will automatically layout your content in newspaper column format. You can specify either column width or a static number of columns.", + "main": "src/jquery.columnizer.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/adamwulf/Columnizer-jQuery-Plugin.git" + }, + "keywords": [ + "jquery", + "columns", + "columnizer", + "text", + "layout", + "jquery-plugin" + ], + "author": "Adam Wulf", + "license": "SEE LICENSE IN LICENSE", + "bugs": { + "url": "https://github.com/adamwulf/Columnizer-jQuery-Plugin/issues" + }, + "homepage": "https://github.com/adamwulf/Columnizer-jQuery-Plugin#readme" +} diff --git a/samples/nested_table_headers.html b/samples/nested_table_headers.html new file mode 100644 index 0000000..a83d86d --- /dev/null +++ b/samples/nested_table_headers.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/samples/table_headers.html b/samples/table_headers.html new file mode 100644 index 0000000..e30e0de --- /dev/null +++ b/samples/table_headers.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 diff --git a/src/jquery.columnizer.js b/src/jquery.columnizer.js index 6e94a29..7536e0b 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 : "", @@ -61,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)){ @@ -148,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")); @@ -183,6 +247,7 @@ * @param targetHeight, the ideal height for the column, get as close as we can to this height */ function columnize($putInHere, $pullOutHere, $parentColumn, targetHeight){ + // // add as many nodes to the column as we can, // but stop once our height is too tall @@ -202,6 +267,7 @@ // our column is on a column break, so just end here return; } + appendSafe($putInHere, $(node)); } if($putInHere[0].childNodes.length === 0) return; @@ -272,11 +338,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; @@ -367,6 +437,8 @@ } } } + // Fix any tables that have had their and moved + fixTables($pullOutHere); } @@ -471,7 +543,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..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,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
"));} 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 @@ -