1( function () { 2 'use strict'; 3 4 const settings = window.LEMMSArtsBannerLinks || {}; 5 const linkClass = settings.linkClass || 'banner-link-layer'; 6 const maximumAttempts = 40; 7 const tapThreshold = 10; 8 let attempts = 0; 9 10 function attachBannerLinks() { 11 const links = document.querySelectorAll( 'sr7-module .' + linkClass + '[href]' ); 12 let attached = false; 13 14 links.forEach( function ( link ) { 15 const slider = link.closest( 'sr7-module' ); 16 let touch = null; 17 let touchNavigationTime = 0; 18 19 if ( ! slider ) { 20 return; 21 } 22 23 if ( slider.dataset.lemBannerLinksAttached === 'true' ) { 24 attached = true; 25 return; 26 } 27 28 function getSlideLink( target ) { 29 const slide = target.closest( 'sr7-slide' ); 30 const slideLink = slide?.querySelector( '.' + linkClass + '[href]' ); 31 32 if ( ! slide || ! slider.contains( slide ) || ! slideLink ) { 33 return null; 34 } 35 36 return slideLink; 37 } 38 39 function openSlideLink( slideLink ) { 40 if ( '_blank' === slideLink.target ) { 41 window.open( slideLink.href, '_blank', 'noopener' ); 42 } else { 43 window.location.href = slideLink.href; 44 } 45 } 46 47 slider.addEventListener( 'click', function ( event ) { 48 /* Ignore the synthetic click that may follow touch navigation. */ 49 if ( Date.now() - touchNavigationTime < 750 ) { 50 return; 51 } 52 53 const slideLink = getSlideLink( event.target ); 54 if ( slideLink ) { 55 openSlideLink( slideLink ); 56 } 57 }, true ); 58 59 slider.addEventListener( 'touchstart', function ( event ) { 60 if ( 1 !== event.touches.length ) { 61 touch = null; 62 return; 63 } 64 65 const point = event.touches[0]; 66 touch = { 67 identifier: point.identifier, 68 x: point.clientX, 69 y: point.clientY, 70 moved: false 71 }; 72 }, { capture: true, passive: true } ); 73 74 slider.addEventListener( 'touchmove', function ( event ) { 75 if ( ! touch ) { 76 return; 77 } 78 79 const point = Array.from( event.touches ).find( function ( item ) { 80 return item.identifier === touch.identifier; 81 } ); 82 83 if ( 84 ! point || 85 Math.abs( point.clientX - touch.x ) > tapThreshold || 86 Math.abs( point.clientY - touch.y ) > tapThreshold 87 ) { 88 touch.moved = true; 89 } 90 }, { capture: true, passive: true } ); 91 92 slider.addEventListener( 'touchend', function ( event ) { 93 if ( ! touch ) { 94 return; 95 } 96 97 const point = Array.from( event.changedTouches ).find( function ( item ) { 98 return item.identifier === touch.identifier; 99 } ); 100 const wasTap = point && 101 ! touch.moved && 102 Math.abs( point.clientX - touch.x ) <= tapThreshold && 103 Math.abs( point.clientY - touch.y ) <= tapThreshold; 104 105 touch = null; 106 107 if ( ! wasTap ) { 108 return; 109 } 110 111 const slideLink = getSlideLink( event.target ); 112 if ( slideLink ) { 113 touchNavigationTime = Date.now(); 114 openSlideLink( slideLink ); 115 } 116 }, { capture: true, passive: true } ); 117 118 slider.addEventListener( 'touchcancel', function () { 119 touch = null; 120 }, { capture: true, passive: true } ); 121 122 slider.dataset.lemBannerLinksAttached = 'true'; 123 attached = true; 124 } ); 125 126 settings.attached = attached; 127 128 return attached; 129 } 130 131 function waitForBanner() { 132 if ( attachBannerLinks() || attempts >= maximumAttempts ) { 133 return; 134 } 135 136 attempts++; 137 window.setTimeout( waitForBanner, 250 ); 138 } 139 140 if ( 'complete' === document.readyState ) { 141 waitForBanner(); 142 } else { 143 window.addEventListener( 'load', waitForBanner, { once: true } ); 144 } 145}() );
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.