1(function($) { 2 var SlidersController = { 3 TYPE_PRODUCTS_SLIDER: 1, // Full width sliders (homepage, shopping cart) + 3 bottom sliders on product page 4 TYPE_POSTS_SLIDER: 2, // Recent blog posts slider (on homepage + on "you might also like" block) 5 TYPE_PRODUCT_IMAGES_SLIDER: 3, // Product images slider 6 TYPE_VIDEOS_SLIDER: 4, // Slider with videos on blog home page 7 8 /** 9 * List of all sliders within controller 10 */ 11 sliders: [], 12 13 swiperInstances: [], 14 15 /** 16 * Bind events for sliders 17 */ 18 bindEvents: function() { 19 var controller = this; 20 $(window).scroll(function() { 21 clearTimeout($.data(this, 'scrollTimer')); 22 $('body').addClass('scrolling'); 23 $.data(this, 'scrollTimer', setTimeout(function() { 24 $('body').removeClass('scrolling'); 25 }, 500)); 26 }); 27 28 // Resize sliders 29 $(window).resize(function () { 30 controller.fixPagination(); 31 if ($('.piscesslider lottie-player').length) controller.setPiscesLottieSrc(); 32 if ($('lottie-player').length) controller.fixLottieHeight(); 33 }); 34 35 // Slider at product videos tab on product page 36 controller.initProductVideosTab(); 37 }, 38 39 /** 40 * Set unique id for swiper container 41 * @returns {undefined} 42 */ 43 giveId: function($element, selector, index) { 44 var id = $element.attr('id'); 45 if (!id) { 46 id = btoa(selector).toString().split('=').join('_') + '_' + index; 47 $element.attr('id', id); 48 } 49 return id; 50 }, 51 52 /** 53 * Hide pagination bullets if there is only one page for slider 54 */ 55 fixPagination: function() { 56 $('.swiper-pagination').each(function() { 57 if ($(this).find('.swiper-pagination-bullet').length === 1) { 58 $(this).addClass('no-pages'); 59 } 60 else { 61 $(this).removeClass('no-pages'); 62 } 63 }); 64 }, 65 66 fixLottieHeight: function() { 67 $( "lottie-player:not(.tribe-splio-lottie-desktop, .tribe-spli
67o-lottie-mobile)" ).each(function() { 68 let bannerSvg = $(this)[0].shadowRoot; 69 bannerSvg = $(bannerSvg).find('svg'); 70 let bannerHeight = $('#piscesslider-height').length > 0 ? $('#piscesslider-height').height() + 'px' : 'calc(19vw + 100px)'; 71 $(bannerSvg).removeAttr('style').removeAttr('width').attr('height', bannerHeight).attr('preserveAspectRatio', 'xMidYMid slice'); 72 if (424 < window.innerWidth && window.innerWidth < 480) { 73 let bannerWidth = $('#piscesslider-height').length > 0 ? $('#piscesslider-height').width() + 30 : 'calc(60vw + 30px)'; 74 $(bannerSvg).removeAttr('style').removeAttr('width').attr('height', bannerHeight).attr('width', bannerWidth).attr('preserveAspectRatio', 'xMidYMid slice'); 75 } 76 }); 77 }, 78 79 setPiscesLottieSrc: function() { 80 var isDesktop = window.innerWidth > 479; 81 $('.piscesslider lottie-player[data-src-desktop], .piscesslider lottie-player[data-src-mobile]').each(function() { 82 var d = $(this).data('src-desktop') || this.getAttribute('data-src-desktop') || ''; 83 var m = $(this).data('src-mobile') || this.getAttribute('data-src-mobile') || ''; 84 var src = ''; 85 if (isDesktop) { 86 src = (d && d.indexOf('.json') !== -1) ? d : (m && m.indexOf('.json') !== -1 ? m : d || m); 87 } else { 88 src = (m && m.indexOf('.json') !== -1) ? m : (d && d.indexOf('.json') !== -1 ? d : m || d); 89 } 90 if (src && this.getAttribute('src') !== src) { 91 this.setAttribute('src', src); 92 } 93 }); 94 }, 95 96 /** 97 * Add slider to controller 98 * @param string Slider selector 99 * @param int Slider type 100 * @param object Additional parameters for slider 101 */ 102 add: function(selector, type, options) { 103 if ('undefined' === typeof type) { 104 type = this.TYPE_PRODUCTS_SLIDER 105 } 106 if ('undefined' === typeof options) { 107 options = {}; 108 } 109 var sliderData = this.prepareSliderData({ 110 selector: selector, 111 type: type, 112 options: options, 113 reinit: false, 114 resize: false, 115 data: [] 116 }); 117 118 this.sliders.push(sliderData); 119 var slider = this.initSlider(sliderData); 120 this.swiperInstances[selector] = slider; 121 return slider; 122 }, 123 124 /** 125 * Set default values for slider options 126 * @returns object Slider options 127 */ 128 prepareSliderData: function(data) { 129 if (data.type == SlidersController.TYPE_PRODUCTS_SLIDER) { 130 if (typeof(data.options.slideSelector) == "undefined") { 131 data.options.slideSelector = '.ajax_block_product'; 132 } 133 if (typeof(data.options.itemWidth) == "undefined") { 134 data.options.itemWidth = 205; 135 } 136 var defaultXsBreakpoint = { 137 slidesPerView: 2, 138 spaceBetween: 0, 139 slidesPerGroup: 1 140 }; 141 var defaultSmallBreakpoint = { 142 slidesPerView: 2, 143 spaceBetween: 0, 144 slidesPerGroup: 1 145 }; 146 var defaultMdBreakpoint = { 147 slidesPerView: 3, 148 spaceBetween: 0, 149 slidesPerGroup: 1 150 }; 151 var defaultLgBreakpoint = { 152 slidesPerView: 3, 153 spaceBetween: 0, 154 slidesPerGroup: 1 155 }; 156 var defaultBigBreakpoint = { 157 slidesPerView: 4, 158 spaceBetween: 0, 159 slidesPerGroup: 1 160 }; 161 if (typeof(data.options.breakpoints) == "undefined") { 162 data.options.breakpoints = { 163 xs: defaultXsBreakpoint, 164 md: defaultMdBreakpoint, 165 small: defaultSmallBreakpoint, 166 lg: defaultLgBreakpoint, 167 big: defaultBigBreakpoint 168 }; 169 } 170 else { 171 // Default values for xs breakpoint 172 if (typeof(data.options.breakpoints.xs) == "undefined") { 173 data.options.breakpoints.xs = defaultXsBreakpoint; 174 } 175 else { 176 if (typeof(data.options.breakpoints.xs.slidesPerView) == "undefined") { 177 data.options.breakpoints.xs.slidesPerView = defaultXsBreakpoint.slidesPerView; 178 } 179 if (typeof(data.options.breakpoints.xs.slidesPerView) == "undefined") { 180 data.options.breakpoints.xs.spaceBetween = defaultXsBreakpoint.spaceBetween; 181 } 182 if (typeof(data.options.breakpoints.xs.slidesPerGroup) == "undefined") { 183 data.options.breakpoints.xs.slidesPerGroup = defaultXsBreakpoint.slidesPerGroup; 184 } 185 } 186 // Default values for small breakpoint 187 if (typeof(data.options.breakpoints.small) == "undefined") { 188 data.options.breakpoints.small = defaultSmallBreakpoint; 189 } 190 else { 191 if (typeof(data.options.breakpoints.small.slidesPerView) == "undefined") { 192 data.options.breakpoints.small.slidesPerView = defaultSmallBreakpoint.slidesPerView; 193 } 194 if (typeof(data.options.breakpoints.small.slidesPerView) == "undefined") { 195 data.options.breakpoints.small.spaceBetween = defaultSmallBreakpoint.spaceBetween; 196 } 197 if (typeof(data.options.breakpoints.small.slidesPerGroup) == "undefined") { 198 data.options.breakpoints.small.slidesPerGroup = defaultSmallBreakpoint.slidesPerGroup; 199 } 200 } 201 // Default values for medium breakpoint 202 if (typeof(data.options.breakpoints.md) == "undefined") { 203 data.options.breakpoints.md = defaultMdBreakpoint; 204 } 205 else { 206 if (typeof(data.options.breakpoints.md.slidesPerView) == "undefined") { 207 data.options.breakpoints.md.slidesPerView = defaultMdBreakpoint.slidesPerView; 208 } 209 if (typeof(data.options.breakpoints.md.slidesPerView) == "undefined") { 210 data.options.breakpoints.md.spaceBetween = defaultMdBreakpoint.spaceBetween; 211 } 212 if (typeof(data.options.breakpoints.md.slidesPerGroup) == "undefined") { 213 data.options.breakpoints.md.slidesPerGroup = defaultMdBreakpoint.slidesPerGroup; 214 } 215 } 216 // Default values for large breakpoint 217 if (typeof(data.options.breakpoints.lg) == "undefined") { 218 data.options.breakpoints.lg = defaultLgBreakpoint; 219 } 220 else { 221 if (typeof(data.options.breakpoints.lg.slidesPerView) == "undefined") { 222 data.options.breakpoints.lg.slidesPerView = defaultLgBreakpoint.slidesPerView; 223 } 224 if (typeof(data.options.breakpoints.lg.slidesPerView) == "undefined") { 225 data.options.breakpoints.lg.spaceBetween = defaultLgBreakpoint.spaceBetween; 226 } 227 if (typeof(data.options.breakpoints.lg.slidesPerGroup) == "undefined") { 228 data.options.breakpoints.lg.slidesPerGroup = defaultLgBreakpoint.slidesPerGroup; 229 } 230 } 231 // Default values for big breakpoint 232 if (typeof(data.options.breakpoints.big) == "undefined") { 233 data.options.breakpoints.big = defaultBigBreakpoint; 234 } 235 else { 236 if (typeof(data.options.breakpoints.big.slidesPerView) == "undefined") { 237 data.options.breakpoints.big.slidesPerView = defaultBigBreakpoint.slidesPerView; 238 } 239 if (typeof(data.options.breakpoints.big.slidesPerView) == "undefined") { 240 data.options.breakpoints.big.spaceBetween = defaultBigBreakpoint.spaceBetween; 241 } 242 if (typeof(data.options.breakpoints.big.slidesPerGroup) == "undefined") { 243 data.options.breakpoints.big.slidesPerGroup = defaultBigBreakpoint.slidesPerGroup; 244 } 245 } 246 } 247 } 248 return data; 249 }, 250 251 /** 252 * Initialize sliders on page 253 * @param object sliderData 254 */ 255 initSlider: function(sliderData) { 256 var slider = false;
257 switch (sliderData.type) { 258 case SlidersController.TYPE_POSTS_SLIDER: 259 slider = this.initPostsSlider(sliderData); 260 return slider; 261 case SlidersController.TYPE_PRODUCTS_SLIDER: 262 slider = this.initProductsSlider(sliderData); 263 return slider; 264 case SlidersController.TYPE_PRODUCT_IMAGES_SLIDER: 265 slider = this.initProductImagesSlider(sliderData); 266 return slider; 267 case SlidersController.TYPE_VIDEOS_SLIDER: 268 slider = this.initVideosSlider(sliderData); 269 return slider; 270 default: 271 break; 272 } 273 }, 274 275 /** 276 * Initialize posts slider 277 * @param object sliderData 278 */ 279 initPostsSlider: function(sliderData) { 280 var slider =this.initProductsSlider(sliderData); 281 return slider; 282 }, 283 284 /** 285 * Initialize products slider 286 * @param object sliderData 287 */ 288 initProductsSlider: function(sliderData) { 289 var slider = false; 290 var self = this; 291 if ($(sliderData.selector).length) { 292 var controller = this; 293 $(sliderData.selector).each(function(index) { 294 var id = controller.giveId($(this), sliderData.selector, index); 295 296 var recommendedSelectors = self.getRecommendedSelectors(); 297 recommendedSelectors.forEach(function (recommendedSelector) { 298 if (recommendedSelector === sliderData.selector && $(sliderData.selector + ' li[data-recommended-incart|=1]').length) { 299 $(sliderData.selector + ' li[data-recommended-incart|=1]').each(function () { 300 if (typeof detachedRecommended[sliderData.selector] === 'undefined') { 301 detachedRecommended[sliderData.selector] = []; 302 } 303 detachedRecommended[sliderData.selector][$(this).attr('data-id-recommended')] = { 304 index: $(this).attr('data-recommended-index'), 305 el: $(this).detach() 306 }; 307 }); 308 if (!$(sliderData.selector + ' .swiper-wrapper li').length) { 309 $(sliderData.selector).closest('.recommended-block').hide(); 310 } 311 } 312 }); 313 314 slider = new Swiper('#' + id, { 315 pagination: sliderData.options.pagination ? sliderData.options.pagination : $('#' + id + ' + .swiper-controls .swiper-pagination'), 316 paginationClickable: true, 317 autoplay: false, 318 nextButton: sliderData.options.nextButton ? sliderData.options.nextButton : $('#' + id + ' + .swiper-controls .swiper-button-next'), 319 prevButton: sliderData.options.prevButton ? sliderData.options.prevButton : $('#' + id + ' + .swiper-controls .swiper-button-prev'), 320 slidesPerView: sliderData.options.breakpoints.big.slidesPerView, 321 slidesPerGroup: sliderData.options.breakpoints.big.slidesPerGroup ? sliderData.options.breakpoints.big.slidesPerGroup : 1, 322 centeredSlides: false, 323 spaceBetween: sliderData.options.breakpoints.big.spaceBetween ? sliderData.options.breakpoints.big.spaceBetween : 20, 324 watchOverflow: true, 325 passiveListeners: false, 326 initialSlide: sliderData.options.initialSlide?sliderData.options.initialSlide:0, 327 onTransitionStart: function () { 328 if (typeof(lazyResponsive) != 'undefined' && typeof lazyResponsive.update === 'function') { 329 lazyResponsive.update(); 330 } 331 if (typeof(lazyInstance) != 'undefined' && typeof lazyResponsive.update === 'function') { 332 lazyInstance.update(); 333 } 334 }, 335 onSlideChangeEnd: function(swiper) { 336 if (typeof sliderData.options.onSlideChangeEnd === 'function') { 337 sliderData.options.onSlideChangeEnd(swiper); 338 } 339 }, 340 breakpoints: { 341 545: { 342 slidesPerView: sliderData.options.breakpoints.xs.slidesPerView, 343 spaceBetween: sliderData.options.breakpoints.xs.spaceBetween, 344 slidesPerGroup: sliderData.options.breakpoints.xs.slidesPerGroup ? sliderData.options.breakpoints.xs.slidesPerGroup : 1 345 }, 346 767: { 347 slidesPerView: sliderData.options.breakpoints.small.slidesPerView, 348 spaceBetween: sliderData.options.breakpoints.small.spaceBetween, 349 slidesPerGroup: sliderData.options.breakpoints.small.slidesPerGroup ? sliderData.options.breakpoints.small.slidesPerGroup : 1 350 }, 351 992: { 352 slidesPerView: sliderData.options.breakpoints.md.slidesPerView, 353 spaceBetween: sliderData.options.breakpoints.md.spaceBetween, 354 slidesPerGroup: sliderData.options.breakpoints.md.slidesPerGroup ? sliderData.options.breakpoints.md.slidesPerGroup : 1 355 }, 356 1199: { 357 slidesPerView: sliderData.options.breakpoints.lg.slidesPerView, 358 spaceBetween: sliderData.options.breakpoints.lg.spaceBetween, 359 slidesPerGroup: sliderData.options.breakpoints.lg.slidesPerGroup ? sliderData.options.breakpoints.lg.slidesPerGroup : 1 360 }, 361 2000: { 362 slidesPerView: sliderData.options.breakpoints.big.slidesPerView, 363 spaceBetween: sliderData.options.breakpoints.big.spaceBetween, 364 slidesPerGroup: sliderData.options.breakpoints.big.slidesPerGroup ? sliderData.options.breakpoints.big.slidesPerGroup : 1 365 } 366 } 367 }); 368 369 370 }); 371 } 372 return slider; 373 }, 374 375 /** 376 * Initialize product images slider 377 * @param object sliderData 378 */ 379 initProductImagesSlider: function(sliderData) { 380 var slider = new Swiper(sliderData.selector, {
381 pagination: sliderData.selector + ' + .swiper-controls .swiper-pagination', 382 paginationClickable: true, 383 autoplay: false, 384 nextButton: sliderData.selector + ' + .swiper-controls .swiper-button-next', 385 prevButton: sliderData.selector + ' + .swiper-controls .swiper-button-prev', 386 slidesPerView: 2, 387 centeredSlides: false, 388 spaceBetween: 10, 389 passiveListeners: false, 390 onTransitionStart: function () { 391 if (typeof(lazyResponsive) != 'undefined' && typeof lazyResponsive.update === 'function') { 392 lazyResponsive.update(); 393 } 394 if (typeof(lazyInstance) != 'undefined') { 395 lazyInstance.update(); 396 } 397 }, 398 breakpoints: { 399 991: { 400 slidesPerView: 1, 401 centeredSlides: true 402 } 403 } 404 }); 405 return slider; 406 }, 407 408 /** 409 * Initialize videos slider 410 * @param object sliderData 411 */ 412 initVideosSlider: function(sliderData) { 413 var controller = this; 414 var slider = false; 415 if ($(sliderData.selector).length) { 416 $(sliderData.selector).each(function(index) { 417 var id = controller.giveId($(this), sliderData.selector, index); 418 slider = new Swiper('#' + id, { 419 slidesPerView: 1, 420 pagination: '#' + id + ' + .swiper-controls .swiper-pagination', 421 paginationClickable: true, 422 autoplay: false, 423 nextButton: '#' + id + ' + .swiper-controls .swiper-button-next', 424 prevButton: '#' + id + ' + .swiper-controls .swiper-button-prev', 425 centeredSlides: true, 426 autoHeight: true, 427 passiveListeners: false, 428 onTransitionStart: function () { 429 if (typeof(lazyResponsive) != 'undefined' && typeof lazyResponsive.update === 'function') { 430 lazyResponsive.update(); 431 } 432 if (typeof(lazyInstance) != 'undefined' && typeof lazyResponsive.update === 'function') { 433 lazyInstance.update(); 434 } 435 } 436 }); 437 }); 438 } 439 return slider; 440 }, 441 442 /** 443 * Run slider at product videos tab on product page (module `productvideos`) 444 */ 445 initProductVideosTab: function() { 446 if ($('#tab_productvideos').length) { 447 $carousel = $('#tab_productvideos').find('.swiper-container'); 448 if ($carousel.find('.single-slide').length) { 449 this.initVideosSlider({ selector: '#tab_productvideos .swiper-container' }); 450 } 451 } 452 }, 453 454 /** 455 * Init sliders for steps (schemamarkup) 456 */ 457 stepSlider: function() { 458 if ($('.swiper-container.swiper_step_carousel').length) { 459 $('.swiper-container.swiper_step_carousel').each(function() { 460 const images_swiper = $(this)[0].swiper; 461 let thumbs = $(this).next().find('.swiper-container.swiper_step_thumbs_carousel'); 462 const images_swiper2 = thumbs[0].swiper; 463 464 let click = false; 465 $(thumbs).find('.swiper-slide').click(function () { 466 images_swiper.slideTo($(this).index()); 467 images_swiper2.slideTo($(this).index()); 468 $(thumbs).find('.swiper-slide').removeClass('selected-slide'); 469 $(this).addClass('selected-slide'); 470 click = true; 471 }); 472 473 // add custom behaviour to nav buttons in order to be able to reach to the last slide in thumbs 474 $(thumbs).next().find('.step-swiper-button-next').click(function () { 475 images_swiper.slideTo(images_swiper.activeIndex + 1); 476 }); 477 478 $(thumbs).next().find('.step-swiper-button-prev').click(function () { 479 images_swiper.slideTo(images_swiper.activeIndex - 1); 480 }); 481 482 const transitionEnd = images_swiper.onTransitionEnd; 483 images_swiper.onTransitionEnd = function onTransitionEnd(e) { 484 $(thumbs).next().find('.step-nav').removeClass('step-swiper-button-disabled') 485 if (images_swiper.activeIndex + 1 === $(thumbs).find('.swiper-slide').length) { 486 $(thumbs).next().find('.step-swiper-button-next').addClass('step-swiper-button-disabled'); 487 } 488 if (images_swiper.activeIndex === 0) { 489 $(thumbs).next().find('.step-swiper-button-prev').addClass('step-swiper-button-disabled'); 490 } 491 images_swiper2.slideTo(images_swiper.activeIndex); 492 $(thumbs).find('.swiper-slide').removeClass('selected-slide'); 493 $(thumbs).find('.swiper-slide').eq(images_swiper.activeIndex).addClass('selected-slide'); 494 transitionEnd(); 495 }; 496 497 const transitionEnd2 = images_swiper2.onTransitionEnd; 498 images_swiper2.onTransitionEnd = function onTransitionEnd(e) { 499 if (!click) { 500 images_swiper.slideTo(images_swiper2.activeIndex); 501 $(thumbs).find('.swiper-slide').removeClass('selected-slide'); 502 $(thumbs).find('.swiper-slide').eq(images_swiper2.activeIndex).addClass('selected-slide'); 503 } 504 click = false;
505 transitionEnd2(); 506 }; 507 }); 508 } 509 }, 510 511 /** 512 * Init sliders with customer pictures for product. See module 'productgallery' 513 */ 514 productGallery: function() { 515 if ($('.gallery_images_wrap .customer_images_top_carousel').length) { 516 this.add('.gallery_images_wrap .customer_images_top_carousel', this.TYPE_PRODUCTS_SLIDER, { 517 breakpoints: { 518 xs: { slidesPerView: 1, spaceBetween: 15 }, 519 small: { slidesPerView: 1, spaceBetween: 15 }, 520 md: { slidesPerView: 1, spaceBetween: 15 }, 521 big: { slidesPerView: 1, spaceBetween: 15 } 522 } 523 }); 524 525 // Fix slides for current breakpoint if slider is hidden and should be displayed 526 $('a[href="#idTab444"]').click(function() { 527 if (typeof($('.gallery_images_wrap .customer_images_top_carousel')[0].swiper) !== 'undefined') { 528 $('.gallery_images_wrap .customer_images_top_carousel')[0].swiper.update(); 529 } 530 $('.gallery_images_wrap .swiper-slide img').Lazy({ 531 chainable: false, 532 afterLoad: function (element) { 533 $('#pictures_slider .load').removeClass('load'); 534 } 535 }); 536 }); 537 } 538 if ($('.gallery_images_wrap .customer_images_bottom_carousel').length) { 539 this.add('.gallery_images_wrap .customer_images_bottom_carousel'); 540 541 if ($('.gallery_images_wrap .customer_images_top_carousel').length) { 542 var images_swiper = $('.gallery_images_wrap .customer_images_top_carousel')[0].swiper; 543 $('.gallery_images_wrap .customer_images_bottom_carousel .swiper-slide').click(function() { 544 images_swiper.slideTo($(this).index()); 545 }); 546 } 547 } 548 }, 549 550 /** 551 * Home page header slider 552 */ 553 initPiscesslider: function() { 554 if ($('#header .slide_holder.piscesslider .swiper-container').length) { 555 new Swiper('#header .slide_holder.piscesslider .swiper-container', { 556 // loop: true, 557 slidesPerView: 1, 558 pagination: '#header .slide_holder.piscesslider .swiper-container + .swiper-controls .swiper-pagination', 559 paginationClickable: true, 560 autoplay: 3500, 561 speed: 1000, 562 centeredSlides: true, 563 spaceBetween: 0, 564 passiveListeners: false, 565 onTransitionStart: function (event) { 566 SlidersController.fixLottieHeight(); 567 if (typeof(lazyResponsive) != 'undefined' && typeof lazyResponsive.update === 'function') { 568 lazyResponsive.update(); 569 } 570 if (typeof(lazyInstance) != 'undefined' && typeof lazyResponsive.update === 'function') { 571 lazyInstance.update(); 572 } 573 const swiper = event; 574 const newIndex = swiper.activeIndex; 575 currentLottieIndex = newIndex; 576 const newSlide = swiper.slides[newIndex]; 577 const newLottiePlayer = newSlide.querySelector('lottie-player'); 578 if (newLottiePlayer) { 579 var lottieIndex = $(newLottiePlayer).data('id'); 580 var lotieName = 'lotties_' + lottieIndex; 581 if ($('.bannerLottie-' + lottieIndex).length && typeof window[lotieName] !== 'undefined') { 582 var lottie = window[lotieName][0]; 583 if (lottie) { 584 lottie.jumpToInteraction(0); 585 lottieActiveAnimation = false; 586 } 587 $('.piscesslider lottie-player').each(function() { 588 if ($(this).data('id') != currentLottieIndex) { 589 this.pause(); 590 } 591 }); 592 } 593 } 594 }, 595 onInit: function() { 596 SlidersController.setPiscesLottieSrc(); 597 if (typeof(fullWidthSupport) === 'function') { 598 fullWidthSupport(); 599 } 600 }, 601 onImagesReady: function() { 602 if (typeof(fullWidthSupport) === 'function') { 603 fullWidthSupport(); 604 } 605 } 606 }); 607 } 608 }, 609 610 /** 611 * Run sliders on pages 612 */ 613 run: function() { 614 var controller = this; 615 $(document).ready(function () { 616 // Homepage categories sliders and Mushroomcalculator 617 var selector = '.indexPage .slider-wrapper.products-slider .swiper-container, .mushroom-slider .swiper-container, .home-slider-category.shortcode .slider-wrapper.products-slider .swiper-container'; 618 if ($(selector).length) { 619 controller.add(selector, sliders().TYPE_PRODUCTS_SLIDER, { 620 breakpoints: { 621 xs: { slidesPerView: 2, spaceBetween: 17 }, 622 small: { slidesPerView: 3, spaceBetween: 17 }, 623 big: { slidesPerView: 5, spaceBetween: 17 } 624 } 625 }); 626 } 627 628 if ($('.swiper_step_carousel.swiper-container').length) { 629 controller.add('.swiper_step_carousel.swiper-container', controller.TYPE_PRODUCTS_SLIDER, { 630 breakpoints: { 631 xs: {slidesPerView: 1, spaceBetween: 15}, 632 small: {slidesPerView: 1, spaceBetween: 15}, 633 md: { slidesPerView: 1, spaceBetween: 15 }, 634 big: {slidesPerView: 1, spaceBetween: 15} 635 } 636 }); 637 638 controller.add('.swiper_step_thumbs_carousel.swiper-container', controller.TYPE_PRODUCTS_SLIDER, { 639 breakpoints: { 640 xs: {slidesPerView: 2, spaceBetween: 15}, 641 small: {slidesPerView: 2, spaceBetween: 15}, 642 md: { slidesPerView: 3, spaceBetween: 15 }, 643 big: {slidesPerView: 3, spaceBetween: 15} 644 } 645 }); 646 } 647 648 // Product page - accessories products slider 649 if ($('#accessories-product-list .accessories-list').length) { 650 controller.add('#accessories-product-list .accessories-list', controller.TYPE_PRODUCTS_SLIDER); 651 } 652 653 // Product page - recommended products slider 654 if ($('#recommended_products .crossselling-carousel').length) { 655 controller.add('#recommended_products .crossselling-carousel', controller.TYPE_PRODUCTS_SLIDER, { 656 breakpoints: { 657 xs: {slidesPerView: 2, spaceBetween: 18}, 658 small: {slidesPerView: 3, spaceBetween: 18}, 659 md: {slidesPerView: 4, spaceBetween: 18}, 660 lg: {slidesPerView: 3, spaceBetween: 18}, 661 big: {slidesPerView: 4, spaceBetween: 18} 662 } 663 }); 664 } 665 666 // Checkout page - recommended products slider 667 if ($('div:not(.empty-cart) .checkout_recommended_products_list').length) { 668 controller.add('.checkout_recommended_products_list', controller.TYPE_PRODUCTS_SLIDER, { 669 breakpoints: { 670 xs: {slidesPerView: 1.75, spaceBetween: 12}, 671 small: {slidesPerView: 3, spaceBetween: 12}, 672 md: {slidesPerView: 3.5, spaceBetween: 12}, 673 lg: {slidesPerView: 3, spaceBetween: 12}, 674 big: {slidesPerView: 3.5, spaceBetween: 12} 675 } 676 }); 677 } 678 679 // Empty shopping cart page - recommended products slider 680 if ($('.empty-cart .checkout_recommended_products_list').length) { 681 controller.add('.checkout_recommended_products_list', controller.TYPE_PRODUCTS_SLIDER, { 682 breakpoints: { 683 xs: {slidesPerView: 1.75, spaceBetween: 12}, 684 small: {slidesPerView: 3, spaceBetween: 12}, 685 md: {slidesPerView: 5.5, spaceBetween: 12}, 686 lg: {slidesPerView: 4, spaceBetween: 12}, 687 big: {slidesPerView: 5.5, spaceBetween: 12} 688 } 689 }); 690 } 691 692 // Empty shopping cart page - recent products slider 693 if ($('.empty-cart .checkout_recent_products_list').length) { 694 controller.add('.checkout_recent_products_list', controller.TYPE_PRODUCTS_SLIDER, { 695 breakpoints: { 696 xs: {slidesPerView: 1.75, spaceBetween: 12}, 697 small: {slidesPerView: 3, spaceBetween: 12}, 698 md: {slidesPerView: 5.5, spaceBetween: 12}, 699 lg: {slidesPerView: 4, spaceBetween: 12}, 700 big: {slidesPerView: 5.5, spaceBetween: 12} 701 } 702 }); 703 } 704 705 // Customer order history page - slider with order products 706 if ($('.historyPage .order_history_carousel').length) { 707 controller.add('.historyPage .order_history_carousel', controller.TYPE_PRODUCTS_SLIDER, { 708 breakpoints: { 709 xs: { slidesPerView: 2, spaceBetween: 15 }, 710 small: { slidesPerView: 3, spaceBetween: 15 }, 711 big: { slidesPerView: 4, spaceBetween: 15 } 712 } 713 }); 714 } 715 716 // Blog posts slider on home page 717 if ($('.last_news_carousel').length) { 718 controller.add('.last_news_carousel', controller.TYPE_POSTS_SLIDER, { 719 breakpoints: { 720 xs: { slidesPerView: 1, spaceBetween: 15 }, 721 small: { slidesPerView: 2, spaceBetween: 15 }, 722 md: { slidesPerView: 2, spaceBetween: 15 }, 723 lg: { slidesPerView: 2, spaceBetween: 15 }, 724 big: { slidesPerView: 2, spaceBetween: 15 } 725 } 726 }); 727 } 728 729 // affiliate page slider 730 if ($('.affiliate_page_carousel').length) { 731 controller.add('.affiliate_page_carousel', controller.TYPE_PRODUCTS_SLIDER, { 732 breakpoints: { 733 xs: { slidesPerView: 1.3, spaceBetween: 10 }, 734 small: { slidesPerView: 2.3, spaceBetween: 15 }, 735 md: { slidesPerView: 3.3, spaceBetween: 20 }, 736 lg: { slidesPerView: 4.3, spaceBetween: 20 }, 737 big: { slidesPerView: 4.5, spaceBetween: 20 } 738 } 739 }); 740 } 741 742 // Recommended products on CMS page 743 if ($('.cmsPage .crossselling-carousel').length) { 744 controller.add('.cmsPage .crossselling-carousel', controller.TYPE_PRODUCTS_SLIDER, { 745 breakpoints: { 746 xs: {slidesPerView: 2, spaceBetween: 16}, 747 small: {slidesPerView: 3, spaceBetween: 16}, 748 md: {slidesPerView: 4.5, spaceBetween: 24}, 749 lg: { slidesPerView: 3, spaceBetween: 24}, 750 big: {slidesPerView: 4.5, spaceBetween: 24} 751 } 752 }); 753 } 754 755 // Recommended products on Grow Guide page 756 if ($('.grow-guidePage .crossselling-carousel').length) { 757 controller.add('.grow-guidePage .crossselling-carousel', controller.TYPE_PRODUCTS_SLIDER, { 758 breakpoints: { 759 xs: { slidesPerView: 2, spaceBetween: 16 }, 760 small:{ slidesPerView: 3, spaceBetween: 16 }, 761 md: { slidesPerView: 4.5, spaceBetween: 24 }, 762 lg: { slidesPerView: 3, spaceBetween: 24 }, 763 big: { slidesPerView: 4.5, spaceBetween: 24 } 764 } 765 }); 766 } 767 768 // Product images mobile slider (with large images) 769 if ($('.thumbs_list_mobile .swiper-container').length) { 770 controller.add('.thumbs_list_mobile .swiper-container', controller.TYPE_PRODUCT_IMAGES_SLIDER); 771 } 772 773 // Slider with links for more information about this product 774 if ($('#linkedpages_carousel').length) { 775 controller.add('#linkedpages_carousel', controller.TYPE_PRODUCTS_SLIDER, { 776 breakpoints: { 777 xs: { slidesPerView: 'auto', spaceBetween: 20 }, 778 small: { slidesPerView: 'auto', spaceBetween: 0 }, 779 md: { slidesPerView: 'auto', spaceBetween: 0 }, 780 big: { slidesPerView: 'auto', spaceBetween: 0 } 781 } 782 }); 783 } 784 785 //splio sliders 786 if ($('#redeem_carousel').length) { 787 controller.add('#redeem_carousel', controller.TYPE_PRODUCTS_SLIDER, { 788 breakpoints: { 789 xs: { slidesPerView: 2, spaceBetween: 25}, 790 small: { slidesPerView: 2, spaceBetween: 25}, 791 md: { slidesPerView: 4, spaceBetween: 25 }, 792 lg: { slidesPerView: 4 , spaceBetween: 25}, 793 big: { slidesPerView: 4, spaceBetween: 25 } 794 } 795 }); 796 } 797 798 if ($('#ranks-benefits-slider').length) { 799 controller.add('#ranks-benefits-slider', controller.TYPE_PRODUCTS_SLIDER, { 800 breakpoints: { 801 xs: { slidesPerView: 1 , spaceBetween: 0}, 802 small: { slidesPerView: 1 , spaceBetween: 0}, 803 lg: { slidesPerView: 1 , spaceBetween: 0}, 804 md: { slidesPerView: 1, spaceBetween: 35 }, 805 big: { slidesPerView: 1, spaceBetween: 35 } 806 }, 807 808 }); 809 } 810 811 if ($('.home_new_products_carousel').length) { 812 controller.add('.home_new_products_carousel', controller.TYPE_PRODUCTS_SLIDER, { 813 breakpoints: { 814 xs: { slidesPerView: 2, spaceBetween: 17 }, 815 small: { slidesPerView: 3, spaceBetween: 17 }, 816 big: { slidesPerView: 5, spaceBetween: 17 } 817 } 818 }); 819 } 820 821 if ($('.cmsproducts-slider').length) { 822 controller.add('.cmsproducts-slider', controller.TYPE_PRODUCTS_SLIDER, { 823 breakpoints: { 824 xs: { slidesPerView: 2, spaceBetween: 17 }, 825 small: { slidesPerView: 3, spaceBetween: 17 }, 826 big: { slidesPerView: 5, spaceBetween: 17 } 827 } 828 }); 829 } 830 831 controller.fixPagination(); 832 controller.initModules(); 833 }); 834 }, 835 836 initModules: function() { 837 this.stepSlider(); 838 this.productGallery(); 839 this.initPiscesslider(); 840 }, 841 842 getRecommendedSelectors: function() { 843 return ['#recommended_products .crossselling-carousel', '.cmsPage .crossselling-carousel', '.checkout_recommended_products_list']; 844 }, 845 846 getRecommendedSlidesPerView: function(selector) { 847 let breakpointsObj = this.swiperInstances[selector].originalParams.breakpoints; 848 let slidesPerView;
849 Object.keys(breakpointsObj).forEach(function(key) { 850 if (window.innerWidth <= key) { 851 if (!slidesPerView) { 852 slidesPerView = breakpointsObj[key].slidesPerView; 853 } 854 } 855 }); 856 if (!slidesPerView) { 857 slidesPerView = 4; 858 } 859 return slidesPerView; 860 }, 861 }; 862 863 // Reference SlidersController via sliders() globally 864 window.sliders = function() { 865 return SlidersController; 866 } 867 868 // Bind sliders events 869 window.sliders().bindEvents(); 870 871 // Initialize sliders 872 window.sliders().run(); 873 874 $( ".piscesslider .swiper-slide" ).on( "mousedown touchstart", function() { 875 SlidersController.fixLottieHeight(); 876 var nextLottie = window['lotties_' + (currentLottieIndex + 1)]; 877 var prevLottie = window['lotties_' + (currentLottieIndex - 1)]; 878 if (typeof(nextLottie) != 'undefined' && nextLottie[0]) { 879 nextLottie[0].jumpToInteraction(0); 880 lottieActiveAnimation = true; 881 } 882 if (typeof(prevLottie) != 'undefined' && prevLottie[0]) { 883 prevLottie[0].jumpToInteraction(0); 884 lottieActiveAnimation = true; 885 } 886 }); 887 888 if ($('.piscesslider lottie-player').length) { 889 SlidersController.setPiscesLottieSrc(); 890 var lottieUploaded = false; 891 var observer = new MutationObserver(function(mutationsList, observer) { 892 var lottieElement = $('.piscesslider .swiper-slide lottie-player'); 893 if (!lottieUploaded && lottieElement.length > 0 && lottieElement[0].shadowRoot && lottieElement[0].shadowRoot.childElementCount > 0) { 894 lottieUploaded = true; 895 SlidersController.fixLottieHeight(); 896 } 897 }); 898 var config = { attributes: true, childList: true, subtree: true }; 899 var lottieElement = $('.piscesslider .swiper-slide lottie-player'); 900 if (lottieElement.length > 0) { 901 observer.observe(lottieElement[0], config); 902 } 903 } 904})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.