1 2jQuery(async function ($) { 3 window['SMcontroller'] = window['SMcontroller'] ? window['SMcontroller'] : new ScrollMagic.Controller({}); 4 window['SMscenes'] = window['SMscenes'] ? window['SMscenes'] : []; 5 window['SMscenes'].push(init); 6 7 8 await init(); 9 async function init() { 10 if($("html").is('[dir="rtl"]')){ 11 $rtl = true; 12 }else{ 13 $rtl = false; 14 } 15 16 const ImgToSvg= async (img) => { 17 const s = document.createElement('div'); 18 if (img.src) { 19 s.innerHTML = (await (await fetch(img.src)).text())//.replace(/fill=".*?"/g, 'fill="transparent"'); 20 s.classList = img.classList; 21 img.replaceWith(s) 22 setTimeout(function() {jQuery(s).css('display', 'block')}); 23 } 24 } 25 26 var heroes = $(".random-hero-slider"); 27 for (var hIndex = 0; hIndex < heroes.length; hIndex++) { 28 if (window['random-hero-slider'] && window['random-hero-slider'][hIndex]) { 29 $(heroes[hIndex]).html(window['random-hero-slider'][hIndex]); 30 $(heroes[hIndex]).css('transform', 'none'); 31 } else { 32 const svgImg = $(heroes[hIndex]).find('.random-hero-cover')[0]; 33 await ImgToSvg(svgImg); 34 if (!window['random-hero-slider']) 35 window['random-hero-slider'] = []; 36 window['random-hero-slider'][hIndex] = $(heroes[hIndex]).html(); 37 } 38 } 39 40 let blocked = false; 41 let blockTimeout = null; 42 let prevDeltaY = 0; 43 let cantScroll = false; 44 45 const contentHolder = $('.random-hero-content-holder'); 46 const images = $('.random-hero-images'); 47 images.each(function() { 48 if (isMobile()) { 49 if (!$(this).hasClass('mobile')){ 50 $(this).remove(); 51 $button = $('.random-hero-slider .wp-block-buttons').eq(0); 52 $button.appendTo($('.random-hero-slider')) 53 } 54 } else { 55 if ($(this).hasClass('mobile')) 56 $(this).remove(); 57 } 58 }); 59 $('.random-hero-images figcaption').each( function() { 60 $(this).html($(this).html().replace('@', '<br />')); 61 }) 62 const imageHolder = $('.random-hero-images'); 63 64 const colors = []; 65 const items = $(heroes[0]).find('.slider-random-item'); 66 for (var i = 0; i < items.length; i++) { 67 colors.push($(items[i]).attr('data-color')); 68 } 69 const imgLength = imageHolder.find('> .wp-block-image').length; 70 const itemLength = items.length; 71 72 for (var i = 0; i < imgLength - itemLength; i++) { 73 const newImgLength = imageHolder.find('> .wp-block-image').length; 74 const indRemove = Math.floor(Math.random() * newImgLength); 75 $(imageHolder.find('> .wp-block-image')[indRemove]).remove(); 76 } 77 imageHolder.find('> .wp-block-image img').show(); 78 79 80 81 const imagesLength = imageHolder.find('> .wp-block-image').length; 82 83 let prevIndexContent = 0; 84 let curIndexContent = 1; 85 86 let prevIndexImage = 0; 87 let curIndexImage = 1; 88 89 for (var hIndex = 0; hIndex < heroes.length; hIndex++) { 90 const svgImg = $(heroes[hIndex]).find('.random-hero-cover')[0]; 91 await ImgToSvg(svgImg); 92 } 93 94 const heroCover = $('.random-hero-cover'); 95 const svgPath = $('.random-hero-cover').find('path'); 96 heroCover.attr('data-active-slide', 0); 97 svgPath.css('fill', colors[0]); 98 99 let opts = { 100 fade: true, 101 infinite:false, 102 speed: 1000, 103 rtl: $rtl 104 }; 105 if (isMobile()) { 106 opts.autoplay = false; 107 opts.autoplaySpeed = 3000; 108 opts.verticalSwiping = true; 109 opts.vertical = true; 110 opts.fade = false; 111 opts.infinite = false; 112 } 113 try{ 114 contentHolder.slick('unslick'); 115 } catch(e){}; 116 contentHolder.slick(opts); 117 118 try{ 119 imageHolder.slick('unslick'); 120 } catch(e){}; 121 122 imageHolder.slick({ 123 fade: true, 124 infinite:false, 125 swipe: true, 126 speed: 1000, 127 rtl: $rtl, 128 //slidesToScroll: -1, 129 //initialSlide: initialSlide, 130 }); 131 132 if (!isMobile()) { 133 contentHolder.on('mousewheel DOMMouseScroll wheel', (function(e) { 134 let deltaY = e.originalEvent.deltaY; 135 if (!cantScroll && deltaY > 0 && jQuery('.random-hero-content-holder .slick-track > div').last().hasClass('slick-active')) { 136 setTimeout(function() {cantScroll = true;}, 500); 137 } 138 if(!cantScroll){ 139 e.preventDefault(); 140 e.stopPropagation(); 141 142 if (blocked || deltaY*deltaY < 100) 143 return; 144 145 if ((deltaY > 0 && deltaY > prevDeltaY) || (deltaY < 0 && deltaY < prevDeltaY) || !blocked) { 146 blocked = true; 147 prevDeltaY = deltaY; 148 blockTimeout = setTimeout(function(){ 149 blocked = false; 150 }, 500); 151 if (deltaY > 0) { 152 $(this).slick('slickNext'); 153 } else { 154 $(this).slick('slickPrev'); 155 } 156 } 157 } 158 159 })); 160 } 161 contentHolder.on("afterChange", function (event, slick, currentSlide) { 162 163 if (slick.$slides.length - 1 == currentSlide) { 164 cantScroll = true; 165 }else{ 166 cantScroll = false; 167 } 168 if(cantScroll){ 169 $('body').addClass('canScroll'); 170 }else{ 171 $('body').removeClass('canScroll'); 172 } 173 174 }); 175 176 contentHolder.on('beforeChange', function(event, slick, curI, nextI) { 177 contentData = randomUniqueNum(prevIndexContent, curIndexContent, 5); 178 179 180 prevIndexContent = contentData[0]; 181 curIndexContent = contentData[1]; 182 183 const heroCover = $(this).parents('.random-hero-slider').find('.random-hero-cover'); 184 const svgPath = $(this).parents('.random-hero-slider').find('.random-hero-cover').find('path'); 185 heroCover.attr('data-active-slide', nextI); 186 svgPath.css('fill', colors[nextI]); 187 imageHolder.slick('slickGoTo', nextI); 188 // $(this).find('.slider-random-item').removeClass('shown') 189 // $(this).find('.slider-random-item').eq(curI).addClass('shown'); 190 191 }); 192 193 $(window).bind('mousewheel', function(event) { 194 if (event.originalEvent.wheelDelta >= 0 && $(window).scrollTop() == 0) { 195 cantScroll = false; 196 } 197 }); 198 199 $(window).scroll(function() { 200 var scrollTop = $(window).scrollTop(); 201 var Element = $('.random-hero-slider + .section'); 202 var elementOffset = Element.offset().top; 203 204 if($(window).width() >= 767){ 205 if(scrollTop <= elementOffset){ 206 $('.random-hero-slider').css('transform', 'translateY(' + scrollTop/1.22 + 'px)'); 207 } 208 } 209 if(scrollTop == 0){ 210 $('body').removeClass('canScroll'); 211 } 212 213 }) 214 } 215 function randomUniqueNum(prevIndex, curIndex, count) { 216 nextIndex = Math.floor(Math.random() * count); 217 if(nextIndex != curIndex && nextIndex != prevIndex){ 218 prevIndex = curIndex; 219 result = [prevIndex, nextIndex]; 220 }else{ 221 return randomUniqueNum(prevIndex, curIndex, count); 222 } 223 return result; 224 } 225}); 226 227
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.