PageSourceSearch

https://www.cadouri.ro/Scripts/public.ajaxcart.js

js cadouri.ro collected 2026-09-27 04:27:32 UTC 5,201 bytes, 156 lines download raw bytes

1/*
2** nopCommerce ajax cart implementation
3*/
4
5
6var AjaxCart = {
7    loadWaiting: false,
8    usepopupnotifications: false,
9    topcartselector: '',
10    topwishlistselector: '',
11    flyoutcartselector: '',
12    topcartsubtotalselector: '',
13
14    init: function (usepopupnotifications, topcartselector, topwishlistselector, flyoutcartselector, topcartsubtotalselector) {
15        this.loadWaiting = false;
16        this.usepopupnotifications = usepopupnotifications;
17        this.topcartselector = topcartselector;
18        this.topwishlistselector = topwishlistselector;
19        this.flyoutcartselector = flyoutcartselector;
20        this.topcartsubtotalselector = topcartsubtotalselector;
21    },
22
23    setLoadWaiting: function (display) {
24        displayAjaxLoading(display);
25        this.loadWaiting = display;
26    },
27
28    //add a product to the cart/wishlist from the catalog pages
29    addproducttocart_catalog: function (urladd) {
30        if (this.loadWaiting != false) {
31            return;
32        }
33        this.setLoadWaiting(true);
34        $.ajax({
35            cache: false,
36            url: urladd,
37            type: 'post',
38            success: this.success_process,
39            complete: this.resetLoadWaiting,
40            error: this.ajaxFailure
41        });
42    },
43
44    //add a product to the cart/wishlist from the product details page
45    addproducttocart_details: function (urladd, formselector) {
46        if (this.loadWaiting != false) {
47            return;
48        }
49        this.setLoadWaiting(true);
50
51        $.ajax({
52            cache: false,
53            url: urladd,
54            data: $(formselector).serialize(),
55            type: 'post',
56            success: this.success_process,
57            complete: this.resetLoadWaiting,
58            error: this.ajaxFailure
59        });
60    },
61
62    addproducttocart_variants: function (urladd, variantId) {
63        if (this.loadWaiting != false) {
64            return;
65        }
66        this.setLoadWaiting(true);
67
68        var quantity = $("#variant_addtocart_" + variantId + "_EnteredQuantity").val();
69
70        $.ajax({
71            cache: false,
72            url: urladd,
73            data: 'variant_addtocart_' + variantId + '.EnteredQuantity=' + quantity,
74            type: 'post',
75            success: this.success_process,
76            complete: this.resetLoadWaiting,
77            error: this.ajaxFailure
78        });
79    },
80
81    //add a product to compare list
82    addproducttocomparelist: function (urladd) {
83        if (this.loadWaiting != false) {
84            return;
85        }
86        this.setLoadWaiting(true);
87
88        $.ajax({
89            cache: false,
90            url: urladd,
91            type: 'post',
92            success: this.success_process,
93            complete: this.resetLoadWaiting,
94            error: this.ajaxFailure
95        });
96    },
97
98    success_process: function (response) {
99        if (response.updatetopcartsubtotalsectionhtml) {
100            $(AjaxCart.topcartsubtotalselector).html(response.updatetopcartsubtotalsectionhtml);
101        }
102        if (response.updatetopcartsectionhtml) {
103            $(AjaxCart.topcartselector).html(response.updatetopcartsectionhtml);
104        }
105        if (response.updatetopwishlistsectionhtml) {
106            $(AjaxCart.topwishlistselector).html(response.updatetopwishlistsectionhtml);
107        }
108        if (response.updateflyoutcartsectionhtml) {
109            $(AjaxCart.flyoutcartselector).replaceWith(response.updateflyoutcartsectionhtml);
110        }
111        if (response.message) {
112            //display notification
113            if (response.success == true) {
114                //success
115                if (AjaxCart.usepopupnotifications == true) {
116
117                    if (response.cartInfoHtml) {
118                        //displayPopupNotification(response)
119                        displayCartNotification(response.message, 'success', true, response.cartInfoHtml, response.hasTierPrices);
120                    }
121                    else {
122                        displayPopupNotification(response.message, 'success', true);
123                    }
124                }
125                else {
126                    //specify timeout for success messages
127                    displayBarNotification(response.message, 'success', 3500);
128                }
129            }
130            else {
131                //error
132                if (AjaxCart.usepopupnotifications == true) {
133                    displayPopupNotification(response.message, 'error', true);
134                }
135                else {
136                    //no timeout for errors
137                    displayBarNotification(response.message, 'error', 0);
138                }
139            }
140            return false;
141        }
142        if (response.redirect) {
143            location.href = response.redirect;
144            return true;
145        }
146        return false;
147    },
148
149    resetLoadWaiting: function () {
150        AjaxCart.setLoadWaiting(false);
151    },
152
153    ajaxFailure: function () {
154        alert('Failed to add the product. Please refresh the page and try one more time.');
155    }
156};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.