View | Details | Raw Unified | Return to bug 26439
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (-17 lines)
Lines 37-59 Link Here
37
37
38
<!-- js_includes.inc -->
38
<!-- js_includes.inc -->
39
[% IF ( virtualshelves || intranetbookbag ) %]
39
[% IF ( virtualshelves || intranetbookbag ) %]
40
    <script>
41
        // virtualshelves || intranetbookbag
42
        var MSG_BASKET_EMPTY = _("Your cart is currently empty");
43
        var MSG_RECORD_IN_BASKET = _("This item is already in your cart");
44
        var MSG_RECORD_ADDED = _("This item has been added to your cart");
45
        var MSG_NRECORDS_ADDED = _("%s item(s) added to your cart");
46
        var MSG_NRECORDS_IN_BASKET = _("%s already in your cart");
47
        var MSG_NO_RECORD_SELECTED = _("No item was selected");
48
        var MSG_NO_RECORD_ADDED = _("No item was added to your cart (already in your cart)!");
49
        var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?");
50
        var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?");
51
        var MSG_IN_YOUR_CART = _("Items in your cart: %s");
52
        var MSG_ITEM_NOT_IN_CART = _("Add to cart");
53
        var MSG_ITEM_IN_CART = _("In your cart");
54
        var MSG_RECORD_REMOVED = _("The item has been removed from your cart");
55
    </script>
56
57
    [% Asset.js("js/basket.js") | $raw %]
40
    [% Asset.js("js/basket.js") | $raw %]
58
[% END %]
41
[% END %]
59
42
(-)a/koha-tmpl/intranet-tmpl/prog/js/basket.js (-24 / +23 lines)
Lines 1-4 Link Here
1
/* global MSG_BASKET_EMPTY MSG_RECORD_IN_BASKET MSG_RECORD_ADDED MSG_NRECORDS_IN_BASKET MSG_NRECORDS_ADDED MSG_NO_RECORD_ADDED MSG_RECORD_REMOVED MSG_CONFIRM_DEL_BASKET MSG_CONFIRM_DEL_RECORDS MSG_IN_YOUR_CART MSG_NO_RECORD_SELECTED MSG_ITEM_IN_CART MSG_ITEM_NOT_IN_CART */
1
/* global __ */
2
2
3
//////////////////////////////////////////////////////////////////////////////
3
//////////////////////////////////////////////////////////////////////////////
4
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT //
4
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT //
Lines 87-93 function openBasket() { Link Here
87
        if (window.focus) { basket.focus(); }
87
        if (window.focus) { basket.focus(); }
88
    }
88
    }
89
    else {
89
    else {
90
        showCartUpdate(MSG_BASKET_EMPTY);
90
        showCartUpdate( __("Your cart is currently empty") );
91
    }
91
    }
92
}
92
}
93
93
Lines 115-121 function addRecord(val, selection,NoMsgAlert) { Link Here
115
                return 0;
115
                return 0;
116
            }
116
            }
117
            if (! NoMsgAlert ) {
117
            if (! NoMsgAlert ) {
118
                showCartUpdate(MSG_RECORD_IN_BASKET);
118
                showCartUpdate( __("This item is already in your cart") );
119
            }
119
            }
120
        }
120
        }
121
        else {
121
        else {
Lines 132-138 function addRecord(val, selection,NoMsgAlert) { Link Here
132
            return 1;
132
            return 1;
133
        }
133
        }
134
        if (! NoMsgAlert ) {
134
        if (! NoMsgAlert ) {
135
            showCartUpdate(MSG_RECORD_ADDED);
135
            showCartUpdate( __("This item has been added to your cart") );
136
            updateLink(val,"add");
136
            updateLink(val,"add");
137
        }
137
        }
138
    }
138
    }
