From 4a7247b3c34aa7878482dcb7c461c9719c7b96d4 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 4 Aug 2010 08:48:47 +0000 Subject: [PATCH] previous changes to better support the embedded browser Print button broke printing elsewhere git-svn-id: svn://svn.open-ils.org/ILS/trunk@17071 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/browser.js | 2 ++ .../xul/staff_client/chrome/content/util/print.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.js b/Open-ILS/xul/staff_client/chrome/content/util/browser.js index 2b48aa83c..d55291a50 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -53,9 +53,11 @@ util.browser.prototype = { var print_params = {}; if (obj.html_source) { print_params.msg = obj.html_source; + print_params.content_type = 'text/html'; } if (typeof content.printable_output == 'function') { print_params.msg = content.printable_output(); + print_params.content_type = 'text/plain'; } JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve(); if (data.print_strategy == 'webBrowserPrint' || !data.print_strategy) { 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 9f2bab675..8265d3a10 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -127,7 +127,10 @@ 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 */ }'); - w = obj.win.open('data:text/html,' + window.escape(msg) + '','receipt_temp','chrome,resizable'); + 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() { try { @@ -315,10 +318,14 @@ dump('params.print_strategy = ' + params.print_strategy + ' || obj.data.print_st obj._NSPrint_custom_print(w,silent,params); break; case 'window.print': - if (! params.msg) { + if (typeof w == 'object') { w.print(); } else { - w = window.open('data:text/plain,'+escape(params.msg)); + if (params.content_type == 'text/plain') { + w = window.open('data:text/plain,'+escape(params.msg)); + } else { + w = window.open('data:text/html,'+escape(params.msg)); + } setTimeout( function() { w.print(); @@ -333,10 +340,14 @@ dump('params.print_strategy = ' + params.print_strategy + ' || obj.data.print_st break; case 'webBrowserPrint': default: - if (! params.msg) { + if (typeof w == 'object') { obj._NSPrint_webBrowserPrint(w,silent,params); } else { - w = window.open('data:text/plain,'+escape(params.msg)); + if (params.content_type == 'text/plain') { + w = window.open('data:text/plain,'+escape(params.msg)); + } else { + w = window.open('data:text/html,'+escape(params.msg)); + } setTimeout( function() { obj._NSPrint_webBrowserPrint(w,silent,params); -- 2.11.0