PageSourceSearch

https://pamutlabor.hu/wp-content/plugins/design-product/asset/js/product-slider.js?ver=1.9.1

js pamutlabor.hu collected 2026-09-26 15:07:20 UTC 5,855 bytes, 155 lines download raw bytes

1jQuery(function ($) {
2
3    var removedItem = null;
4
5    var sliderItemPerPage = 6;
6
7    $(document).ready(function(){
8
9        let selectedItemIndex = hideSelectedSliderItem();
10        
11        $(`#product-slider`).carousel({
12            pause: true,
13            interval: false,
14            touch: true,
15            swipe: 30,
16            wrap: true
17        });
18
19        $(`#product-slider .carousel-item:visible`).first().addClass('active');
20
21        if (selectedItemIndex < sliderItemPerPage) {
22            /* To be six items in slider if necessary. */
23            $(`#product-slider .active-next`).next().addClass('active-next');
24        }
25
26        if (window.innerWidth < 768) {
27            $(`#product-slider .carousel-item`).first().addClass('active');
28        }
29
30        /* Event which fires when slide is finished */
31        $('#product-slider').on('slid.bs.carousel', function (e) {
32            /* Fire scroll event to execute lazy load.  */
33            $(document).scroll();
34
35            let activeElement = $(e.relatedTarget);
36
37            let activeElementIndex = activeElement.index();
38            
39            $('#product-slider .carousel-item').removeClass('active-next');
40            for (let i = activeElementIndex; i < activeElementIndex + sliderItemPerPage; i++) {
41                $('#product-slider .carousel-item').eq(i).addClass('active-next');
42            }
43        });
44
45        /* Event which fires immediately when the slide instance method is invoked. */
46        $('#product-slider').on('slide.bs.carousel', function (e) {
47
48            if (window.innerWidth > 768) {
49                /* On small screen we do not disable slide. */
50
51                if ($('#product-slider .carousel-item').length <= sliderItemPerPage) {
52                    return false;
53                }
54
55                /* Disable the slide event if we reached the last item and move to next slider. */
56                if (e.direction == 'left' && $(this).find('.active-next').last().index() == $(this).find('.carousel-item').last().index()) {
57                    return false;
58                }
59
60                /* Disable the slide event if we reached the first item and move back. */
61                if (e.direction == 'right' && $(this).find('.active').index() == $(this).find('.carousel-item').first().index()) {
62                    return false;
63                }
64            }
65
66        });
67
68        /* Swipe functions for Bootstrap Carousel */
69        $(`#product-slider`).bcSwipe({ 
70            threshold: 50 
71        });
72
73        var url = window.location.href;
74
75        /**
76         * Handle broken images url in product slider.
77         */
78        $('.single-product .row.doris-left-area-row.doris-products .carla-slider-item img').on('error', (e) => {
79            if (url.indexOf('pamutlabor.hu') > -1 || url.indexOf('staging-pamutlabor') > -1) {
80                e.target.src = 'https://mk0pamutlaborr78t5ay.kinstacdn.com/wp-content/uploads/2019/02/pamutlabor_logo_placeholder-500x583.jpg';
81            } else if (url.indexOf('spacewombat.de') > -1) {
82                e.target.src = 'https://mk0spacewombatdvnmup.kinstacdn.com/wp-content/uploads/2019/09/loading_image.jpg';
83            } else if (url.indexOf('teetaku.hu') > -1) {
84                e.target.src = 'https://mk0teetakupmg6g5vlfv.kinstacdn.com/wp-content/uploads/2019/02/teetaku_logo_placeholder-500x583.jpg';
85            }
86        });
87
88        /**
89         * Handle broken images url in mobile product slider.
90         */
91        $('.single-product .doris-right-area-mobile.doris-right-area-row.doris-products .carla-slider-item img').on('error', (e) => {
92            if (url.indexOf('pamutlabor.hu') > -1 || url.indexOf('staging-pamutlabor') > -1) {
93                e.target.src = 'https://mk0pamutlaborr78t5ay.kinstacdn.com/wp-content/uploads/2019/02/pamutlabor_logo_placeholder-500x583.jpg';
94            } else if (url.indexOf('spacewombat.de') > -1) {
95                e.target.src = 'https://mk0spacewombatdvnmup.kinstacdn.com/wp-content/uploads/2019/09/loading_image.jpg';
96            } else if (url.indexOf('teetaku.hu') > -1) {
97                e.target.src = 'https://mk0teetakupmg6g5vlfv.kinstacdn.com/w
97p-content/uploads/2019/02/teetaku_logo_placeholder-500x583.jpg';
98            }
99        });
100       
101    });
102
103    $('#base').change(function(){
104        hideSelectedSliderItem();
105
106        displayItemsCorrectly();
107    });
108
109    /**
110     * Hide the selected element in product slider.
111     * 
112     * hideSelectedSliderItem
113     * @return int 
114     */
115    function hideSelectedSliderItem() {
116        if (removedItem !== null) {
117            /* Add active class to removed item. */
118            $(`#product-slider .carousel-item`).removeClass('active');
119            removedItem.addClass('active');
120
121            /* Prepend removed item to slider content. */
122            $(`#product-slider`).prepend(removedItem);
123            
124        }
125
126        let selectedBaseSlug = $('#base option:selected').data('base');
127
128        removedItem = $(`#product-slider [data-slug="${selectedBaseSlug}"]`);
129
130        removedItem.removeClass('active-next');
131
132        let removedItemIndex = $(`#product-slider [data-slug="${selectedBaseSlug}"]`).index();
133
134        $(`#product-slider [data-slug="${selectedBaseSlug}"]`).remove();
135
136        return removedItemIndex;
137    }
138
139    /**
140     * Display slider items correctly after modify it.
141     * 
142     * displayItemsCorrectly
143     * @return void 
144     */
145    function displayItemsCorrectly() {
146        $(`#product-slider .carousel-item`).removeClass('active');
147        $(`#product-slider .carousel-item`).removeClass('active-next');
148
149        $(`#product-slider .carousel-item`).first().addClass('active');
150
151        for (let i = 0; i < 0 + sliderItemPerPage; i++) {
152            $('#product-slider .carousel-item').eq(i).addClass('active-next');
153        }
154    }
155});

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.