PageSourceSearch

https://batc.org.uk/wp-content/plugins/wp-carousel-free/public/js/wp-carousel-free-public.js?ver=2.7.13

js batc.org.uk collected 2026-09-24 10:10:00 UTC 6,860 bytes, 146 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    function SPCarouselFreeInit() {
5        jQuery('body').find('.wpcp-carousel-section.wpcp-standard').not('.swiper-initialized').each(function () {
6
7            var carousel_id = $(this).attr('id');
8            var _this = $(this);
9            var wpcpSwiperData = $('#' + carousel_id).data('swiper');
10
11            if (wpcpSwiperData.effect == 'flip') {
12                /**
13                * Apply fade effect to slides
14                * @param {number} slidesToShow - Number of slides to show
15                */
16                function fade_effect(slidesToShow) {
17                    var fade_items = $(`#${carousel_id} .swiper-wrapper >.single-item-fade`);
18                    // Group slides.
19                    for (var i = 0; i < fade_items.length; i += slidesToShow) {
20                        fade_items.slice(i, i + slidesToShow).wrapAll('<div class="swiper-slide"><div class="swiper-slide-kenburn"></div></div>');
21                    }
22                    // Fix fade last item small issue if row or column does not fill
23                    $(`#${carousel_id} .swiper-slide-kenburn`).each(function () {
24                        var empty_items = slidesToShow - $(this).find('.single-item-fade').length
25                        if (empty_items > 0) {
26                            for (let i = 0; i < empty_items; i++) {
27                                $(this).append(`<div class="single-item-fade" style="width:${100 / slidesToShow}%;"></div>`);
28                            }
29                        }
30                    });
31                    $(fade_items).css('width', `${100 / slidesToShow}%`);
32
33                    // $carousel_items = $(`#${carousel_id}`).find('.single-item-fade').length;
34                }
35                // Apply fade effect based on screen size.
36                if ($(window).width() > wpcpSwiperData.responsive.desktop) {
37                    fade_effect(wpcpSwiperData.slidesToShow.lg_desktop);
38                } else if ($(window).width() > wpcpSwiperData.responsive.laptop) {
39                    fade_effect(wpcpSwiperData.slidesToShow.desktop);
40                } else if ($(window).width() > wpcpSwiperData.responsive.tablet) {
41                    fade_effect(wpcpSwiperData.slidesToShow.laptop);
42                } else if ($(window).width() > wpcpSwiperData.responsive.mobile) {
43                    fade_effect(wpcpSwiperData.slidesToShow.tablet);
44                } else if ($(window).width() > 0) {
45                    fade_effect(wpcpSwiperData.slidesToShow.mobile);
46                }
47                wpcpSwiperData.slidesToShow.mobile = 1;
48                wpcpSwiperData.slidesToShow.tablet = 1;
49                wpcpSwiperData.slidesToShow.desktop = 1;
50                wpcpSwiperData.slidesToShow.laptop = 1;
51                wpcpSwiperData.slidesToShow.lg_desktop = 1;
52            }
53            var wpcpSwiper = new Swiper('#' + carousel_id + ':not(.swiper-initialized, .swiper-container-initialized)', {
54                // Optional parameters
55                autoplay: wpcpSwiperData.autoplay ? ({
56                    delay: wpcpSwiperData.autoplaySpeed, disableOnInteraction: false,
57                }) : false,
58                speed: wpcpSwiperData.speed,
59                effect: wpcpSwiperData.effect,
60                centeredSlides: wpcpSwiperData.centerMode,
61                // slidesPerGroup: 1,
62                slidesPerView: wpcpSwiperData.slidesToShow.mobile,
63                simulateTouch: wpcpSwiperData.draggable,
64                loop: wpcpSwiperData.infinite,
65                allowTouchMove: wpcpSwiperData.swipe,
66                spaceBetween: wpcpSwiperData.spaceBetween,
67                freeMode: wpcpSwiperData.freeMode,
68                grabCursor: true,
69                preloadImages: ('false' !== wpcpSwiperData.lazyLoad) ? true : false,
70                lazy: {
71                    loadPrevNext: ('false' !== wpcpSwiperData.lazyLoad) ? true : false,
72                    loadPrevNextAmount: 1
73                },
74
75                // Responsive breakpoints
76                breakpoints: {
77                    // when window width is >= 480px
78                    [wpcpSwiperData.responsive.mobile]: {
79                        slidesPerView: wpcpSwiperData.slidesToShow.tablet,
80                    },
81                    // when window width is >= 736px
82                    [wpcpSwiperData.responsive.tablet]: {
83                        slidesPerView: wpcpSwiperData.slidesToShow.laptop,
84                    },
85                    // when window width is >= 980px
86                    [wpcpSwiperData.responsive.laptop]: {
87                        slidesPerView: wpcpSwiperData.slidesToShow.desktop,
88                    },
89                    [wpcpSwiperData.responsive.desktop]: {
90                        slidesPerView: wpcpSwiperData.slidesToShow.lg_desktop,
91                    }
92                },
93
94                // If we need pagination
95                pagination: {
96                    el: '.swiper-pagination',
97                    clickable: true,
98                    dynamicBullets: 'dynamic' == wpcpSwiperData.pagination_type ? true : false,
99                },
100                a11y: wpcpSwiperData.accessibility ? ({
101                    prevSlideMessage: 'Previous slide',
102                    nextSlideMessage: 'Next slide',
103                }) : false,
104
105                // Navigation arrows
106                navigation: {
107                    nextEl: '#' + carousel_id + ' .swiper-button-next',
108                    prevEl: '#' + carousel_id + ' .swiper-button-prev',
109                },
110            });
111
112            // On hover stop.
113            if (wpcpSwiperData.pauseOnHover && wpcpSwiperData.autoplay) {
114                $('#' + carousel_id).on({
115                    mouseenter: function () {
116                        wpcpSwiper.autoplay.stop();
117                    },
118                    mouseleave: function () {
119                        wpcpSwiper.autoplay.start();
120                    }
121                });
122            }
123        });
124
125        jQuery(document).find('.wpcp-carousel-wrapper').addClass('wpcp-loaded');
126    }
127
128    /**
129     * Expose the initializer globally.
130     *
131     * The block editor canvas is an iframe since WordPress 6.3, so the editor
132     * has to be able to run the initializer on the window that owns the
133     * markup instead of re-downloading this file into the wrong document.
134     */
135    window.spWPCarouselFreeInit = SPCarouselFreeInit;
136
137    // Initialize the carousel when the document is ready
138    $(document).ready(function () {
139        SPCarouselFreeInit();
140    });
141
142    // Register the handler with Elementor's frontend event.
143    $(window).on('elementor/frontend/init', function () {
144        elementorFrontend.hooks.addAction('frontend/element_ready/sp_wp_carousel_shortcode.default', SPCarouselFreeInit);
145    });
146})(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.