adjust the arbitrary print sleep based on the number of items that need printing...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 25 Jun 2009 13:28:12 +0000 (13:28 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 25 Jun 2009 13:28:12 +0000 (13:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13470 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/extras/selfcheck/selfcheck.js

index 60646fc..1cf569a 100644 (file)
@@ -176,10 +176,12 @@ function selfckLogoutPatron() {
     $('selfck-item-barcode-input').value = ''; // prevent browser caching
     $('selfck-patron-login-input').value = '';
     if(patron) {
-        selfckPrint();
+        var numItems = selfckPrint();
+        var sleepTime = 1000;
+        if(numItems > 0) sleepTime += (numItems / 2) * 1000;
         setTimeout(
             function() { location.href = location.href; },
-            3500 // give the browser time to send the page to the printer
+            sleepTime // give the browser time to send the page to the printer
         );
     }
 }
@@ -406,7 +408,12 @@ function selfckRenew() {
   * Sets the print date and prints the page
   */
 function selfckPrint() {
-    for(var x in successfulItems) { // make sure we've checked out at least one item
+
+    var numItems = 0;
+    for(var x in successfulItems)  
+        numItems++;
+
+    if(numItems > 0) {
         hideMe($('selfck-patron-checkout-container'));
         unHideMe($('selfck-print-queuing'));
         appendClear($('selfck-print-date'), text(new Date().toLocaleString()));
@@ -427,8 +434,9 @@ function selfckPrint() {
             }
         }
         window.print();
-        return;
     }
+
+    return numItems;
 }