|
41 | 41 | // text nodes. smaller numbers will result in higher accuracy |
42 | 42 | // column widths, but will take slightly longer |
43 | 43 | accuracy : false, |
| 44 | + // false to round down column widths (for compatibility) |
| 45 | + // true to conserve all decimals in the column widths |
| 46 | + precise : false, |
44 | 47 | // don't automatically layout columns, only use manual columnbreak |
45 | 48 | manualBreaks : false, |
46 | 49 | // previx for all the CSS classes used by this plugin |
|
65 | 68 | } |
66 | 69 | if(options.debug) { // assert is off by default |
67 | 70 | this.debug=options.debug; |
68 | | - } |
| 71 | + } |
| 72 | + if(!options.setWidth) { |
| 73 | + if (options.precise) { |
| 74 | + options.setWidth = function (numCols) { |
| 75 | + return 100 / numCols; |
| 76 | + }; |
| 77 | + } else { |
| 78 | + options.setWidth = function (numCols) { |
| 79 | + return Math.floor(100 / numCols); |
| 80 | + }; |
| 81 | + } |
| 82 | + } |
69 | 83 |
|
70 | 84 | /** |
71 | 85 | * appending a text node to a <table> will |
|
445 | 459 | $inBox.data("columnizing", true); |
446 | 460 |
|
447 | 461 | $inBox.empty(); |
448 | | - $inBox.append($("<div style='width:" + (Math.floor(100 / numCols))+ "%; float: " + options.columnFloat + ";'></div>")); //" |
| 462 | + $inBox.append($("<div style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //" |
449 | 463 | $col = $inBox.children(":last"); |
450 | 464 | appendSafe($col, $cache.clone()); |
451 | 465 | maxHeight = $col.height(); |
|
488 | 502 | className = (i === 0) ? prefixTheClassName("first") : ""; |
489 | 503 | className += " " + prefixTheClassName("column"); |
490 | 504 | className = (i == numCols - 1) ? (prefixTheClassName("last") + " " + className) : className; |
491 | | - $inBox.append($("<div class='" + className + "' style='width:" + (Math.floor(100 / numCols))+ "%; float: " + options.columnFloat + ";'></div>")); //" |
| 505 | + $inBox.append($("<div class='" + className + "' style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //" |
492 | 506 | } |
493 | 507 |
|
494 | 508 | // fill all but the last column (unless overflowing) |
495 | 509 | i = 0; |
496 | 510 | while(i < numCols - (options.overflow ? 0 : 1) || scrollHorizontally && $destroyable.contents().length){ |
497 | 511 | if($inBox.children().length <= i){ |
498 | 512 | // we ran out of columns, make another |
499 | | - $inBox.append($("<div class='" + className + "' style='width:" + (Math.floor(100 / numCols))+ "%; float: " + options.columnFloat + ";'></div>")); //" |
| 513 | + $inBox.append($("<div class='" + className + "' style='width:" + options.setWidth(numCols) + "%; float: " + options.columnFloat + ";'></div>")); //" |
500 | 514 | } |
501 | 515 | $col = $inBox.children().eq(i); |
502 | 516 | if(scrollHorizontally){ |
|
0 commit comments