(function ($) { "use strict"; $(document).ready(function () { FullPageInit(); handleNavigationNextPrev(); ScrollToSection(); stepsSlider(); accordion(); //handleScrollBackUp(); }); /** * Activate plans details on mobile */ const FullPageInit = () => { $('#fullpage').fullpage({ licenseKey: '1LHKK-U0RE8-K703H-MSJ8J-MXRON', anchors: ['Pirmas', 'Antras', 'Trecias', 'Ketvirtas'], menu: '#fp-labas-navigation', responsiveWidth: 767, responsiveHeight: 526, verticalCentered: false, credits: { enabled: false}, scrollingSpeed: 1000, css3:false, afterLoad: function(section, origin){ let activeSection = section.index; let originSection = origin.index; if ( originSection == 0 ){ $('.labas-navigation').addClass('black'); $('.labas-navigation').removeClass('reverse'); } else if ( originSection == 3 ){ $('.labas-navigation').addClass('reverse black'); } else { $('.labas-navigation').removeClass('reverse black'); } } }); } /** * Handle slide navigation with arrow */ const handleNavigationNextPrev = () => { const button = $('.labas-navigation-item--last'); button.on('click', function() { let activeSection = $.fn.fullpage.getActiveSection().index(); if ( activeSection == 0) { $.fn.fullpage.moveSectionDown(); } else if ( activeSection == 1 ) { $.fn.fullpage.moveSectionDown(); } else if ( activeSection == 2 ) { $.fn.fullpage.moveSectionDown(); } else { $.fn.fullpage.moveSectionUp(); } }) } /** * Handle slide change on scroll back up of overlowed section */ const handleScrollBackUp = () => { const scrollable = $('.legal-section .fp-overflow'); if ( scrollable.length > 0 ) { $(scrollable).on('scroll', function() { let scrollPosition = $(this).scrollTop(); if (scrollPosition === 0) { $.fn.fullpage.moveSectionUp(); } }) } } /** * Set slider for steps section */ const stepsSlider = () => { $('.steps-slider').slick({ infinite: false, dots: true, slidesToShow: 1, slidesToScroll: 1, fade: true, adaptiveHeight: true }); } /** * Activate terms more button */ const accordion = () => { if ( screen.width < 768 || screen.height < 526 ) { $('.legal-accordion').click(function() { $(this).toggleClass('toggle'); $(this).next().slideToggle(); }); } } /** * Scroll to section */ const ScrollToSection = () => { $('a.scroll-to[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash; var $target = $(target); if ( screen.width < 767 || screen.height < 525 ) { $('html, body').stop().animate({ scrollTop: $target.offset().top - 70 }, 700); } else { $.fn.fullpage.moveSectionDown(); } return false; }); } })(jQuery);