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/SBogers10/tandartsmaas.komma.pro/wwwroot/js/app/modules/swiper.js
define('modules/swiper',['swiper','modules/images'],function(swiper,images)
{
    return {
        initialize : function()
        {
            if($('.swiper-images').size() && $('.swiper-info').size())
            {
                var speed = 800;

                // Setup slides
                var swiperImages = new Swiper('.swiper-images',
                    {
                        grabCursor: true,
                        speed: speed,
                        nextButton: '.swiper-button-next',
                        prevButton: '.swiper-button-prev',
                        keyboardControl: true,
                        onSlideChangeStart : function(swiperImages)
                        {
                            updateSwiperNavigation(swiperImages.activeIndex);
                            updateNextPrevNavigation(swiperImages.activeIndex, swiperImages.slides.length)
                        }
                    });

                var swiperInfo = new Swiper('.swiper-info',
                    {
                        direction: 'vertical',
                        speed: speed
                    });

                // Bind Slides
                swiperImages.params.control = swiperInfo;
                swiperInfo.params.control = swiperImages;

                // Bind click event to navigation
                $('.aboutSwiper .navigation ul li').bind('click',function()
                {
                    // Slide Swiper
                    var targetSlide = $(this).index();
                    swiperImages.slideTo(targetSlide, speed);

                    scrollToEmployeeTop()
                });

                $('.aboutSwiper .swiper-button').bind('click',function()
                {
                    if( ! $(this).hasClass('disabled')) scrollToEmployeeTop()
                });

                $('.swiper-slide').addClass('animate');
            }
        }
    };

    function scrollToEmployeeTop()
    {
        var employeeTop = $('#employeesTitle').offset().top;
        var $scroller =  $('html, body');

        if($scroller.scrollTop() < employeeTop)
            $scroller.animate({
            scrollTop: employeeTop
        }, 500);
    }

    function updateSwiperNavigation(activeSlide)
    {
        $('.aboutSwiper .navigation ul li.active').removeClass('active');
        $('.aboutSwiper .navigation ul li').eq(activeSlide).addClass('active');

        // Update quotes
        var $activeQuote = $('.aboutSwiper .valign-parent.active');
        var index = $activeQuote.index();
        $activeQuote.addClass('out').removeClass('active');
        setTimeout(function(){ $('.aboutSwiper .valign-parent').eq(index).removeClass('animating').removeClass('out') },800);

        $('.aboutSwiper .valign-parent').eq(activeSlide).addClass('animating').addClass('active');
    }

    function updateNextPrevNavigation(activeSlide,numSlides)
    {
        console.log(activeSlide + ' ' + numSlides);
        var $prev = $('.swiper-button-prev');
        var $next = $('.swiper-button-next');

        $prev.removeClass('disabled');
        $next.removeClass('disabled');

        if(activeSlide == 0) $prev.addClass('disabled');
        if(activeSlide == numSlides-1) $next.addClass('disabled');
    }
});