Re-marking basket count with spans to avoid validation errors
[koha_gimpoz] / koha-tmpl / opac-tmpl / prog / en / js / basket.js
index f889bdd..5505879 100644 (file)
@@ -11,7 +11,7 @@ var valCookie = readCookie(nameCookie);
 if(valCookie){
     var arrayRecords = valCookie.split("/");
     if(arrayRecords.length > 0){
-        var basketcount = " ("+(arrayRecords.length-1)+")";
+        var basketcount = arrayRecords.length-1;
     } else {
         var basketcount = "";
     }
@@ -132,14 +132,21 @@ function addRecord(val, selection,NoMsgAlert) {
     }
 }
 
+function AllAreChecked(s){
+       if (! s.length) { return false;}
+       var l = s.length;
+       for (var i=0; i < l; i++) {
+               if(! s[i].checked) { return false; }
+       }
+       return true;
+}
+
 function SelectAll(){
     if(document.bookbag_form.biblionumber.length > 0) {
-        for (var i=0; i < document.bookbag_form.biblionumber.length; i++) {
-            if (document.bookbag_form.select_all.checked) {
-                document.bookbag_form.biblionumber[i].checked=true;
-            } else {
-                document.bookbag_form.biblionumber[i].checked=false;
-            }
+               var checky = AllAreChecked(document.bookbag_form.biblionumber);
+               var l = document.bookbag_form.biblionumber.length;
+        for (var i=0; i < l; i++) {
+            document.bookbag_form.biblionumber[i].checked = (checky) ? false : true;
         }
     }
 }
@@ -159,11 +166,6 @@ function addMultiple(){
     }
 }
 
-function addSelToShelf() {
-    var items = document.getElementById('records').value;
-    document.location = "/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber="+items;
-}
-
 function addSelRecords(valSel) { // function for adding a selection of biblios to the basket
                                                 // from the results list
     var arrayRecords = valSel.split("/");
@@ -320,7 +322,7 @@ function sendBasket() {
 
     var loc = CGIBIN + "opac-sendbasket.pl?" + strCookie;
 
-    var optWin="dependant=yes,scrollbars=no,resizable=no,height=300,width=400,top=50,left=100";
+    var optWin="dependant=yes,scrollbars=no,resizable=no,height=300,width=450,top=50,left=100";
     var win_form = open(loc,"win_form",optWin);
 }
 
@@ -355,7 +357,12 @@ function showLess() {
 
 function updateBasket(updated_value,target) {
     if(typeof document.getElementById != "undefined") {
-        target.getElementById('basket').innerHTML = " ("+updated_value+")";
+               if(target.getElementById('basket')){
+               target.getElementById('basket').innerHTML = "<span>"+updated_value+"</span>";
+               }
+               if(target.getElementById('cartDetails')){
+                       target.getElementById('cartDetails').innerHTML = _("Your cart contains ")+updated_value+_(" items");
+               }
     } else if (typeof document.layers != "undefined") {
         target.layers['basket'].open();
         target.layers['basket'].write(" ("+updated_value+")");
@@ -364,6 +371,7 @@ function updateBasket(updated_value,target) {
 document.getElementById == "undefined") {
         target.all['basket'].innerHTML = " ("+updated_value+")";
     }
+       var basketcount = updated_value;
 }
 
 function openBiblio(dest,biblionumber) {
@@ -371,3 +379,22 @@ function openBiblio(dest,biblionumber) {
     opener.document.location = openerURL;
     opener.focus();
 }
+
+function addSelToShelf() {
+    var items = document.getElementById('records').value;
+    document.location = "/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber="+items;
+}
+
+///  vShelfAdd()  builds url string for multiple-biblio adds.
+
+function vShelfAdd() {
+        bibs= new Array;
+        if(document.bookbag_form.biblionumber.length > 0) {
+                for (var i=0; i < document.bookbag_form.biblionumber.length; i++) {
+                        if (document.bookbag_form.biblionumber[i].checked) {
+                                bibs.push("biblionumber=" +  document.bookbag_form.biblionumber[i].value);
+                        }
+                }
+        return bibs.join("&");
+        }
+}