1(function () { 2 let handleScroll; 3 let adsInitialized = false; 4 5 function getHeaderOffset() { 6 const header = $('.wrap-HEADER'); 7 const nav = $('.wrap-NAV'); 8 9 let offset = 0; 10 if (header.length && header.css('position') === 'fixed') { 11 offset += header.outerHeight(); 12 } 13 if (nav.length && nav.css('position') === 'fixed') { 14 offset += nav.outerHeight(); 15 } 16 17 return offset; 18 } 19 20 function ajustarAlturaUltimoRoba() { 21 const contenidoIzq = $('.CONTENIDO-IZQ'); 22 const columnaDer = $('.CONTENIDO-DER.wrap-SIMPLE'); 23 if (contenidoIzq.length === 0 || columnaDer.length === 0) return; 24 25 const robas = columnaDer.children('div[id^="roba_desktop_"]'); 26 if (robas.length === 0) return; 27 28 const ultimoRoba = robas.last(); 29 const bottomIzq = contenidoIzq.offset().top + contenidoIzq.outerHeight() - 24; 30 const bottomRoba = ultimoRoba.offset().top + ultimoRoba.outerHeight(); 31 32 const espacioExtra = bottomIzq - bottomRoba; 33 34 if (espacioExtra > 0) { 35 const nuevaAltura = ultimoRoba.outerHeight() + espacioExtra; 36 37 ultimoRoba.css({ 38 'max-height': `${nuevaAltura}px`, 39 'height': '100%', 40 }); 41 42 const hijos = ultimoRoba.children('div'); 43 hijos.eq(0).css('height', '100%'); 44 hijos.eq(1).css('height', '100%'); 45 } 46 } 47 48 function iniciarStickyRobas() { 49 if ($(window).width() <= 991) return; 50 if (adsInitialized) return; 51 adsInitialized = true; 52 53 const columnaDer = $('.CONTENIDO-DER.wrap-SIMPLE'); 54 if (columnaDer.length === 0) return; 55 56 const robas = columnaDer.children('div[id^="roba_desktop_"]'); 57 if (robas.length === 0) return; 58 59 handleScroll = function () { 60 const headerOffset = getHeaderOffset(); 61 const ultimoRoba = robas.last(); 62 63 robas.each(function () { 64 const roba = $(this); 65 66 // Detectamos el iframe (si existe) 67 const adIframe = roba.find('div[id^="google_ads_iframe_"]').first(); 68 const adContent = roba.find('div[id^="div-gpt-ad"]').first().length 69 ? roba.find('div[id^="div-gpt-ad"]').first() 70 : roba.children(':not(script)').first(); 71 72 // Para sticky usaremos el iframe si existe, si no, el adContent 73 const target = adIframe.length ? adIframe : adContent; 74 if (!target.length) return; 75 76 const targetHeight = target.outerHeight(); 77 const parentHeight = roba.outerHeight(); 78 79 const robaRect = roba[0].getBoundingClientRect(); 80 const topDistance = robaRect.top; 81 const bottomDistance = robaRect.bottom; 82 const espacioScroll = roba[0].scrollHeight - targetHeight; 83 84 // Si el espacio es muy chico, no aplicar sticky 85 if (espacioScroll < 80) { 86 target.removeClass('fixed_add stick-bottom').css({ 87 position: 'static', 88 top: 'auto', 89 bottom: 'auto', 90 }); 91 return; 92 } 93 94 // Limpiar siempre antes de aplicar 95 target.removeClass('fixed_add stick-bottom').css({ 96 position: 'static', 97 top: 'auto', 98 bottom: 'auto', 99 }); 100 101 const isHeaderFixed = headerOffset > 0; 102 103 if (isHeaderFixed && topDistance <= headerOffset && (bottomDistance - headerOffset) > targetHeight) { 104 target.addClass('fixed_add').css({ 105 position: 'fixed', 106 top: `${headerOffset}px`, 107 }); 108 } else if ((bottomDistance - headerOffset) <= targetHeight) { 109 target.addClass('stick-bottom').css({ 110 position: 'absolute', 111 bottom: '0', 112 }); 113 } 114 }); 115 116 ajustarAlturaUltimoRoba(); 117 }; 118 119 // Esperar a que los ads estén cargados 120 let attempts = 0; 121 const maxAttempts = 10; 122 const intervalTime = 150; 123 124 const interval = setInterval(() => { 125 const ready = robas.toArray().every(roba => 126 $(roba).children(':not(script)').first().outerHeight() > 0 127 ); 128 129 if (ready || attempts >= maxAttempts) { 130 clearInterval(interval); 131 handleScroll(); 132 $(window).on('scroll resize', handleScroll); 133 } 134 attempts++; 135 }, intervalTime); 136 137 setTimeout(() => { 138 clearInterval(interval); 139 handleScroll(); 140 $(window).on('scroll resize', handleScroll); 141 }, maxAttempts * intervalTime); 142 } 143 144 $(document).ready(function () { 145 iniciarStickyRobas(); 146 }); 147 })();
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.