From 4e8fb086e9c242da21ed0047b64d089a7e0a6fa7 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Wed, 10 Aug 2011 21:03:46 -0400 Subject: [PATCH] Use openDialog to make go_print workaround vanish By passing params and the go_print function into openDialog we get to ignore race conditions, as the window is created with the passed in arguments. Oh, and we can stop using js2JSON and such. Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- .../xul/staff_client/chrome/content/util/print.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index aba38e9501..a470651ed2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -148,13 +148,11 @@ util.print.prototype = { switch(content_type) { case 'text/html' : - var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '}; function my_init() { if (typeof go_print == "function") { go_print(); } else { setTimeout( function() { if (typeof go_print == "function") { alert("Please tell the developers that the 2-second go_print workaround executed, and let them know whether this job printed successfully. Thanks!"); go_print(); } else { alert("Please tell the developers that the 2-second go_print workaround did not work. We will try to print one more time; there have been reports of wasted receipt paper at this point. Please check the settings in the print dialog and/or prepare to power off your printer. Thanks!"); window.print(); } }, 2000 ); } /* FIXME - mozilla bug#301560 - xpcom kills it too */ }'); + var jsrc = 'data:text/javascript,' + window.escape('var params = window.arguments[0]; window.go_print = window.arguments[1];'); var print_url = 'data:text/html,' + '' - + '' + window.escape(msg) + ''; - w = obj.win.open(print_url,'receipt_temp','chrome,resizable'); - w.minimize(); - w.go_print = function() { + + '' + window.escape(msg) + ''; + w = obj.win.openDialog(print_url,'receipt_temp','chrome,resizable,minimizable', null, { "data" : params.data, "list" : params.list}, function() { try { obj.NSPrint(w, silent, params); } catch(E) { @@ -162,7 +160,8 @@ util.print.prototype = { w.print(); } w.minimize(); w.close(); - } + }); + w.minimize(); break; default: w = obj.win.open('data:' + content_type + ',' + window.escape(msg),'receipt_temp','chrome,resizable'); -- 2.43.2