| Priority: 10 | Apply to: Entire Site ═══════════════════════════════════════════════════════════════ */ (function() { 'use strict'; // Hantera HTML inuti rubriker (t.ex. ) — bevara taggar, wrap:a ord function wrapWordsPreservingTags(el) { if (el.dataset.aitWrapped === 'true') return; const html = el.innerHTML; const tokens = html.match(/(<[^>]+>|[^<\s]+|\s+)/g) || []; let wordIndex = 0; el.innerHTML = tokens.map(function(t) { if (t.charAt(0) === '<' || /^\s+$/.test(t)) return t; const delay = (wordIndex * 0.06).toFixed(2); wordIndex++; return '' + t + ''; }).join(''); el.dataset.aitWrapped = 'true'; } function init() { // ── 1. WORD REVEAL ── const targets = document.querySelectorAll('.reveal-words'); if (targets.length) { targets.forEach(wrapWordsPreservingTags); if ('IntersectionObserver' in window) { const observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { entry.target.classList.add('revealed'); observer.unobserve(entry.target); } }); }, { threshold: 0.35, rootMargin: '0px 0px -80px 0px' }); targets.forEach(function(el) { observer.observe(el); }); } else { targets.forEach(function(el) { el.classList.add('revealed'); }); } } // ── 2. AUTO-APPLICERA .hero-trust-card PÅ RÄTT CONTAINER ── // Robust logik: rensa felaktig användning först, hitta sen den minsta // containern som har alla tre trust-värden men INTE har en h1 inuti const hero = document.querySelector('.ait-hero-mesh'); if (hero) { document.querySelectorAll('.hero-trust-card').forEach(function(el) { el.classList.remove('hero-trust-card'); }); const allContainers = hero.querySelectorAll('[data-element_type="container"]'); const matches = []; for (let i = 0; i < allContainers.length; i++) { const c = allContainers[i]; const t = c.textContent || ''; if (t.indexOf('24/7') > -1 && t.indexOf('100+') > -1 && t.indexOf('25+') > -1 && !c.querySelector('h1')) { matches.push(c); } } if (matches.length > 0) { let smallest = matches[0]; let smallestCount = smallest.querySelectorAll('*').length; for (let i = 1; i < matches.length; i++) { const count = matches[i].querySelectorAll('*').length; if (count < smallestCount) { smallest = matches[i]; smallestCount = count; } } smallest.classList.add('hero-trust-card'); } } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();