[open-ils-commits] r17071 - trunk/Open-ILS/xul/staff_client/chrome/content/util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Aug 4 04:48:52 EDT 2010


Author: phasefx
Date: 2010-08-04 04:48:47 -0400 (Wed, 04 Aug 2010)
New Revision: 17071

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
Log:
previous changes to better support the embedded browser Print button broke printing elsewhere

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-08-04 03:56:35 UTC (rev 17070)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-08-04 08:48:47 UTC (rev 17071)
@@ -53,9 +53,11 @@
                                     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) {

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-08-04 03:56:35 UTC (rev 17070)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-08-04 08:48:47 UTC (rev 17071)
@@ -127,7 +127,10 @@
             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,<html id="top"><head><script src="/xul/server/main/JSAN.js"></script><script src="' + window.escape(jsrc) + '"></script></head><body onload="try{my_init();}catch(E){alert(E);}">' + window.escape(msg) + '</body></html>','receipt_temp','chrome,resizable');
+                    var print_url = 'data:text/html,'
+                        + '<html id="top"><head><script src="/xul/server/main/JSAN.js"></script><script src="' + window.escape(jsrc) + '"></script></head>'
+                        + '<body onload="try{my_init();}catch(E){alert(E);}">' + window.escape(msg) + '</body></html>';
+                    w = obj.win.open(print_url,'receipt_temp','chrome,resizable');
                     w.minimize();
                     w.go_print = function() { 
                         try {
@@ -315,10 +318,14 @@
                         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 @@
                     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);



More information about the open-ils-commits mailing list