'); win.document.close(); win.focus(); setTimeout(function(){ win.print(); }, 500); },copyListLink: function(listId) { fetch(MLW.ajax, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: 'action=mlw_get_share_url&nonce='+MLW.nonce+'&list_id='+listId }).then(function(r){ return r.json(); }).then(function(res){ if (!res.success) { MLW.showToast('Eroare generare link'); return; } var url = res.data.url; if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(url).then(function(){ MLW.showToast('✓ Link copiat în clipboard!'); }); } else { var tmp = document.createElement('textarea'); tmp.value = url; tmp.style.position = 'fixed'; tmp.style.opacity = '0'; document.body.appendChild(tmp); tmp.select(); document.execCommand('copy'); document.body.removeChild(tmp); MLW.showToast('✓ Link copiat în clipboard!'); } }); },sendEmail: function() { var email = document.getElementById('wlEmailInput').value; var status = document.getElementById('wlEmailStatus'); if (!email) return; document.getElementById('wlEmailSend').textContent = 'Se trimite...'; MLW.fetch('mlw_send_email', {list_id: MLW.currentListId, email: email}, function(res) { status.style.display = 'block'; if (res.success) { status.textContent = '✓ Email trimis cu succes!'; status.style.color = '#059669'; setTimeout(function(){ MLW.closeModal('wlEmailModal'); }, 2000); } else { status.textContent = 'Eroare la trimitere. Încearcă din nou.'; status.style.color = '#d42b2b'; } document.getElementById('wlEmailSend').textContent = 'Trimite'; }); },switchTab: function(tab) { document.querySelectorAll('.wlp-tab').forEach(function(t){ t.classList.remove('active'); }); document.querySelectorAll('.wlp-list').forEach(function(l){ l.classList.remove('active'); }); tab.classList.add('active'); var lid = tab.dataset.listId; var list = document.getElementById('wl-' + lid); if (list) list.classList.add('active'); },updateButtons: function() { document.querySelectorAll('.btn-wl, .js-wishlist-add').forEach(function(btn) { var id = parseInt(btn.dataset.productId); if (id && MLW.ids.indexOf(id) !== -1) btn.classList.add('wl-active'); }); },updateBadge: function(count) { var c = (count !== undefined) ? count : MLW.ids.length; var b = document.querySelector('.wl-badge'); if (b) { b.textContent = c; b.style.display = c > 0 ? 'flex' : 'none'; } },initCounts: function() { document.querySelectorAll('.wlp-list').forEach(function(list) { var cards = list.querySelectorAll('.wlp-trow').length; var lid = list.dataset.listId; var cnt = document.getElementById('cnt-' + lid); if (cnt && cards > 0) { cnt.textContent = cards; cnt.style.display = 'inline'; } }); },toast: function(msg) { var t = document.createElement('div'); t.className = 'mlw-toast'; t.textContent = msg; document.body.appendChild(t); requestAnimationFrame(function(){ t.classList.add('in'); }); setTimeout(function(){ t.classList.remove('in'); setTimeout(function(){ t.remove(); }, 300); }, 2500); } }; document.addEventListener('DOMContentLoaded', function(){ MLW.init(); });
Coșul tău este în prezent gol.