1( function ($) { 2 3 $(document).ready(function () { 4 doSlideshow(); 5 }); 6 7 function lazySlide(array, index) { 8 var sources = $(array[index]).find('source'); 9 var img = $(array[index]).find('img'); 10 var src = img.attr('data-src'); 11 12 sources.each(function () { 13 var source = $(this).attr('data-srcset'); 14 $(this).attr('srcset', source); 15 $(this).attr('data-processed', 'true'); 16 $(this).removeAttr('data-srcset'); 17 18 }); 19 img.attr('src', src); 20 img.attr('data-processed', 'true'); 21 img.removeAttr('data-src'); 22 } 23 24 function doSlideshow() { 25 var wrap = $('#slideshow-1 .slideshow'); 26 if (wrap.length > 0) { 27 28 //LAZY LOADING (before carousel is loaded) 29 wrap.on("init", function () { 30 31 //load 1st, 2nd and last slide 32 var slides = wrap.find('.slide'); 33 if(slides.length <= 1){ 34 dots = false 35 } 36 var slidesLoaded = [slides[0], slides[1], slides[ss_lenght - 1]]; 37 38 //items index change based on animation kind (0 to n-1 for fade, 1 to n for slide) 39 if (animation === false) { 40 slidesLoaded = [slides[1], slides[2], slides[ss_lenght]]; 41 } 42 slides.each(function (index) { 43 lazySlide(slidesLoaded, index); 44 }) 45 }); 46 47 var motion = window.matchMedia("(prefers-reduced-motion: reduce)"); 48 autoplay = motion.matches ? false : autoplay; 49 console.log('autoplay', autoplay); 50 //slideshow setup 51 wrap.slick({ 52 rows: 0, 53 rtl: rtl, 54 fade: animation, 55 pauseOnHover: false, 56 pauseOnFocus: false, 57 autoplay: autoplay, 58 arrows: arrows, 59 dots: dots, 60 infinite: true, 61 autoplaySpeed: autoplaySpeed, 62 speed: animationSpeed, 63 nextArrow: wrap.parent().find('.next'), 64 prevArrow: wrap.parent().find('.prev'), 65 appendDots: wrap.parent().find('.pager') 66 }); 67 } 68 69 //LAZY LOADING (after carousel is loaded) 70 71 //load 1st, 2nd and last clone 72 var clones = wrap.find('.slick-cloned'); 73 var clonesLoaded = [clones[0], clones[1], clones[ss_lenght - 1]]; 74 75 //items index change based on animation kind (0 to n-1 for fade, -1 to n-2 for slide) 76 if (animation === false) { 77 clonesLoaded = [clones[0], clones[1], clones[2]]; 78 } 79 clones.each(function (index) { 80 lazySlide(clonesLoaded, index); 81 }); 82 83 wrap.on("afterChange", function (e, slick) { 84 var slides = $.merge(slick.$slides, clones); 85 86 //load next slide + 1 87 var index = slick.currentSlide + 1; 88 89 lazySlide(slides, index); 90 91 //load previous slide - 1 92 if (slick.currentSlide === 0) { 93 index = ss_lenght - 1; 94 } else { 95 index = slick.currentSlide - 1; 96 } 97 lazySlide(slides, index); 98 99 //load current slide if click on pager 100 var indexCurrent = slick.currentSlide; 101 102 lazySlide(slides, indexCurrent); 103 }); 104 } 105 106 107}(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.