HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers14/coeveringmatrijzen.nl/wwwroot/js/customSwiper.js
customSwiper().initialize();
images().initialize();

function customSwiper() {
    return {

        initialize : function()
        {
            var t = this;
            t.resize();

            var $container = $('.swiper-container');

            if($container.size())
            {
                var speed = 1200;

                // Default options
                var options = {
                    grabCursor: true,
                    pagination: '.swiper-pagination',
                    paginationClickable: true,
                    speed: speed,
                    spaceBetween: 0,
                    autoplay: 3000,
                    loop: true,
                    effect : 'fade',
                    keyboardControl: true,
                    onInit: function(images)
                    {
                        t.resize();
                        updateCounter(images);

                    },
                    onSlideChangeStart : function(images)
                    {
                        updateCounter(images);
                    }
                };


                if(msieversion() && msieversion() < 10)
                {
                    options.effect = 'slide';
                }

                $(window).resize(function()
                {
                    t.resize();
                });

                // Custom properties
                /*var custom = $container.attr('data-custom');
                if(typeof custom !== typeof undefined && custom !== false)
                {
                    if(custom == 'home')
                    {
                        options.speed = 1200;
                        options.loop = true;
                        options.spaceBetween = 0;
                        options.effect = 'fade';
                    }
                }*/

                // Setup slides
                new Swiper('.swiper-container',options);
            }
        },

        resize : function()
        {
            var $swiper = $('.swiper-container');

            if($swiper.hasClass('swiper-resize'))
            {
                // Determine ratio
                var ratio = $swiper.attr('data-ratio');
                var parts = ratio.split(':');
                var ratioW = parts[0];
                var ratioH = parts[1];

                var width = $swiper.width();
                var height = width * ratioH / ratioW; // Ratio 5:1
                $swiper.height(height);
            }
        }
    };

    function updateCounter(images)
    {
        $('.counter').html((images.activeIndex + 1) + ' / ' + images.slides.length);
    }
}

function images()
{
    return {
        initialize: function()
        {
            var t = this;

            t.fill();
            t.preload();

            $(window).resize(function()
            {
                setTimeout(function(){ t.fill() },100);
            });
        },

        fill : function()
        {


            $('img.fill').one('load',function()
            {
                // Sizes
                var w = $(this).width();
                var h = $(this).height();
                var pw = $(this).parent().width();
                var ph = $(this).parent().height();
                var ratio = w/h;

                var css = {};

                // Check new with
                /*if( ratio < (pw/ph))
                {*/
                    css.width = pw;
                    css.height = pw / ratio;
               /* }
                else
                {
                    css.height = ph;
                    css.width = ph * ratio;
                }*/


                css.marginLeft = (css.width / -2) + 'px';
                css.marginTop = (css.height / -2) + 'px';

                css.left = '50%';
                css.top = '50%';

                $(this).css(css);

            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        },


        preload: function()
        {
            if(msieversion() && msieversion() < 10)
            {
                $('img.preload').css({ opacity: 1 });
            }

            $('img.preload').one('load',function()
            {
                $(this).addClass('loaded');
            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        }

    }
}

function msieversion() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0)      // If Internet Explorer, return version number
        return (parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));

    return false;
}