From 085a83b75e2f803d32a07836fc1cc9f6f6eae111 Mon Sep 17 00:00:00 2001 From: dbs Date: Mon, 30 Aug 2010 14:13:00 +0000 Subject: [PATCH] Use different label printing strategies for XUL 1.9.2 vs. 1.9.0 r16421 contained a fix for printing in XUL 1.9.2 that appears to have broken printing in XUL 1.9.0. This change should switch back to the old style of printing if XUL 1.9.0 is detected, and otherwise uses the 1.9.2 strategy for any other version of XUL. git-svn-id: svn://svn.open-ils.org/ILS/trunk@17367 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/cat/spine_labels.js | 69 ++++++++++++++++++---- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/spine_labels.js b/Open-ILS/xul/staff_client/server/cat/spine_labels.js index 5b24e18a05..9d6e029e38 100644 --- a/Open-ILS/xul/staff_client/server/cat/spine_labels.js +++ b/Open-ILS/xul/staff_client/server/cat/spine_labels.js @@ -551,22 +551,65 @@ } } html += ''; - var loc = ( urls.XUL_BROWSER ); - xulG.new_tab( - loc, - { - 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title') - }, - { - 'url' : 'data:text/html;charset=utf-8,'+window.escape(html), - 'html_source' : html, - 'show_print_button' : 1, - 'no_xulG' : 1 - } - ); + + /* From https://developer.mozilla.org/en/Using_nsIXULAppInfo */ + var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); + var platformVer = appInfo.platformVersion; + + /* We need to use different print strategies for different + * XUL versions, apparently + */ + if (platformVer.substr(0, 5) == '1.9.0') { + preview_xul_190(html); + } else { + preview_xul_192(html); + } + + } catch(E) { g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E); } } + function preview_xul_190(html) { + JSAN.use('util.window'); var win = new util.window(); + var loc = ( urls.XUL_REMOTE_BROWSER ); + //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels'); + var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550'); + w.xulG = { + 'url' : 'about:blank', + 'show_print_button' : 1, + 'alternate_print' : 1, + 'no_xulG' : 1, + 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'), + 'on_url_load' : function(b) { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + if (typeof w.xulG.written == 'undefined') { + w.xulG.written = true; + w.g.browser.get_content().document.write(html); + w.g.browser.get_content().document.close(); + } + } catch(E) { + alert(E); + } + } + }; + } + function preview_xul_192(html) { + var loc = ( urls.XUL_BROWSER ); + xulG.new_tab( + loc, + { + 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title') + }, + { + 'url' : 'data:text/html;charset=utf-8,'+window.escape(html), + 'html_source' : html, + 'show_print_button' : 1, + 'no_xulG' : 1 + } + ); + } -- 2.11.0