'; menu.appendChild(drawer); } var wrap=qs('.cn-mobile-drawer-gcr', drawer); if(!wrap){ wrap=document.createElement('div'); wrap.className='cn-mobile-drawer-gcr'; wrap.innerHTML='
Avis Google
'; drawer.appendChild(wrap); } return qs('#cn-mobile-gcr-slot')||qs('.cn-mobile-drawer-gcr__slot', wrap); } function placeGcr(){ if(!isMobile())return; var slot=ensureGcrSlot(); if(!slot)return; var badge=qs('.cn-gcr-badge'); if(!badge)return; if(badge.parentNode!==slot)slot.appendChild(badge); badge.classList.add('cn-gcr-in-drawer'); }function fixImg(img){ try{ if(img.classList && (img.classList.contains('cn-hero-bg') || img.classList.contains('cn-hero-lcp-img'))) return; if(img.getAttribute('data-cn-mm-lazy')==='1' && !img.getAttribute('src')) return; if(!img.hasAttribute('alt')) img.setAttribute('alt',''); if(img.classList && img.classList.contains('cn-hero-lcp-img')) return; img.loading = img.loading || 'lazy'; var ds=img.getAttribute('data-src')||img.getAttribute('data-lazy')||img.getAttribute('data-original'); if(ds && (!img.src || img.src.indexOf('data:image')===0 || img.naturalWidth===0)) img.src=ds; }catch(e){} }function a11yFix(){ qsa('a.close-cart').forEach(function(a){ a.setAttribute('href','#'); a.setAttribute('role','button'); if(!a.getAttribute('aria-label')) a.setAttribute('aria-label','Fermer le panier'); }); qsa('button.pos-search__submit').forEach(function(b){ b.setAttribute('aria-label','Rechercher'); }); qsa('a.account-login').forEach(function(a){ var sp=a.querySelector('span'); var logged=sp && /account|compte/i.test(sp.textContent||''); a.setAttribute('aria-label', logged ? 'Mon compte' : 'Connexion'); }); qsa('a.rt-banner-link').forEach(function(a){ var img=a.querySelector('img'); var label=a.getAttribute('aria-label')||''; if(!label){ try{ var slug=decodeURIComponent((a.pathname||'').split('/').pop().replace(/\.html$/,'').replace(/^[0-9]+[-_]?/,'').replace(/[-_]/g,' ')).trim(); label=slug||'Bannière'; }catch(e){ label='Bannière'; } a.setAttribute('aria-label', label); } if(img){ var alt=(img.getAttribute('alt')||'').trim(); if(!alt) img.setAttribute('alt', label); img.setAttribute('aria-hidden','true'); } }); qsa('.category-item .category-image a').forEach(function(a){ var item=a.closest('.category-item'); var nameEl=item && item.querySelector('.category-content .name, .category-content a.name'); var label=(nameEl && (nameEl.textContent||'').trim()) || ''; if(!label){ try{ label=decodeURIComponent((a.pathname||'').split('/').pop().replace(/\.html$/,'').replace(/^[0-9]+[-_]?/,'').replace(/[-_]/g,' ')).trim(); }catch(e){ label='Catégorie'; } } if(!label) label='Catégorie'; a.setAttribute('aria-label', label); var img=a.querySelector('img'); if(img){ if(!(img.getAttribute('alt')||'').trim()) img.setAttribute('alt', label); img.setAttribute('aria-hidden','true'); } }); qsa('.cn-instagram-section a[href*="instagram.com"], .slick-slide-inner > a[href*="instagram.com"], figure.slick-slide-inner > a').forEach(function(a){ var href=a.getAttribute('href')||''; if(href.indexOf('instagram.com')<0 && !a.closest('.cn-instagram-section')) return; if(!a.getAttribute('aria-label')) a.setAttribute('aria-label','Voir sur Instagram — Comptoir Nourisson'); var img=a.querySelector('img'); if(img && !(img.getAttribute('alt')||'').trim()){ img.setAttribute('alt','Comptoir Nourisson sur Instagram'); } }); qsa('iframe[src*="google.com"], iframe[src*="gstatic.com"], #__ratingbadge_0 iframe, div[id^="__ratingbadge"] iframe').forEach(function(f){ if(!f.getAttribute('title')) f.setAttribute('title','Avis clients Google'); }); qsa('.manufacturer a, a[href*="/fr/_"], a[href$="/_"]').forEach(function(a){ var href=a.getAttribute('href')||''; var txt=(a.textContent||'').trim(); if(/\/_$/.test(href.replace(/\/$/,'')) || href.indexOf('/fr/_')>=0 || !txt){ var wrap=a.closest('.manufacturer'); if(wrap){ try{ wrap.parentNode && wrap.parentNode.removeChild(wrap); }catch(e){ wrap.style.display='none'; } } else { try{ a.parentNode && a.parentNode.removeChild(a); }catch(e){ a.style.display='none'; } } } }); qsa('.slick-slide').forEach(function(slide){ var hidden = slide.getAttribute('aria-hidden')==='true' || (!slide.classList.contains('slick-active') && !slide.classList.contains('slick-current')); if(hidden){ slide.setAttribute('inert',''); slide.setAttribute('tabindex','-1'); qsa('a, button, input, select, textarea, [tabindex]', slide).forEach(function(el){ if(el.tagName==='A'){ var href=el.getAttribute('href'); if(href!==null && href!==''){ if(!el.hasAttribute('data-cn-href')) el.setAttribute('data-cn-href', href); el.removeAttribute('href'); } el.setAttribute('data-cn-slick-off','1'); } if(el.tagName==='BUTTON') el.setAttribute('disabled','disabled'); el.setAttribute('tabindex','-1'); }); } else { slide.removeAttribute('inert'); if(slide.getAttribute('tabindex')==='-1') slide.removeAttribute('tabindex'); qsa('a[data-cn-href], button[disabled], [data-cn-slick-off]', slide).forEach(function(el){ if(el.hasAttribute('data-cn-href')){ el.setAttribute('href', el.getAttribute('data-cn-href')); el.removeAttribute('data-cn-href'); } el.removeAttribute('data-cn-slick-off'); if(el.tagName==='BUTTON') el.removeAttribute('disabled'); el.removeAttribute('tabindex'); }); } }); qsa('a[href=""], a:not([href])').forEach(function(a){ if(a.getAttribute('data-cn-slick-off')==='1' || a.hasAttribute('data-cn-href')) return; if(a.closest && a.closest('.slick-slide[aria-hidden="true"], .slick-slide[inert]')) return; var txt=(a.textContent||'').trim(); var hasImg=!!a.querySelector('img'); if(txt || hasImg){ if(!a.getAttribute('href')) a.setAttribute('href','#'); if(!txt && hasImg && !a.getAttribute('aria-label')) a.setAttribute('aria-label','Lien'); return; } var li=a.closest('li.submenu-item'); var child=li && li.querySelector('.category-sub-menu a[href^="http"], .category-sub-menu a[href^="/"]'); if(child && child.getAttribute('href')){ a.setAttribute('href', child.getAttribute('href')); a.textContent=(child.textContent||'').trim() || 'Voir la catégorie'; if(!(a.textContent||'').trim()) a.setAttribute('aria-label','Voir la catégorie'); return; } if(li && !(li.textContent||'').trim().replace(/add|remove/g,'').trim()){ try{ li.parentNode && li.parentNode.removeChild(li); }catch(e){ li.style.display='none'; } } else { try{ a.parentNode && a.parentNode.removeChild(a); }catch(e){ a.style.display='none'; a.setAttribute('aria-hidden','true'); } } }); }function unlock(){ document.documentElement.style.overflow=''; document.body.style.overflow=''; }function isOpen(){ var icon=qs('#menu-icon'); return !!(icon&&icon.classList.contains('open-menu')); } function openMenu(){ var icon=qs('#menu-icon'); var menu=qs('#mobile_menu_wrapper'); if(!icon||!menu)return; icon.classList.add('open-menu'); menu.classList.add('box-menu'); document.body.style.overflow='hidden'; wakeMegamenuImgs(); placeGcr(); } function closeMenu(){ var icon=qs('#menu-icon'); var menu=qs('#mobile_menu_wrapper'); if(icon) icon.classList.remove('open-menu'); if(menu) menu.classList.remove('box-menu'); document.body.style.overflow=''; } function onMenuTap(e){ if(e){ e.preventDefault(); e.stopPropagation(); if(e.stopImmediatePropagation)e.stopImmediatePropagation(); } if(isOpen()) closeMenu(); else openMenu(); return false; } function bindMenu(){ var icon=qs('#menu-icon'); if(!icon||icon.__cnMenu5)return; icon.__cnMenu5=1; ['click','touchend'].forEach(function(type){ icon.addEventListener(type, onMenuTap, true); }); var closer=qs('#mobile_menu_wrapper .menu-close'); if(closer&&!closer.__cnMenu5){ closer.__cnMenu5=1; closer.addEventListener('click', function(e){e.preventDefault();e.stopImmediatePropagation();closeMenu();}, true); } }function swapBrandLogos(){ qsa('.cn-brand-carousel-img, .cn-brands-section img[src*="/img/m/"]').forEach(function(img){ var src=img.getAttribute('src')||''; var m=src.match(/\/img\/m\/(\d+)\.(?:jpe?g|png|webp)(?:\?.*)?$/i); if(!m || src.indexOf('-c.webp')>=0) return; img.setAttribute('src', '/img/m/'+m[1]+'-c.webp'); }); }function softFixSlick(){ if(!window.jQuery) return; var $=window.jQuery; var $s=$('.cn-hero-slide .pos-slideshow').first(); if(!$s.length) $s=$('.pos-slideshow').first(); if(!$s.length) return; $s.find('.slick-slide').each(function(){ var hidden=this.getAttribute('aria-hidden')==='true' || !this.classList.contains('slick-active'); if(hidden && !this.classList.contains('slick-current')){ this.style.removeProperty('opacity'); this.style.removeProperty('visibility'); return; } this.style.setProperty('opacity','1','important'); this.style.setProperty('visibility','visible','important'); }); restoreHeroBgs(true); if(!$s.data('cnA11yBound')){ $s.data('cnA11yBound',1); $s.on('afterChange init reInit', function(){ a11yFix(); softFixSlick(); }); } }function showBackTop(){ var root=document.body||document.documentElement; if(!root) return; qsa('.back-top:not(#cn-back-top), #cn-back-top-static').forEach(function(el){ el.style.setProperty('display','none','important'); el.style.setProperty('visibility','hidden','important'); el.style.setProperty('pointer-events','none','important'); }); var el=document.getElementById('cn-back-top'); if(!el){ el=document.createElement('div'); el.id='cn-back-top'; el.className='back-top cn-backtop-on'; el.innerHTML='
'+ ''+ ' '; root.appendChild(el); el.addEventListener('click',function(e){ e.preventDefault();e.stopPropagation(); try{window.scrollTo({top:0,behavior:'smooth'});}catch(err){ document.documentElement.scrollTop=0;document.body.scrollTop=0; } },true); } else if(el.parentNode!==root){ root.appendChild(el); } var y=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0; var show=y>120; el.className='back-top cn-backtop-on'+(show?' cn-visible':''); el.setAttribute('style', (show ?'display:block!important;opacity:1!important;visibility:visible!important;pointer-events:auto!important;' :'display:none!important;opacity:0!important;visibility:hidden!important;pointer-events:none!important;')+ 'position:fixed!important;right:18px!important;bottom:24px!important;left:auto!important;'+ 'z-index:2147483646!important;margin:0!important;width:48px!important;height:48px!important;' ); var btn=el.querySelector('.back-top-button'); if(btn){ btn.setAttribute('style', 'display:flex!important;align-items:center!important;justify-content:center!important;'+ 'width:48px!important;height:48px!important;border-radius:50%!important;'+ 'background:#B49C7B!important;color:#fff!important;text-decoration:none!important;'+ 'border:2px solid #fff!important;box-shadow:0 8px 22px rgba(0,0,0,.3)!important;'+ 'position:relative!important;cursor:pointer!important;' ); if(!btn.querySelector('.cn-bt-svg')){ btn.innerHTML=''+ ''; } } }function boot(){ stripRalewaySafe(); killNewsletter(); unlock(); bindMenu(); restoreHeroBgs(false); lazyMegamenu(); swapBrandLogos(); softFixSlick(); a11yFix(); showBackTop(); placeGcr(); qsa('img').forEach(fixImg); } function stripRalewaySafe(){ qsa('link[href*="fonts.googleapis.com"]').forEach(function(l){ var h=(l.getAttribute('href')||''); if(/Raleway/i.test(h) && !/Open\+Sans/i.test(h)){ try{ l.parentNode && l.parentNode.removeChild(l); }catch(e){} } }); }showBackTop(); if(document.readyState==='loading') document.addEventListener('DOMContentLoaded', boot); else boot(); setTimeout(boot,200); setTimeout(showBackTop,500); setTimeout(function(){ restoreHeroBgs(false); lazyMegamenu(); },800); setTimeout(showBackTop,1500); window.addEventListener('scroll', showBackTop, {passive:true}); window.addEventListener('load', function(){ boot(); showBackTop(); a11yFix(); }); setInterval(function(){ showBackTop(); }, 600); try{ var mo=new MutationObserver(function(){ a11yFix(); stripRalewaySafe(); }); mo.observe(document.documentElement,{childList:true,subtree:true}); setTimeout(function(){ try{mo.disconnect();}catch(e){} }, 15000); }catch(e){} })();
J'ai compris !