top of page

Éléments essentiels

Vegdog Birthday cookies

5,99 €Prix
TVA Incluse |
Quantité

    Sit Happens Coaching - Tous droits réservés

    bottom of page
    function syncTiles(){ $grid.querySelectorAll('.pc-item').forEach(el=>{ const name = el.getAttribute('data-name'); const active = (selectionMode==='single') ? (selected[0]===name) : selected.includes(name); el.setAttribute('aria-pressed', active); el.classList.toggle('is-selected', active); updateBadge(el, name); }); } function updateBadge(el, name){ // Nettoie el.querySelectorAll('.pc-badge').forEach(b=>b.remove()); if(selectionMode==='double'){ const idx = selected.indexOf(name); if(idx>-1){ const b = document.createElement('div'); b.className='pc-badge'; b.textContent = idx===0? 'A' : 'B'; el.appendChild(b); } } } function updateSummary(){ if(selected.length===0){ $summary.textContent = 'Aucune sélection'; return; } if(selectionMode==='single'){ $summary.textContent = `Sélection: ${selected[0]}`; } else { const [a,b] = selected; $summary.textContent = `Couleurs: ${a || '—'} ${b? ' + '+b : ''}`; } } function syncHiddenFields(){ // Injection facultative dans des champs existants de formulaire try{ if(selectionMode==='single' && CONFIG.formFieldSingleId){ const i = document.getElementById(CONFIG.formFieldSingleId); if(i) i.value = selected[0] || ''; } if(selectionMode==='double'){ if(CONFIG.formFieldDoubleIdA){ const ia = document.getElementById(CONFIG.formFieldDoubleIdA); if(ia) ia.value = selected[0] || ''; } if(CONFIG.formFieldDoubleIdB){ const ib = document.getElementById(CONFIG.formFieldDoubleIdB); if(ib) ib.value = selected[1] || ''; } } }catch(err){ /* silencieux */ } } // Toolbar (changer le mode à la volée) $root.querySelectorAll('.pc-chip').forEach(btn=>{ btn.addEventListener('click', ()=>{ selectionMode = btn.getAttribute('data-mode'); selected = []; $root.querySelectorAll('.pc-chip').forEach(b=>b.setAttribute('aria-pressed','false')); btn.setAttribute('aria-pressed','true'); $grid.setAttribute('role', selectionMode==='single'?'radiogroup':'group'); renderGrid(); }) }); // Actions $copy.addEventListener('click', async ()=>{ const text = (selectionMode==='single') ? (selected[0] || '') : selected.join(' / '); try{ await navigator.clipboard.writeText(text); $copy.textContent = 'Copié !'; setTimeout(()=>{$copy.textContent='Copier la sélection'},1200); }catch(err){ alert(text); } }); $clear.addEventListener('click', ()=>{ selected=[]; syncTiles(); updateSummary(); syncHiddenFields(); }); // Premier rendu renderGrid(); })();