PageSourceSearch

https://ergowebshop.de/templates/FIRE/js/jtl.basket.js?v=505

js ergowebshop.de collected 2026-10-10 02:05:02 UTC 5,249 bytes, 168 lines download raw bytes

1(function() {
2    'use strict';
3
4    var BasketClass = function(options) {
5        this.init(options);
6    };
7
8    BasketClass.DEFAULTS = {
9        input: {
10            id: 'a',
11            varId: 'VariKindArtikel', //Salepix Ilya fix for ajax add cart
12            quantity: 'anzahl'
13        },
14        selector: {
15            list: {
16                main: '*[data-toggle="basket-add"]',
17                form: 'form.form-basket',
18                quantity: 'input.quantity',
19                submit: '*[type="submit"]',
20                loading: 'io-loading'
21            },
22            cart: {
23                container: '.cart-icon-dropdown'
24            }
25        }
26    };
27
28    BasketClass.prototype = {
29
30        constructor: BasketClass,
31
32        init: function(options) {
33            this.options = $.extend({}, BasketClass.DEFAULTS, options);
34        },
35
36        addToBasket: function($form, data) {
37            var $main = $form;
38
39            if (typeof data === 'undefined') {
40                data = $form.serializeObject();
41            }
42
43            //Salepix Ilya fix for ajax add cart
44            var productId = (parseInt(data[this.options.input.varId])) ? parseInt(data[this.options.input.varId]) : parseInt(data[this.options.input.id]);
45
46            var quantity = parseFloat(
47                data[this.options.input.quantity].replace(',', '.')
48            );
49
50            if (productId > 0 && quantity > 0) {
51                this.pushToBasket($main, productId, quantity, data);
52            }
53        },
54
55        pushToBasket: function($main, productId, quantity, data) {
56            var that = this;
57
58            that.toggleState($main, true);
59
60            $.evo.io().call('pushToBasket', [productId, quantity, data], that, function(error, data) {
61
62                that.toggleState($main, false);
63
64                if (error) {
65                    return;
66                }
67
68                var response = data.response;
69
70                if (response) {
71                    switch (response.nType) {
72                        case 0: // error
73                            that.error(response);
74                            break;
75                        case 1: // forwarding
76                            that.redirectTo(response);
77                            break;
78                        case 2: // added to basket
79                            that.updateCart();
80                            that.pushedToBasket(response);
81                            break;
82                    }
83                }
84            });
85        },
86
87        toggleState: function($main, loading) {
88            var cls = this.options.selector.list.loading;
89            if (loading) {
90                $main.addClass(cls);
91            } else {
92                $main.removeClass(cls);
93            }
94        },
95
96        redirectTo: function(response) {
97            window.location.href = response.cLocation;
98        },
99
100        error: function(response) {
101            var errorlist = '<ul><li>' + response.cHints.join('</li><li>') + '</li></ul>';
102            $.evo.extended().showNotify({
103                text: errorlist,
104                title: response.cLabel
105            });
106        },
107
108        pushedToBasket: function(response) {
109            // SALEPIX ADDED
110            const selector = '[data-toggle="cart-offcanvas"]';
111            const element = document.body.querySelector(selector);
112            if(element && element.hasAttribute('data-salepix-sidebasket-options')) {
113                const options = JSON.parse(element.dataset.salepixSidebasketOptions);
114                if(options.openOffCanvasCartAfterPusshedSuccess) {
115                    document.body.classList.add('is-event-pushedToBasket');
116                }
117            }
118            const pushedSuccessHide = document.body.querySelector('#pushedSuccessHide');
119            if(pushedSuccessHide) {
120                if(response.cPopup.indexOf('pushed-success') > 0) {
121                    document.body.classList.add('is-pushed-success-hide');
122                }
123            }
124            if(!window.openOffCanvasCartAfterPusshedSuccess) {
125                $.evo.extended().showNotify({
126                    text: response.cPopup,
127                    title: response.cNotification
128                });
129            }
130        },
131
132        updateCart: function(type) {
133            var that = this,
134                t = parseInt(type);
135
136            if (type === undefined) {
137                t=0;
138            }
139
140            $.evo.io().call('getBasketItems', [t], this, function(error, data) {
141                if (error) {
142                    return;
143                }
144
145                var tpl = data.response.cTemplate;
146
147                $(that.options.selector.cart.container)
148                    .replaceWith(tpl);
149            });
150        }
151    };
152
153    // PLUGIN DEFINITION
154    // =================
155
156    $.evo.basket = function() {
157        return new BasketClass();
158    };
159
160    // PLUGIN DATA-API
161    // ===============
162    $('#main-wrapper').on('submit', '[data-toggle="basket-add"]', function(event) {
163        event.preventDefault();
164        $.evo.basket().addToBasket($(this));
165    }).on('show.bs.dropdown', '[data-toggle="basket-items"]', function (event) {
166        $.evo.basket().updateCart();
167    });
168})(jQuery);

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.