$(function(){ if($('.jsSwiperMotion').length != 0){ jsSwiperMotion(); }; function jsSwiperMotion(){ $('.jsSwiperMotion .swiperWrap').each(function(){ var target = $(this), ul = target.find('ul'), list = ul.find('li'), bnt_left = target.closest('.jsSwiperMotion').find('.btnLeft'), bnt_right = target.closest('.jsSwiperMotion').find('.btnRight'), number = target.closest('.jsSwiperMotion').find('.swiperArrow .number'), show = 1, toScroll=1, dot = true; target.data('show') ? show = target.data('show') : show; target.data('toscroll') ? toScroll = target.data('toscroll') : toScroll = show; if(target.closest('.jsSwiperMotion').hasClass('type2')){ number.find('span').text(' / ' + Math.ceil(list.length/show)); ul.on("afterChange", function(event, slick, currentSlide){ target.find('.swiperArrow .number em').text(currentSlide/show +1); }); target.css('height','auto'); dot = false; } let slickObj = { prevArrow: bnt_left, nextArrow: bnt_right, infinite: false, slidesToShow: show, slidesToScroll: toScroll, dots: dot }; if (window.location.href.indexOf("front/reservation/reservationStep1To2") > -1) { slickObj["infinite"] = true; slickObj["pauseOnHover"] = false; slickObj["pauseOnFocus"] = false; slickObj["autoplay"] = true; slickObj["autoplaySpeed"] = 2000; } ul.slick(slickObj); target.closest('.jsSwiperMotion').show(); if(target.hasClass('imageWrap')){ ul.on("beforeChange", function(event, slick, currentSlide){ target.children('.textBox').find('> div').removeClass('on'); }); ul.on("afterChange", function(event, slick, currentSlide){ target.children('.textBox').find('> div').eq(currentSlide).addClass('on'); }); }; if(list.length/show <= 1){ target.next().hide(); }; }); }; });