Credit card payments working with printable receipts
[evergreen-equinox.git] / Open-ILS / web / js / ui / default / opac / simple.js
index 776dfef..d71c98a 100644 (file)
@@ -27,3 +27,24 @@ function addSearchRow() {
         $("adv_global_addrow")
     );
 }
+function print_node(node_id) {
+    var iframe = document.createElement("iframe");
+    var source_node = document.getElementById(node_id);
+    source_node.parentNode.appendChild(iframe);
+
+    var iwin = iframe.contentWindow;
+
+    /* These next three statements are only needed by IE, but they don't
+     * hurt FF/Chrome. */
+    iwin.document.open();
+    iwin.document.write(    /* XXX make better/customizable? */
+        "<html><head><title>Recipt</title></head><body></body></html>"
+    );
+    iwin.document.close();
+
+    iwin.document.body.innerHTML = source_node.innerHTML;
+    iframe.focus();
+
+    try { iframe.print(); } catch (e) { iwin.print(); }
+    setTimeout(function() { iframe.style.display = "none"; }, 3500);
+}