1 |
- define(["knockout","jquery","ccResourceLoader!global/OCS_BFService","navigation","CCi18n"],function(e,t,n,r,i){"use strict";var s;return{WIDGET_ID:"x_SwiperBannerCollection",bannerContent:e.observableArray(),isMobile:e.observable(),showSwiper:e.observable(!1),banners:e.observableArray(),onLoad:function(e){window.onresize=function(){var t=e.isMobile(),n=e.checkViewport(992);t!=n&&e.isMobile(n)}},checkViewport:function(e){return window.innerWidth<e},renderSwiperCollectiontwo:function(){var e={slidesPerView:1.9,initialSlide:0,spaceBetween:20,lazy:{enabled:!0,preloaderClass:"skeleton-item",loadPrevNext:!0,loadPrevNextAmount:5},centeredSlides:!0,breakpoints:{320:{spaceBetween:20,slidesPerView:1.4},375:{spaceBetween:30,slidesPerView:"auto"},992:{slidesPerView:4,centeredSlides:!1},1366:{slidesPerView:4,centeredSlides:!1}}};s.isMobile()&&(e.loop=!0);var n=new Swiper(".swiper-banner-collection-2",e);if(s.hasOwnProperty("activeDots")&&s.activeDots()||s.checkViewport(375))e.pagination={el:".swiper-pagination-banner-collection-2",clickable:!0};setTimeout(function(){n.$wrapperEl&&(n.update(),s.showSwiper(!0),t("[class*='catSwiperImg']").on("click",function(e){e.stopPropagation(),e.currentTarget.dataset.hasOwnProperty("index")&&e.currentTarget.dataset.index&&s.gotoLink(s.bannerContent()[e.currentTarget.dataset.index].link)}))},500)},renderSwiperHomeAU:function(){var e={slidesPerView:1.9,spaceBetween:20,speed:500,centeredSlides:!0,loop:!0,watchOverflow:!0,breakpoints:{320:{spaceBetween:0,slidesPerView:1},768:{spaceBetween:0,slidesPerView:1},992:{slidesPerView:1.3},1366:{slidesPerView:1.9}},on:{beforeInit:function(){s.isMobile()&&(this.params.loop=!1)}}};s.hasOwnProperty("activeDots")&&s.activeDots()&&(e.pagination={el:".swiper-pagination-banner-collection-2",clickable:!0}),s.hasOwnProperty("activeArrows")&&s.activeArrows()&&(e.navigation={nextEl:".swiper-next-banner-collection-2",prevEl:".swiper-prev-banner-collection-2"}),s.hasOwnProperty("carouselInterval")&&s.carouselInterval()&&(e.autoplay={delay:s.carouselInterval()}),setTimeout(function(){var t=new Swiper(".swiper-banner-home-AU",e)},300)},getBanners:function(){var e=this,n=e.category().longDescription,r=t('<div style="display:none;">').append(t.parseHTML(n)),i=1;e.banners([]);while(r.find("#banner-collection-"+i).length>0){var s={"src-desktop":null,"src-mobile":null,title:null,url:null,alt:null,price:null,priceIva:null,priceBono:null,color:null},o=r.find("#banner-collection-"+i);for(var u in s)o.attr(u)&&(s[u]=o.attr(u));e.banners.push(s),i++}},priceUnavailableText:function(){return i.t("ns.recommendations:resources.priceUnavailable")},createBanners:function(){var e=this;e.bannerContent([]),e.banners().forEach(function(t){var n={imgDesktop:null,imgMobile:null,link:"#",title:"",alt:"",price:null,priceIva:null,priceBono:null,color:null};t.hasOwnProperty("src-desktop")&&t["src-desktop"]&&(n.imgDesktop="/file/"+t["src-desktop"],t.hasOwnProperty("src-mobile")&&t["src-mobile"]&&(n.imgMobile="/file/"+t["src-mobile"]),t.hasOwnProperty("title")&&(n.title=t.title),t.hasOwnProperty("url")&&(n.link=t.url),t.hasOwnProperty("alt")&&(n.alt=t.alt),t.hasOwnProperty("price")&&(n.price=t.price),t.hasOwnProperty("priceIva")&&(n.priceIva=t.priceIva),t.hasOwnProperty("priceBono")&&(n.priceBono=t.priceBono),t.hasOwnProperty("color")&&(n.color=t.color),e.bannerContent.push(n))}),setTimeout(function(){e.renderSwiperCollectiontwo()},1e3)},gotoLink:function(e){!e.indexOf("#")==0?r.goTo(e):e.indexOf("#")!=-1&&document.getElementById(e.replaceAll("#","")).scrollIntoView({behavior:"smooth"})},beforeAppear:function(){var e=this;e.isMobile(e.checkViewport(992)),s=e,e.showSwiper(!1),e.getBanners(),e.createBanners()}}})
|