Skip to content

Commit 73f94ee

Browse files
committed
Add eventlistener to enable print button
1 parent 768ca4f commit 73f94ee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

web/app.js

+16
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,22 @@ const PDFViewerApplication = {
20012001
opts
20022002
);
20032003
}
2004+
window.addEventListener("message", event => {
2005+
const origins = [
2006+
/^http:\/\/localhost:5000\/canvas_test.*/,
2007+
/^https:\/\/.*\.herokuapp\.com$/,
2008+
/^https:\/\/.*\.sharinpix\.com$/,
2009+
];
2010+
2011+
const originAllowed = origins.some(origin => origin.test(event.origin));
2012+
2013+
if (originAllowed && event.data.type === "image-download") {
2014+
const printButton = document.getElementById("printButton");
2015+
const secondaryPrintButton = document.getElementById("secondaryPrint");
2016+
printButton?.classList.remove("hidden");
2017+
secondaryPrintButton?.classList.remove("hidden");
2018+
}
2019+
});
20042020
},
20052021

20062022
bindWindowEvents() {

0 commit comments

Comments
 (0)