0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 21:52:43 +00:00

Move "printPage()" to helpers.js for reuse in multiple pages

This commit is contained in:
Trevor Buckner
2024-05-24 19:28:02 -04:00
parent e396211f92
commit ac3168e365
6 changed files with 27 additions and 56 deletions

View File

@@ -17,6 +17,18 @@ const splitTextStyleAndMetadata = (brew)=>{
}
};
module.exports = {
splitTextStyleAndMetadata
const printPage = ()=>{
if (window.typeof !== 'undefined') {
window.frames['BrewRenderer'].contentWindow.print();
//Force DOM reflow; Print dialog causes a repaint, and @media print CSS somehow makes out-of-view pages disappear
let node = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0);
node.style.display='none';
node.offsetHeight; // accessing this is enough to trigger a reflow
node.style.display='';
}
};
module.exports = {
splitTextStyleAndMetadata,
printPage
};