From 881ba12dc00fcde01ed1d50166fabbbcdc7d2462 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 12 Jul 2010 18:12:50 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@16911 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/util/browser.js | 3 ++ .../staff_client/chrome/content/util/print.js | 35 ++++++++++++++++--- 2 files changed, 33 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 ab877db56d..2b48aa83cc 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -54,6 +54,9 @@ util.browser.prototype = { 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 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 15c515994b..9f2bab6759 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -315,14 +315,39 @@ dump('params.print_strategy = ' + params.print_strategy + ' || obj.data.print_st 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; } -- 2.43.2