From aa60fce1569e4b302e38c8e4605f0f693c1f12ac Mon Sep 17 00:00:00 2001 From: Dave Zaccaria Date: Tue, 26 May 2020 17:34:02 -0400 Subject: [PATCH] Updating interactive notes save as pdf to work across more browsers (chrome & ios safari) - Switching from document.write to innerHTML for interactive note printing to avoid Chrome bugs - Adding a longer timeout before trying to print and close to fix a race condition in ios --- src/assets/base.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/assets/base.js b/src/assets/base.js index a717c00..a717efc 100644 --- a/src/assets/base.js +++ b/src/assets/base.js @@ -56,22 +56,23 @@ var today_pretty = new Date().toDateString(); var mywindow = window.open("", "new div", "height=800,width=800"); - mywindow.document.write("Sermon Notes"); + var mywindowHTML = "Sermon Notes"; /* optional stylesheet */ - mywindow.document.write( - '' - ); - mywindow.document.write( - '
' - ); - mywindow.document.write("

" + title + "

"); - mywindow.document.write("

" + today_pretty + "


"); - mywindow.document.write($(notes_text).html()); - mywindow.document.write("
"); + mywindowHTML += ''; + mywindowHTML += '
'; + mywindowHTML += "

" + title + "

"; + mywindowHTML += "

" + today_pretty + "


"; + mywindowHTML += $(notes_text).html(); + mywindowHTML += "
"; + + mywindow.document.body.innerHTML = mywindowHTML; + setTimeout(function() { mywindow.print(); - mywindow.close(); - }, 50); + setTimeout(function() { + mywindow.close(); + }, 1000); + }, 500); return true; }