(function($){
'use strict';
let m_debugSwiper=false;
let m_body=null;
let m_swiperEnabled=true;
let t_swiperEffect='';
window.addEventListener('DiadaoWpSdkStarted', event=> {
startScript();
});
function startScript(){
if(jQuery('body').hasClass('device-responsive') ){
t_swiperEffect="slide"
}else{
t_swiperEffect="fade"
}
if(m_swiperEnabled){
$(document).ready(function(){
m_body=$('body');
if(m_debugSwiper) console.log('-> swiper init ');
init_medias_swiper_sdk_template();
init_thumbnails_swiper_sdk_template();
init_accomodations_swiper_sdk_template();
});
}}
function init_medias_swiper_sdk_template(){
let t_swiperAutoplayDelay=4500;
var t_arraySwipers=$('.swiper-container.mediasSwiper');
if(t_arraySwipers!==undefined
&& t_arraySwipers.length
){
var t_swiperContainer=[], t_kwpbSwiperId=[], t_kwpbSwiperModule=[], t_kwpbSwiper=[];
t_arraySwipers.each(function(index){
t_swiperContainer[index]=$(this);
if(t_swiperContainer[index].data('diadaoswiperid')!==undefined
&& t_swiperContainer[index].data('diadaoswiperid')!==null
){
t_kwpbSwiperId[index]=t_swiperContainer[index].data('diadaoswiperid');
t_kwpbSwiperModule[index]=t_swiperContainer[index].parent();
if(!t_kwpbSwiperModule[index].hasClass('is-initialized') ){
if(m_debugSwiper) console.log("** init medias swiper sdk template:" + t_kwpbSwiperId[index], t_swiperContainer[index]);
t_kwpbSwiper[index]=new Swiper(t_swiperContainer[index][0], {
init: false,
spaceBetween: 0,
slidesPerView: 'auto',
speed: 1000,
loop: true,
centeredSlides: false,
clickable: false,
preventClicksPropagation: true,
preventClicks: true,
watchSlidesProgress: true,
autoplay: {
delay: t_swiperAutoplayDelay,
disableOnInteraction: false,
pauseOnMouseEnter: false,
waitForTransition: true,
},
navigation: {
nextEl: '.swiper-button-next.' + t_kwpbSwiperId[index],
prevEl: '.swiper-button-prev.' + t_kwpbSwiperId[index],
},
pagination: {
el: '.swiper-pagination.' + t_kwpbSwiperId[index],
clickable: true,
},
effect: t_swiperEffect,
crossFade: true,
breakpoints: {
0: {
simulateTouch: true,
},
992: {
simulateTouch: false,
}},
on: {
touchStart: function (){
this.params.speed=300;
console.log('touched');
},
transitionEnd: function (){
setTimeout(()=> {
this.params.speed=1000;
console.log('transitionEnd');
}, 1000);
},
},
});
t_kwpbSwiper[index].on('init', function(e){
t_kwpbSwiperModule[index].addClass('is-initialized');
});
t_kwpbSwiper[index].on('afterInit', function(e){
});
t_kwpbSwiper[index].init();
}}
});
}}
function init_thumbnails_swiper_sdk_template(){
var t_arraySwipers=$('.thumbnails-list__swiper');
if(t_arraySwipers!==undefined
&& t_arraySwipers.length
){
var t_swiperContainer=[], t_kwpbSwiperId=[], t_kwpbSwiperModule=[], t_kwpbSwiper=[];
t_arraySwipers.each(function(index){
t_swiperContainer[index]=$(this);
if(t_swiperContainer[index].data('diadaoswiperid')!==undefined
&& t_swiperContainer[index].data('diadaoswiperid')!==null
){
t_kwpbSwiperId[index]=t_swiperContainer[index].data('diadaoswiperid');
t_kwpbSwiperModule[index]=t_swiperContainer[index].parent();
if(!t_kwpbSwiperModule[index].hasClass('is-initialized') ){
if(m_debugSwiper) console.log("** init thumbnails swiper sdk template:" + t_kwpbSwiperId[index], t_swiperContainer[index]);
t_kwpbSwiper[index]=new Swiper(t_swiperContainer[index][0], {
init: false,
slidesPerView: 'auto',
navigation: {
nextEl: '.swiper-button-next.' + t_kwpbSwiperId[index],
prevEl: '.swiper-button-prev.' + t_kwpbSwiperId[index],
},
pagination: {
el: '.swiper-pagination.' + t_kwpbSwiperId[index],
clickable: true,
},
breakpoints: {
0: {
navigation: {
enabled: false,
},
spaceBetween: 8,
},
992: {
pagination: {
enabled: false,
},
spaceBetween: 24,
}},
effect: "slide",
});
t_kwpbSwiper[index].on('init', function(e){
t_kwpbSwiperModule[index].addClass('is-initialized');
});
t_kwpbSwiper[index].on('afterInit', function(e){
ScrollTrigger.refresh();
});
t_kwpbSwiper[index].init();
}}
});
}}
function init_accomodations_swiper_sdk_template(){
$('.accomodationsswiper').each((e,el)=> {
const accomodationsSwiper=new Swiper(
el,
{
init: false,
slidesPerView: 'auto',
spaceBetween: 0,
navigation: false,
pagination: false,
roundLengths: true,
breakpoints: {
0: {
slidesPerView: 'auto',
},
700: {
slidesPerView: 2,
},
992: {
slidesPerView: 2,
},
1440: {
slidesPerView: 3,
},
1640: {
slidesPerView: 4,
}},
effect: "slide",
on: {
init: function (e){
$(e.el).addClass('is-initialized');
},
}}
);
accomodationsSwiper.init();
});
}})(jQuery, Swiper);