PageSourceSearch

https://shop.zepter.com/Scripts/Zepter/Product/AddToCart.js

js zepter.com collected 2026-10-02 10:49:51 UTC 5,098 bytes, 101 lines download raw bytes

1class Product_AddToCart {
2    constructor() {
3        this.animationDuration = 250;
4        if (document.body.classList.contains("V3")) {
5            return;
6        }
7        this.container = document.getElementById("ProductDetails_PriceDetails");
8        this.buttons = this.container.getElementsByTagName("button");
9        for (var i = 0; i < this.buttons.length; i++) {
10            let button = this.buttons[i];
11            var addShoppingCartItemIsAjaxRequest = String(button.getAttribute("data-add-shopping-cart-item-is-ajax-request")).toLowerCase() == "true";
12            var isVersion = parseInt(button.getAttribute("data-block-version"));
13            if (isVersion > 2) {
14                return;
15            }
16            if (addShoppingCartItemIsAjaxRequest) {
17                this.serveAjaxRequest(button);
18            }
19        }
20    }
21    serveAjaxRequest(button) {
22        let c = this;
23        var overlay = button.getElementsByClassName("ajax-processing-overlay").item(0);
24        var icons = button.getElementsByClassName("ajax-processing-icons").item(0);
25        var iconProcessing = icons.getElementsByClassName("icon-processing").item(0);
26        var iconSuccess = icons.getElementsByClassName("icon-success").item(0);
27        var itemAdded = false;
28        overlay.style.opacity = "0";
29        iconProcessing.style.opacity = "0";
30        iconSuccess.style.opacity = "0";
31        overlay.style.transition = "opacity " + (this.animationDuration / 1000) + "s ease-in-out";
32        iconProcessing.style.transition = "opacity " + (this.animationDuration / 1000) + "s ease-in-out";
33        iconSuccess.style.transition = "opacity " + (this.animationDuration / 1000) + "s ease-in-out";
34        // Obsłuż kliknięcie w przycisk
35        button.onclick = function () {
36            // Oczekuj na dodanie towaru do koszyka
37            document.addEventListener("updatecart", function () {
38                itemAdded = true;
39            });
40            // Pokaż zasłonę guzika
41            overlay.classList.remove("d-none");
42            // Uruchom ciąg animacji
43            setTimeout(function () {
44                c.disableAllAddToCartButtons();
45                overlay.style.opacity = "1";
46                icons.classList.remove("d-none");
47                setTimeout(function () {
48                    iconProcessing.classList.remove("d-none");
49                    setTimeout(function () {
50                        iconProcessing.style.opacity = "1";
51                        // Oczekuj na dodanie towaru do koszyka
52                        var waitForUpdateCart = setInterval(function () {
53                            // Jeśli towar został dodany
54                            if (itemAdded == true) {
55                                clearInterval(waitForUpdateCart);
56                                setTimeout(function () {
57                                    iconProcessing.style.opacity = "0";
58                                    setTimeout(function () {
59                                        iconProcessing.classList.add("d-none");
60                                        iconSuccess.classList.remove("d-none");
61                                        setTimeout(function () {
62                                            iconSuccess.style.opacity = "1";
63                                            setTimeout(function () {
64                                                iconSuccess.style.opacity = "0";
65                                                overlay.style.opacity = "0";
66                                                setTimeout(function () {
67                                                    iconSuccess.classList.add("d-none");
68                                                    overlay.classList.add("d-none");
69                                                    c.enableAllAddToCartButtons();
70                                                }, c.animationDuration);
71                                            }, 1000);
72                                        }, 10);
73                                    }, c.animationDuration);
74                                }, c.animationDuration);
75                            }
76                        }, 100);
77                    }, c.animationDuration);
78                }, c.animationDuration);
79            }, 0);
80        };
81    }
82    disableAllAddToCartButtons() {
83        let buttons = document.querySelectorAll("[name=\"AddItem\"]");
84        for (var i = 0; i < buttons.length; i++) {
85            let button = buttons[i];
86            button.setAttribute("disabled", "disabled");
87        }
88    }
89    enableAllAddToCartButtons() {
90        let buttons = document.querySelectorAll("[name=\"AddItem\"]");
91        for (var i = 0; i < buttons.length; i++) {
92            let button = buttons[i];
93            button.removeAttribute("disabled");
94        }
95    }
96}
97new Product_AddToCart();
98document.addEventListener("product_addtocart_refresh", function () {
99    new Product_AddToCart();
100});
101//# sourceMappingURL=AddToCart.js.map

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.