From 8031a2108427cde1bb33104e13e0180db33ea4eb Mon Sep 17 00:00:00 2001 From: pines Date: Fri, 3 Nov 2006 16:59:06 +0000 Subject: [PATCH] print tweaks.. checkout is bad because it can seems to break the print xpcom if the frame is destroyed too soon.. the current timeout is a kludge git-svn-id: svn://svn.open-ils.org/ILS/trunk@6557 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/print.js | 19 +++++++++++-------- Open-ILS/xul/staff_client/server/circ/checkout.js | 13 ++++++++++++- 2 files changed, 23 insertions(+), 9 deletions(-) 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 8b4cf5b61c..7343becfb5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -53,22 +53,22 @@ util.print.prototype = { var w; 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() { return go_print(); /* FIXME - mozilla bug#301560 - xpcom kills it too */ if (' + (typeof params.modal != 'undefined' ? 'true' : 'false') + ') setTimeout(function(){ try { window.print(); window.close(); } catch(E) { alert(E); } },0); }'); + 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 { alert("Please inform the developers that the go_print bug occurred. After this alert, we will try to print again."); window.print(); } /* FIXME - mozilla bug#301560 - xpcom kills it too */ if (' + (typeof params.modal != 'undefined' ? 'true' : 'false') + ') setTimeout(function(){ try { window.print(); window.close(); } catch(E) { alert(E); } },0); }'); w = obj.win.open('data:text/html,' + window.escape(msg) + '','receipt_temp','chrome,resizable'); w.minimize(); w.go_print = function() { - setTimeout( - function() { + //setTimeout( + // function() { try { obj.NSPrint(w, silent, params); } catch(E) { - obj.error.sdump('D_ERROR','util.print.simple: ' + E); + obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E); w.print(); } w.minimize(); w.close(); - }, 0 - ); + // }, 0 + //); } break; @@ -80,7 +80,7 @@ util.print.prototype = { try { obj.NSPrint(w, silent, params); } catch(E) { - obj.error.sdump('D_ERROR','util.print.simple: ' + E); + obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E); w.print(); } w.minimize(); w.close(); @@ -100,9 +100,10 @@ util.print.prototype = { } catch(E) { dump(E+'\n'); } - var cols; + var cols = []; // FIXME -- This could be done better.. instead of finding the columns and handling a tree dump, // we could do a dump_with_keys instead + /* switch(params.type) { case 'offline_checkout' : JSAN.use('circ.util'); @@ -186,6 +187,7 @@ util.print.prototype = { ); break; } + */ var s = this.template_sub( params.header, cols, params ); for (var i = 0; i < params.list.length; i++) { @@ -251,6 +253,7 @@ util.print.prototype = { try { if (typeof params.row != 'undefined') { if (params.row.length >= 0) { + alert('debug pause'); for (var i = 0; i < cols.length; i++) { var re = new RegExp(cols[i],"g"); try{b = s; s=s.replace(re, params.row[i]);} diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index 3aa1b7937f..2ce2dcc85f 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -282,7 +282,18 @@ circ.checkout.prototype = { if (silent) params.no_prompt = true; JSAN.use('util.print'); var print = new util.print(); print.tree_list( params ); - setTimeout(function(){obj.list.on_all_fleshed = null;if (typeof f == 'function') f();},0); + setTimeout( + function(){ + obj.list.on_all_fleshed = null; + if (typeof f == 'function') { + setTimeout( + function() { + f(); + }, 1000 + ) + } } + , 1000 + ); } catch(E) { obj.error.standard_unexpected_error_alert('print',E); } -- 2.11.0