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

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jul 12 14:12:54 EDT 2010


Author: phasefx
Date: 2010-07-12 14:12:50 -0400 (Mon, 12 Jul 2010)
New Revision: 16911

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
Log:
printing the contents of iframes is sometimes problematic, especially with complex DHTML, etc.  This change allows content to define a printable_output() function for simple text to print instead of the rendered content itself


Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-07-12 17:09:23 UTC (rev 16910)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-07-12 18:12:50 UTC (rev 16911)
@@ -54,6 +54,9 @@
                                     if (obj.html_source) {
                                         print_params.msg = obj.html_source;
                                     }
+                                    if (typeof content.printable_output == 'function') {
+                                        print_params.msg = content.printable_output();
+                                    }
                                     JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
                                     if (data.print_strategy == 'webBrowserPrint' || !data.print_strategy) {
                                         // Override the print strategy temporarily in this context

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-07-12 17:09:23 UTC (rev 16910)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/print.js	2010-07-12 18:12:50 UTC (rev 16911)
@@ -315,14 +315,39 @@
                         obj._NSPrint_custom_print(w,silent,params);
                     break;    
                     case 'window.print':
-                        w.print();
+                        if (! params.msg) {
+                            w.print();
+                        } else {
+                            w = window.open('data:text/plain,'+escape(params.msg));
+                            setTimeout(
+                                function() {
+                                    w.print();
+                                    setTimeout(
+                                        function() {
+                                            w.close(); 
+                                        }, 2000
+                                    );
+                                }, 0
+                            );
+                        }
                     break;    
                     case 'webBrowserPrint':
-                        obj._NSPrint_webBrowserPrint(w,silent,params);
-                    break;    
                     default:
-                        //w.print();
-                        obj._NSPrint_webBrowserPrint(w,silent,params);
+                        if (! params.msg) {
+                            obj._NSPrint_webBrowserPrint(w,silent,params);
+                        } else {
+                            w = window.open('data:text/plain,'+escape(params.msg));
+                            setTimeout(
+                                function() {
+                                    obj._NSPrint_webBrowserPrint(w,silent,params);
+                                    setTimeout(
+                                        function() {
+                                            w.close(); 
+                                        }, 2000
+                                    );
+                                }, 0
+                            );
+                        }
                     break;    
                 }
 



More information about the open-ils-commits mailing list