fix(print): Add print button to preview, don't print immediately (Fixes #1352)

This commit is contained in:
Ben Gotow 2016-02-19 19:07:22 -08:00
parent 9f8f1750cc
commit 5c8c139965
3 changed files with 33 additions and 7 deletions

View file

@ -26,6 +26,9 @@ export default class PrintWindow {
</head>
<body>
<div id="print-header">
<div onClick="continueAndPrint()" id="print-button">
Print
</div>
<div class="logo-wrapper">
<img src="${imgPath}" alt="nylas-logo"/>
<span class="account">${account.name} &lt;${account.email}&gt;</span>

View file

@ -1,6 +1,26 @@
body {
overflow: auto !important;
}
#print-button {
float:right;
margin-left: 10px;
/* From main button styles: */
padding: 0 0.8em;
border-radius: 3px;
display: inline-block;
height: 1.9em;
line-height: 1.9em;
font-size: 13.02px;
cursor: default;
color: #231f20;
position: relative;
color: #ffffff;
font-weight: 500;
background: linear-gradient(to bottom, #6bb1f9 0%, #0a80ff 100%);
box-shadow: none;
border: 1px solid #3878fa;
}
#print-header {
padding: 15px 20px 0 20px;
}

View file

@ -25,17 +25,20 @@
removeClassFromNodes(scrollContentInners, 'scroll-region-content-inner');
}
function print() {
window.print();
// Close this print window after selecting to print
// This is really hackish but appears to be the only working solution
setTimeout(window.close, 500);
function continueAndPrint() {
document.getElementById('print-button').style.display = 'none';
window.requestAnimationFrame(function() {
window.print();
// Close this print window after selecting to print
// This is really hackish but appears to be the only working solution
setTimeout(window.close, 500);
});
}
var messageNodes = document.querySelectorAll('.message-item-area>span');
removeScrollClasses();
rebuildMessages(messageNodes, window.printMessages);
// Give it a few ms before poppint out the print dialog
setTimeout(print, 50);
window.continueAndPrint = continueAndPrint;
})();