diff options
author | Mark Wells <mark@freeside.biz> | 2016-07-12 13:51:47 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-07-12 13:55:12 -0700 |
commit | 66eb3662102dbf92ac40fb8889c9c5051fd1ed29 (patch) | |
tree | 634cbd1655fa54dae4a19233a8eed159b0045b6f /httemplate/elements | |
parent | 408574c3f92b84f422f9a95dd0ab904d9c23ece6 (diff) |
workaround for page-break-inside:avoid on Chrome, #71301
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/freeside.css | 4 | ||||
-rw-r--r-- | httemplate/elements/printtofit.js | 17 | ||||
-rw-r--r-- | httemplate/elements/table-grid.html | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/httemplate/elements/freeside.css b/httemplate/elements/freeside.css index 8ad724a4f..3a6239e4b 100644 --- a/httemplate/elements/freeside.css +++ b/httemplate/elements/freeside.css @@ -313,3 +313,7 @@ td.label { color: #ff0000; } +/* but see printtofit.js */ +.nosplit, .nosplitrows tr { + page-break-inside: avoid; +} diff --git a/httemplate/elements/printtofit.js b/httemplate/elements/printtofit.js index 66257fca8..98236026e 100644 --- a/httemplate/elements/printtofit.js +++ b/httemplate/elements/printtofit.js @@ -1,13 +1,30 @@ $().ready(function() { + // yuck + var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); var beforePrint = function() { if ($('body').width() > 0) { // 7.5 inches * 96 DPI; maybe make the width a user pref? var maxwidth = 7.5 * 96; $('body').css('zoom', maxwidth / $('body').width()); + if (isChrome) { + // Chrome doesn't respect page-break-* styles on table rows/cells, + // so wrap the contents of table cells with a block element + // ref. Chromium bug #99124, #87828, #59193 + // should be fixed with Chrome 53 + var nosplits = $('.nosplitrows td'); + if (nosplits.length > 0) { + nosplits.wrapInner('<div class="nosplit autowrap" />'); + } + } } }; var afterPrint = function() { $('body').css('zoom', 1); + // get the direct children of the wrapper divs. + var nosplits = $('div.autowrap >'); + if (nosplits.length > 0) { + nosplits.unwrap(); + } } if (window.matchMedia) { // chrome, most importantly; also IE10? diff --git a/httemplate/elements/table-grid.html b/httemplate/elements/table-grid.html index 4f4200570..bf60fe03e 100644 --- a/httemplate/elements/table-grid.html +++ b/httemplate/elements/table-grid.html @@ -1,4 +1,4 @@ -<TABLE CLASS="grid" CELLSPACING=<% $opt{cellspacing} %> CELLPADDING=<% $opt{cellpadding} %> <% $opt{bgcolor} %>> +<TABLE CLASS="grid nosplitrows" CELLSPACING=<% $opt{cellspacing} %> CELLPADDING=<% $opt{cellpadding} %> <% $opt{bgcolor} %>> <%init> |