document.addEventListener("DOMContentLoaded", function () { // إضافة الشريط للصفحة const nav = document.createElement("nav"); nav.className = "bottom-nav-bar"; nav.innerHTML = ` حسابي الأقسام المفضلة الرئيسية `; document.body.appendChild(nav); // تحديد العنصر النشط const path = window.location.pathname; const items = { "nav-home": ["/"], "nav-wishlist": ["/wishlist"], "nav-categories": ["/categories"], "nav-account": ["/account", "/login", "/register"], }; for (const [id, paths] of Object.entries(items)) { const el = document.getElementById(id); if (el && paths.some(p => path === p || path.startsWith(p + "/"))) { el.classList.add("active"); } } const hasActive = document.querySelector(".bottom-nav-bar .nav-item.active"); if (!hasActive && path === "/") { const home = document.getElementById("nav-home"); if (home) home.classList.add("active"); } }); document.addEventListener("DOMContentLoaded", function () { document.querySelectorAll(".home-block-title").forEach(function (el) { // إزالة أي خط أو تنسيق افتراضي el.style.cssText = ` display: flex !important; align-items: center !important; justify-content: center !important; gap: 12px !important; font-size: 20px !important; font-weight: 700 !important; color: #2a1f0a !important; text-decoration: none !important; border: none !important; box-shadow: none !important; margin: 28px auto 20px !important; position: relative !important; `; // إزالة الخط الأزرق من العناصر الداخلية el.querySelectorAll("*").forEach(function (child) { child.style.textDecoration = "none"; child.style.borderBottom = "none"; child.style.boxShadow = "none"; }); // إضافة الزخرفة يمين ويسار const rightStar = document.createElement("span"); rightStar.style.cssText = "display:flex; align-items:center; gap:6px; flex-shrink:0;"; rightStar.innerHTML = ` `; const leftStar = document.createElement("span"); leftStar.style.cssText = "display:flex; align-items:center; gap:6px; flex-shrink:0;"; leftStar.innerHTML = ` `; el.insertBefore(rightStar, el.firstChild); el.appendChild(leftStar); }); }); function applyCartIcon() { document.querySelectorAll(".product-card").forEach(function (card) { // تجنب التكرار if (card.dataset.cartDone === "1") return; card.dataset.cartDone = "1"; const title = card.querySelector(".product-card__title"); const addToCartContainer = card.querySelector(".product-card__addToCart:not(.mobile)"); if (!title || !addToCartContainer) return; addToCartContainer.style.display = "none"; const mobileCart = card.querySelector(".product-card__addToCart.mobile"); if (mobileCart) mobileCart.style.display = "none"; const wrapper = document.createElement("div"); wrapper.className = "custom-title-wrapper"; title.parentNode.insertBefore(wrapper, title); wrapper.appendChild(title); const iconBtn = document.createElement("button"); iconBtn.type = "button"; iconBtn.className = "custom-cart-icon-btn"; iconBtn.innerHTML = ` `; iconBtn.addEventListener("click", () => { const originalBtn = addToCartContainer.querySelector("button"); if (originalBtn) originalBtn.click(); }); wrapper.appendChild(iconBtn); }); } // تشغيل بعد تحميل الصفحة مباشرة document.addEventListener("DOMContentLoaded", applyCartIcon); // تشغيل بعد ثانية للـ Web Components setTimeout(applyCartIcon, 1000); // مراقبة أي عناصر جديدة تُضاف const observer = new MutationObserver(applyCartIcon); observer.observe(document.body, { childList: true, subtree: true }); // for navbar-brand window.addEventListener('scroll', () => { const brand = document.querySelector('.navbar-brand'); if (window.scrollY > 80) { brand.classList.add('visible'); } else { brand.classList.remove('visible'); } });