PageSourceSearch

https://www.heutinkvoorthuis.nl/Scripts/default/modules/heutinkrelatedproducts.js

js heutinkvoorthuis.nl collected 2026-09-26 12:02:27 UTC 2,575 bytes, 78 lines download raw bytes

1modules.heutinkrelatedproducts = (function ($) {
2    var me = {
3        moduleContainer: null,
4    };
5
6    me.init = function (moduleContainer) {
7        me.moduleContainer = moduleContainer;
8
9        me.initOrderNow();
10        me.initTabs();
11    };
12
13    me.initOrderNow = function () {
14        $(me.moduleContainer).on("click", "[data-order-relatedproducts]", function (e) {
15            me.addProduct($(this));
16            event.preventDefault();
17        });
18    };
19
20    me.initTabs = function () {
21        me.tabs = $(me.moduleContainer).find("[data-related-tab]");
22        me.tabsContent = $(me.moduleContainer).find("[data-tab-content]");
23
24        $.each(me.tabs, function (index, tab) {
25            var tabContent = $("[data-tab-content='" + $(tab).data("tab") + "']");
26
27            $(tab).on("click", function (e) {
28                e.preventDefault();
29
30                me.switchTab(this, tabContent);
31            });
32        });
33    };
34
35    me.switchTab = function (tab, tabContent) {
36        $(me.tabs).removeClass("btn-theme05").addClass("btn-white");
37        $(tab).removeClass("btn-white").addClass("btn-theme05");
38
39        $(me.tabsContent).hide();
40        $(tabContent).show();
41    };
42
43    me.addProduct = function (element) {
44        // Get productId
45        var productId = element.closest("[data-product-block]").data("productid");
46        $.post(
47            ajaxCallbackUrl.checkoutBasketAddOrUpdateProduct,
48            {
49                productId: productId,
50                optionChoiceId: null,
51                quantity: 1,
52            },
53            function (data) {
54                if (util.stringToBoolean(data.result)) {
55                    $(document).trigger("checkoutbasket:refresh");
56
57                    if (!$.cookie("hideRelatedProductsPopup")) {
58                        $.post(
59                            ajaxCallbackUrl.RelatedProductsPopupContents,
60                            {
61                                productId: productId,
62                            },
63                            function (data) {
64                                util.showAddToBasketPopup(data);
65                            }
66                        );
67                    } else {
68                        window.location.href = data.basketUrl;
69                    }
70                } else if (util.stringToBoolean(data.chemicalNotAllowed)) {
71                    window.location.href = data.loginUrl;
72                }
73            }
74        );
75    };
76
77    return me;
78})(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.