/* Add custom Js code below */ setTimeout(function () { var btn = document.createElement("div"); btn.id = "whatsapp-button"; btn.innerHTML = 'WhatsApp'; btn.style.position = "fixed"; btn.style.bottom = "20px"; btn.style.right = "20px"; btn.style.zIndex = "9999"; btn.style.width = "60px"; btn.style.height = "60px"; btn.style.backgroundColor = "#25D366"; btn.style.borderRadius = "50%"; btn.style.boxShadow = "0 4px 12px rgba(0,0,0,0.3)"; btn.style.display = "flex"; btn.style.justifyContent = "center"; btn.style.alignItems = "center"; btn.style.cursor = "pointer"; btn.style.transition = "transform 0.3s ease"; btn.onmouseover = function () { btn.style.transform = "scale(1.1)"; }; btn.onmouseout = function () { btn.style.transform = "scale(1)"; }; var img = btn.querySelector("img"); img.style.width = "30px"; img.style.height = "30px"; btn.onclick = function () { window.open("https://wa.me/966561515801", "_blank"); }; document.body.appendChild(btn); }, 2000); // // Google Fonts let cairoFontLink = document.createElement("link"); cairoFontLink.href = "https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap"; cairoFontLink.rel = "stylesheet"; document.head.appendChild(cairoFontLink); // let style = document.createElement("style"); style.innerHTML = ` * { font-family: 'Cairo', sans-serif !important; } `; document.head.appendChild(style); // إنشاء اللودر وقت تحميل الصفحة const loader = document.createElement('div'); loader.id = 'custom-preloader'; loader.innerHTML = ` Logo `; document.body.appendChild(loader); // إزالة اللودر بعد تحميل الصفحة window.addEventListener('load', () => { loader.style.opacity = '0'; loader.style.transition = 'opacity 0.8s ease'; setTimeout(() => { loader.remove(); }, 800); }); if (window.innerWidth <= 768) { const nav = document.createElement("div"); nav.className = "custom-mobile-nav"; nav.style.cssText = ` position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #ccc; display: flex; justify-content: space-around; align-items: center; padding: 6px 0; z-index: 9999; `; nav.innerHTML = ` الحساب السلة المفضلة
الفئات
الرئيسية `; document.body.appendChild(nav); // فتح الحساب document.getElementById("login-btn").addEventListener("click", function (e) { e.preventDefault(); if (typeof salla !== "undefined" && salla.event) { salla.event.dispatch("login::open"); } else { alert("لم يتم تحميل مكتبة salla بعد."); } }); // المفضلة document.getElementById("wishlist-btn").addEventListener("click", function (e) { e.preventDefault(); alert("صفحة المفضلة غير مفعلة حالياً."); }); // الفئات - toggle القائمة document.getElementById("categories-toggle").addEventListener("click", function (e) { const menu = document.getElementById("categories-menu"); // نمنع التفعيل فقط لو تم الضغط على العنصر نفسه، مش على الروابط if (e.target.closest("a")) return; menu.style.display = menu.style.display === "block" ? "none" : "block"; }); // عدد السلة try { const cartItems = JSON.parse(localStorage.getItem("cart")) || []; const cartCount = document.getElementById("cart-count"); if (cartItems.length > 0) { cartCount.textContent = cartItems.length; cartCount.style.display = "inline-block"; } } catch (e) { console.warn("تعذر قراءة السلة"); } } function moveWhatsappButtonLeft() { var btn = document.getElementById("whatsapp-button"); if (btn && window.innerWidth <= 768) { btn.style.bottom = "90px"; // ارفع الزر لفوق btn.style.right = "auto"; // شيل التمركز اليمين btn.style.left = "20px"; // حط الزر على الشمال } } window.addEventListener("load", moveWhatsappButtonLeft); let tries = 0; let interval = setInterval(() => { moveWhatsappButtonLeft(); tries++; if (tries >= 5) clearInterval(interval); }, 1000);