1var pmSlideshow = {}; 2(function($){ 3 4 pmSlideshow = { 5 6 init: function(){ 7 this.chooseImagesToShow(); 8 this.initSlick(); 9 10 this.eventHandlers(); 11 }, 12 13 chooseImagesToShow: function(){ 14 var mediaQuery = window.matchMedia('(min-width: 768px)'); 15 var isMobile = !mediaQuery.matches; 16 $('.slideshow-container').each(function(i){ 17 var showingCount = 0; 18 $(this).find('.slide-img').each(function (index){ 19 20 var $item = $(this); 21 var src = null; 22 var ds = $item.attr('data-display-setting'); 23 24 //IF LEGACY SHOW THE DESKTOP IMAGE 25 if(ds=="legacy" 26 || !isMobile && ['desktop','desktopmobile'].includes(ds)){ 27 src = $item.attr('data-lazy-desktop'); 28 } 29 //IF MOBILE REQUIRED USE THE OTHER IMG 30 if(isMobile && ['mobile','desktopmobile'].includes(ds) ){ 31 src = $item.attr('data-lazy-mobile'); 32 } 33 34 if(!src){ 35 $item.closest('.slideshow-slide').remove();//SHOW NOTHING 36 }else{ 37 //SET LAZY SRC 38 $item.attr('data-lazy', src); 39 40 //LOAD THE FIRST TWO SLIDES 41 if(showingCount++ < 2){ 42 $item.attr('src', src); 43 } 44 45 } 46 }) 47 // PRE LOAD THE LAST ONE JUST IN CASE THE USER GOES TO THE LEFT 48 var lastSlide = $(this).find('.slide-img').last(); 49 var lastSrc = lastSlide.attr('data-lazy'); 50 lastSlide.attr('src', lastSrc); 51 52 }); 53 }, 54 55 initSlick: function(){ 56 //make slider height static if inventory page - #40566, static for brown completely 57 var heightBoolean = true; 58 if (window.location.href.search("/inventory/") > 0 || window.location.href.search("brownmotorworks") > 0) { 59 heightBoolean = false; 60 } 61 //per-site autoplay interval overrides, in ms. default is undefined (slick default, 3000ms) 62 var autoplaySpeedBySiteToken = { 63 'lakeshoreseaford': 8000, 64 'victorvilledelamomotorsports': 15000, 65 'vistadelamomotorsports': 15000, 66 }; 67 68 $('.slideshow-container').not('.slick-initialized').slick({ 69 dots: true, 70 autoplay: true, 71 infinite: true, 72 speed: 700, 73 slidesToShow: 1, 74 slidesToScroll: 1, 75 adaptiveHeight: heightBoolean, 76 lazyLoad: 'on-demand', 77 autoplaySpeed: autoplaySpeedBySiteToken[window.pm_api?.site_token], 78 }); 79 80 //manually turning data-lazy into src for cloned slides images. Slick Slider Bug, infinite not working on slidesToShow:1 81 $('.slideshow-container').on('beforeChange', function(event, slick, currentSlide, nextSlide) { 82 if (nextSlide == 0) {//this fires when a new loop is about to start 83 $('.slideshow-container img[data-lazy]').each(function(index) { 84 let $item = $(this); 85 $item.attr('src', $item.attr('data-lazy')); 86 }) 87 } 88 }); 89 90 //force to load next slide, to prevent white loading slide 91 $('.slideshow-container').on('afterChange', function(event, slick, currentSlide) { 92 $nextSlide = $($(this).find('div[data-slick-index='+(currentSlide+1) +'] img[data-lazy]')); 93 if($nextSlide){ 94 $nextSlide.attr('src', $nextSlide.attr('data-lazy')); 95 } 96 $nextSlide2 = $($(this).find('div[data-slick-index='+(currentSlide+2) +'] img[data-lazy]')); 97 if($nextSlide2){ 98 $nextSlide2.attr('src', $nextSlide2.attr('data-lazy')); 99 } 100 //LOADING PREV SLIDE IF USER GOES TO THE LEFT 101 $prevSlide = $($(this).find('div[data-slick-index='+(currentSlide-1) +'] img[data-lazy]')); 102 if($prevSlide){ 103 $prevSlide.attr('src', $prevSlide.attr('data-lazy')); 104 } 105 106 }); 107 }, 108 109 eventHandlers: function(){ 110 jQuery(document).ready(function() { 111 112 // pmSlideshow.initSlick(); 113 114 }); 115 116 //Force Load Slide 2 so it would load as a 1px height slide. Occurs when adaptiveHeight is on 117 // $('.slideshow-container').on('init', function(event, slick) { 118 // $secondSlide = $($('.slideshow-container div[data-slick-index="1"] img[data-lazy]')); 119 // if($secondSlide){ 120 // $secondSlide.attr('src', $secondSlide.attr('data-lazy')); 121 // } 122 // var finalIndex = slick.slideCount-1; 123 // $finalSlide = $($('.slideshow-container div[data-slick-index="'+finalIndex+'"] img[data-lazy]')); 124 // if($finalSlide){
125 // $finalSlide.attr('src', $finalSlide.attr('data-lazy')); 126 // } 127 // }); 128 } 129 } 130 $('.slideshow-container').css('display', 'block'); 131 pmSlideshow.init(); 132 133})(jQuery); 134 135 136 137 138
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.