HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux mail.btech-izolacje.pl 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
User: pewna6876 (1017)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: /home/pewnabryka.pl/public_html/wp-content/plugins/vehica-core/assets/js/gallery.js
"use strict"

jQuery(document).ready(function () {
    var pswpElement = document.querySelectorAll('.pswp')[0];

    var images = [];

    jQuery.each(jQuery('.vehica-gallery-main .vehica-swiper-slide:not(.vehica-swiper-slide-duplicate)'), (index, image) => {
        if (typeof jQuery(image).data('src') !== 'undefined') {
            images.push({
                src: jQuery(image).data('src'),
                w: jQuery(image).data('width'),
                h: jQuery(image).data('height'),
                title: jQuery(image).data('title'),
                index: jQuery(image).data('index')
            });
        }
    })

    jQuery('.vehica-gallery-main .vehica-swiper-slide').on('click', function () {
        var options = {
            index: jQuery(this).data('index'),
            showHideOpacity: true,
            closeOnScroll: false,
            shareEl: false,
            getThumbBoundsFn: function () {
                var pageYScroll = window.pageYOffset || document.documentElement.scrollTop;
                var rect = jQuery('.vehica-gallery-main').get(0).getBoundingClientRect();
                return {x: rect.left, y: rect.top + pageYScroll, w: rect.width, h: rect.height};
            }.bind(this)
        };

        var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images, options);
        gallery.listen('afterChange', function () {
            window.VehicaEventBus.$emit('carGalleryChangeImage', gallery.currItem.index);
        });
        gallery.init();
    })
});