Lines 202-221 function addSelRecords(valSel) { // function for adding a selection of biblios t Link Here
202
    var msg = "";
202
    var msg = "";
203
    if (nbAdd) {
203
    if (nbAdd) {
204
        if (i > nbAdd) {
204
        if (i > nbAdd) {
205
            msg = MSG_NRECORDS_ADDED.format(nbAdd);
205
            msg = __("%s item(s) added to your cart").format(nbAdd);
206
            msg += "<br/>";
206
            msg += "<br/>";
207
            msg += MSG_NRECORDS_IN_BASKET.format((i-nbAdd));
207
            msg += __("%s already in your cart").format((i-nbAdd));
208
        }
208
        }
209
        else {
209
        else {
210
            msg = MSG_NRECORDS_ADDED.format(nbAdd);
210
            msg = __("%s item(s) added to your cart").format(nbAdd);
211
        }
211
        }
212
    }
212
    }
213
    else {
213
    else {
214
        if (i < 1) {
214
        if (i < 1) {
215
            msg = MSG_NO_RECORD_SELECTED;
215
            msg = __("No item was selected");
216
        }
216
        }
217
        else {
217
        else {
218
            msg = MSG_NO_RECORD_ADDED;
218
            msg = __("No item was added to your cart (already in your cart)!");
219
        }
219
        }
220
    }
220
    }
221
	showCartUpdate(msg);
221
	showCartUpdate(msg);
Lines 254-260 function delSingleRecord(biblionumber){ Link Here
254
    writeCookie( nameCookie, valCookie );
254
    writeCookie( nameCookie, valCookie );
255
    updateBasket( arrayRecords.length-1 );
255
    updateBasket( arrayRecords.length-1 );
256
    updateLink(biblionumber,"del");
256
    updateLink(biblionumber,"del");
257
    showCartUpdate(MSG_RECORD_REMOVED);
257
    showCartUpdate(__("The item has been removed from your cart"));
258
}
258
}
259
259
260
function delSelRecords() {
260
function delSelRecords() {
Lines 281-287 function delSelRecords() { Link Here
281
281
282
            if (str2.length === 0) { // equivalent to emptying the basket
282
            if (str2.length === 0) { // equivalent to emptying the basket
283
                var rep = false;
283
                var rep = false;
284
                rep = confirm(MSG_CONFIRM_DEL_BASKET);
284
                rep = confirm(__("Are you sure you want to empty your cart?"));
285
                if (rep) {
285
                if (rep) {
286
                    delCookie(nameCookie);
286
                    delCookie(nameCookie);
287
                    document.location = "about:blank";
287
                    document.location = "about:blank";
Lines 305-311 function delSelRecords() { Link Here
305
        document.location = CGIBIN + "basket/basket.pl?" + strCookie;
305
        document.location = CGIBIN + "basket/basket.pl?" + strCookie;
306
    }
306
    }
307
    else {
307
    else {
308
        alert(MSG_NO_RECORD_SELECTED);
308
        alert(__("No item was selected"));
309
    }
309
    }
310
}
310
}
311
311
Lines 334-340 function delRecord (n, s) { Link Here
334
334
335
function delBasket(context,rep) {
335
function delBasket(context,rep) {
336
    if (rep === undefined){
336
    if (rep === undefined){
337
        rep = confirm(MSG_CONFIRM_DEL_BASKET);
337
        rep = confirm(__("Are you sure you want to empty your cart?"));
338
    }
338
    }
339
    if (rep) {
339
    if (rep) {
340
        if(context == "popup"){
340
        if(context == "popup"){
Lines 354-360 function delBasket(context,rep) { Link Here
354
function quit() {
354
function quit() {
355
    if (document.myform.records.value) {
355
    if (document.myform.records.value) {
356
        var rep = false;
356
        var rep = false;
357
        rep = confirm(MSG_CONFIRM_DEL_RECORDS);
357
        rep = confirm(__("Are you sure you want to remove the selected items?"));
358
        if (rep) {
358
        if (rep) {
359
            delSelRecords();
359
            delSelRecords();
360
        }
360
        }
Lines 411-420 function showLess() { Link Here
411
function updateBasket(updated_value,target) {
411
function updateBasket(updated_value,target) {
412
	if(target){
412
	if(target){
413
	target.$('#basketcount').html(" <span>("+updated_value+")</span>");
413
	target.$('#basketcount').html(" <span>("+updated_value+")</span>");
414
    target.$('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value));
414
    target.$('#cartDetails').html(__("Items in your cart: %s").format(updated_value));
415
	} else {
415
	} else {
416
	$('#basketcount').html(" <span>("+updated_value+")</span>");
416
	$('#basketcount').html(" <span>("+updated_value+")</span>");
417
    $('#cartDetails').html(MSG_IN_YOUR_CART.format(updated_value));
417
    $('#cartDetails').html(__("Items in your cart: %s").format(updated_value));
418
	}
418
	}
419
	var basketcount = updated_value;
419
	var basketcount = updated_value;
420
}
420
}
Lines 429-435 function addSelToShelf() { Link Here
429
	if(items){
429
	if(items){
430
    document.location = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber="+items;
430
    document.location = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber="+items;
431
	} else {
431
	} else {
432
        alert(MSG_NO_RECORD_SELECTED);
432
        alert(__("No item was selected"));
433
    }
433
    }
434
}
434
}
435
435
Lines 443-449 function vShelfAdd(biblist) { Link Here
443
                bibs.push("biblionumber=" +  biblist[i].value);
443
                bibs.push("biblionumber=" +  biblist[i].value);
444
            }
444
            }
445
        }
445
        }
446
        if (bibs.length === 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
446
        if (bibs.length === 0) { showListsUpdate(__("No item was selected")); }
447
        return bibs.join("&");
447
        return bibs.join("&");
448
    } else {
448
    } else {
449
        var bibnums = getContextBiblioNumbers();
449
        var bibnums = getContextBiblioNumbers();
Lines 453-459 function vShelfAdd(biblist) { Link Here
453
            }
453
            }
454
            return bibs.join("&");
454
            return bibs.join("&");
455
        } else {
455
        } else {
456
            showListsUpdate(MSG_NO_RECORD_SELECTED);
456
            showListsUpdate(__("No item was selected"));
457
        }
457
        }
458
    }
458
    }
459
}
459
}
Lines 484-503 function updateLink(val, op, target){ Link Here
484
    var cartR = target ? target.$("#cartR" + val) : $("#cartR" + val);
484
    var cartR = target ? target.$("#cartR" + val) : $("#cartR" + val);
485
485
486
    if(op == "add"){
486
    if(op == "add"){
487
        cart.html(MSG_ITEM_IN_CART).addClass("incart");
487
        cart.html(__("In your cart")).addClass("incart");
488
        cartR.show();
488
        cartR.show();
489
    } else {
489
    } else {
490
        cart.html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart");
490
        cart.html(__("Add to cart")).removeClass("incart").addClass("addtocart");
491
        cartR.hide();
491
        cartR.hide();
492
    }
492
    }
493
}
493
}
494
494
495
function updateAllLinks(target){
495
function updateAllLinks(target){
496
    if(target){
496
    if(target){
497
        target.$("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart");
497
        target.$("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
498
        target.$(".cartRemove").hide();
498
        target.$(".cartRemove").hide();
499
    } else {
499
    } else {
500
        $("a.incart").html(MSG_ITEM_NOT_IN_CART).removeClass("incart").addClass("addtocart");
500
        $("a.incart").html(__("Add to cart")).removeClass("incart").addClass("addtocart");
501
        $(".cartRemove").hide();
501
        $(".cartRemove").hide();
502
    }
502
    }
503
}
503
}
504
- 

Return to bug 26439