[open-ils-commits] r17270 - in trunk/Open-ILS/web/js: dojo/openils ui/default/acq/common (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 19 16:00:19 EDT 2010
Author: erickson
Date: 2010-08-19 16:00:14 -0400 (Thu, 19 Aug 2010)
New Revision: 17270
Modified:
trunk/Open-ILS/web/js/dojo/openils/Util.js
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
Log:
added util function for printing an html string; use new func for PO printing; TODO, use new func in selfcheck code to reduce duplication
Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js 2010-08-19 18:18:21 UTC (rev 17269)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js 2010-08-19 20:00:14 UTC (rev 17270)
@@ -361,5 +361,36 @@
dojo.forEach(patterns, function(pat) { _hilightNode(node, pat); });
};
+
+ /**
+ * Takes a chunk of HTML, inserts it into a new window, prints the window,
+ * then closes the windw. To provide ample printer queueing time, automatically
+ * wait a short time before closing the window after calling .print(). The amount
+ * of time to wait is based on the size of the data to be printed.
+ * @param html The HTML string
+ * @param callback Optional post-printing callback
+ */
+ openils.Util.printHtmlString = function(html, callback) {
+
+ var win = window.open('', 'Print Window', 'resizable,width=800,height=600,scrollbars=1');
+
+ // force the new window to the background
+ win.blur();
+ window.focus();
+
+ win.document.body.innerHTML = html;
+ win.print();
+
+ setTimeout(
+ function() {
+ win.close();
+ if(callback)
+ callback();
+ },
+ // 1k == 1 second pause, max 10 seconds
+ Math.min(html.length, 10000)
+ );
+ };
+
}
Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2010-08-19 18:18:21 UTC (rev 17269)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2010-08-19 20:00:14 UTC (rev 17270)
@@ -2076,8 +2076,7 @@
progressDialog.hide();
var evt = openils.Util.readResponse(r);
if(evt && evt.template_output()) {
- win = window.open('','', 'resizable,width=800,height=600,scrollbars=1');
- win.document.body.innerHTML = evt.template_output().data();
+ openils.Util.printHtmlString(evt.template_output().data());
}
}
}
More information about the open-ils-commits
mailing list