Catégorie : Non classé

Tous les articles

Il semble que nous ne trouvions pas ce que vous cherchez.
Retour en haut
(() => { 'use strict'; let scheduled = 0; const prefetched = new Set(); const overlapsHeader = (header) => { const nav = header.querySelector('.inrcy-nav'); const actions = header.querySelector('.inrcy-header-actions'); const links = nav ? Array.from(nav.querySelectorAll('.inrcy-nav-link')) : []; const last = links.at(-1); if (!nav || !actions || !last || getComputedStyle(actions).display === 'none') { return false; } const navRect = nav.getBoundingClientRect(); const actionsRect = actions.getBoundingClientRect(); const lastRect = last.getBoundingClientRect(); return nav.scrollWidth > nav.clientWidth + 1 || lastRect.right > actionsRect.left - 8 || navRect.right > actionsRect.left - 8; }; const balanceHeader = () => { const header = document.querySelector('#inrcyResponsiveHeader, .inrcy-header'); if (!header) { return; } header.classList.remove('inrcy-header--compact', 'inrcy-header--tight'); if (!overlapsHeader(header)) { return; } header.classList.add('inrcy-header--compact'); if (overlapsHeader(header)) { header.classList.add('inrcy-header--tight'); } }; const fitHeroLines = () => { const canvas = fitHeroLines.canvas || (fitHeroLines.canvas = document.createElement('canvas')); const context = canvas.getContext('2d'); if (!context) { return; } document.querySelectorAll('.hs-title-line').forEach((line) => { const initial = getComputedStyle(line); const base = Number(line.dataset.inrcyBaseFontSize || parseFloat(initial.fontSize)); if (!Number.isFinite(base) || base <= 0) { return; } line.dataset.inrcyBaseFontSize = String(base); line.style.fontSize = base + 'px'; const style = getComputedStyle(line); const text = line.textContent.trim(); const available = line.clientWidth - 4; if (!text || available <= 20) { return; } context.font = [ style.fontStyle, style.fontVariant, style.fontWeight, base + 'px', style.fontFamily ].join(' '); const letterSpacing = parseFloat(style.letterSpacing) || 0; const measured = context.measureText(text).width + Math.max(0, text.length - 1) * letterSpacing; if (measured > available) { const fitted = Math.max(24, base * available / measured * 0.97); line.style.fontSize = fitted.toFixed(2) + 'px'; } }); }; const run = () => { balanceHeader(); fitHeroLines(); }; const schedule = () => { cancelAnimationFrame(scheduled); scheduled = requestAnimationFrame(run); }; const prefetchLanguage = (target) => { const link = target.closest && target.closest('.trp-switcher-dropdown-list a[href]'); if (!link) { return; } const url = new URL(link.href, location.href); if (url.origin !== location.origin || url.href === location.href || prefetched.has(url.href)) { return; } prefetched.add(url.href); const hint = document.createElement('link'); hint.rel = 'prefetch'; hint.as = 'document'; hint.href = url.href; document.head.appendChild(hint); }; const init = () => { run(); window.addEventListener('resize', schedule, { passive: true }); document.addEventListener('pointerover', (event) => prefetchLanguage(event.target), { passive: true }); document.addEventListener('focusin', (event) => prefetchLanguage(event.target)); document.addEventListener('touchstart', (event) => prefetchLanguage(event.target), { passive: true }); if (document.fonts && document.fonts.ready) { document.fonts.ready.then(schedule); } if ('ResizeObserver' in window) { const header = document.querySelector('#inrcyResponsiveHeader, .inrcy-header'); const hero = document.querySelector('.hs-title'); const observer = new ResizeObserver(schedule); if (header) observer.observe(header); if (hero) observer.observe(hero); } }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init, { once: true }); } else { init(); } })();