document.addEventListener("DOMContentLoaded", function () { // 1) الهيدر الأساسي const header = document.querySelector("header") || document.querySelector(".site-header") || document.querySelector(".salla-header") || document.querySelector(".header"); if (!header) return; header.style.position = "relative"; // 2) حاول نلقط صورة اللوقو الأصلية const originalLogoImg = header.querySelector(".logo img") || header.querySelector('[class*="logo"] img') || document.querySelector('img[alt*="logo" i]'); if (!originalLogoImg) return; // 3) اخفي اللوقو الأصلي (بدون ما نكسر الهيدر) const originalLogoWrapper = originalLogoImg.closest(".logo") || originalLogoImg.parentElement; if (originalLogoWrapper) originalLogoWrapper.style.visibility = "hidden"; // 4) لا تكرر الإنشاء إذا موجود if (header.querySelector(".fa76-center-logo")) return; // 5) أنشئ لوقو “متمركز” فوق الهيدر const a = document.createElement("a"); a.href = "/"; a.className = "fa76-center-logo"; const img = document.createElement("img"); img.src = originalLogoImg.src; img.alt = "FA76 | Timeless Elegance"; a.appendChild(img); header.appendChild(a); }); (function () { function findHeader() { return ( document.querySelector("header") || document.querySelector(".site-header") || document.querySelector(".salla-header") ); } function mount() { const header = findHeader(); if (!header) return false; // منع التكرار if (document.querySelector(".fa76-trust-ticker")) return true; const bar = document.createElement("div"); bar.className = "fa76-trust-ticker"; bar.innerHTML = `
🚚 توصيل سريع لجميع المناطق
💳 طرق دفع آمنة ومرنة
♻️ إسترجاع واسترداد مجاني
🛒 تسوق الآن وامنحي إطلالتك لمسة فاخرة
تواصل معنا
`; // إظهار فوري (احتياط لو كان فيه CSS يخفيه) bar.style.opacity = "1"; bar.style.visibility = "visible"; bar.style.display = "block"; // وضعه فوق الهيدر مباشرة header.parentNode.insertBefore(bar, header); return true; } // 1) حاول فورًا if (mount()) return; // 2) حاول عند جاهزية DOM (بدون انتظار الصور) if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", function () { if (mount()) return; }); } // 3) راقب تغييرات الصفحة وأضفه أول ما يظهر الهيدر const obs = new MutationObserver(function () { if (mount()) obs.disconnect(); }); obs.observe(document.documentElement, { childList: true, subtree: true }); // 4) حماية: إيقاف المراقبة بعد 8 ثواني setTimeout(function () { try { obs.disconnect(); } catch (e) {} }, 8000); })(); /* ========================= C-1: Desktop Menu Under Logo (FA76) ========================= */ (function () { function mountMenuUnderLogo(){ if (window.innerWidth < 992) return; // لا تعيد الإنشاء لو موجود if (document.querySelector('.fa76-desktop-menu')) return; const header = document.querySelector('header.header-bar'); if (!header) return; // روابط الأقسام الأصلية داخل الهيدر (ثيم رائد) const headerLinks = Array.from(header.querySelectorAll('a.nav-link')) .filter(a => a.textContent && a.textContent.trim().length >= 2); if (headerLinks.length < 4) return; // إنشاء شريط جديد تحت الهيدر const nav = document.createElement('nav'); nav.className = 'fa76-desktop-menu'; const ul = document.createElement('ul'); headerLinks.forEach(a => { const li = document.createElement('li'); const clone = a.cloneNode(true); clone.classList.remove('nav-link'); clone.textContent = clone.textContent.trim(); li.appendChild(clone); ul.appendChild(li); }); nav.appendChild(ul); // ضع الشريط تحت الهيدر مباشرة header.insertAdjacentElement('afterend', nav); // أخفِ روابط الأقسام الأصلية داخل الهيدر فقط (بدون لمس اللوقو) headerLinks.forEach(a => a.classList.add('fa76-hide-navlink')); } function cleanupOnMobile(){ if (window.innerWidth >= 992) return; // في الجوال: احذف الشريط الجديد إن وجد + رجّع روابط الهيدر document.querySelectorAll('.fa76-desktop-menu').forEach(el => el.remove()); document.querySelectorAll('a.fa76-hide-navlink') .forEach(a => a.classList.remove('fa76-hide-navlink')); } function run(){ cleanupOnMobile(); mountMenuUnderLogo(); } window.addEventListener('load', run); window.addEventListener('resize', run); // محاولات لأن ثيم سلة أحيانًا يتأخر بالتحميل let tries = 0; const t = setInterval(() => { tries++; run(); if (tries > 25) clearInterval(t); }, 400); })(); /* ========== FA76 | Desktop Compact Search (Click to Expand) ========== */ (function () { const FA = window.FA76 || (window.FA76 = {}); if (FA.compactSearchInit) return; // منع التكرار FA.compactSearchInit = true; function isDesktop() { return window.matchMedia("(min-width: 992px)").matches; } function findEmailNodeInHeader() { // يحاول يلقط نص يحتوي @ داخل الهيدر const header = document.querySelector("header, .store-header, .header"); if (!header) return null; const candidates = header.querySelectorAll("*"); for (const el of candidates) { const txt = (el.textContent || "").trim(); if (txt.includes("@") && txt.length <= 60) { // نخفي العنصر الأقرب المناسب بدون ما نخفي الهيدر كله return el; } } return null; } function findSearchInput() { // أشهر سيلكتورات البحث في سلة + fallback return ( document.querySelector('input[type="search"]') || document.querySelector('form[action*="search"] input') || document.querySelector("input[name='q']") || null ); } function findHeaderIconsArea() { // نحاول نلقط منطقة الأيقونات (سلة/حساب) return ( document.querySelector(".store-header__icons") || document.querySelector(".store-header__buttons") || document.querySelector(".store-header__actions") || document.querySelector("header .icons") || document.querySelector("header") // fallback: نضيفه في الهيدر نفسه لو ما لقينا ); } function createUI(originalInput) { // نخفي البحث الأصلي بالديسكتوب فقط (لكن نخليه موجود عشان الفورم) const originalForm = originalInput.closest("form") || originalInput.parentElement; // نبني واجهة البحث المصغّر const wrap = document.createElement("div"); wrap.className = "fa76-search-wrap"; const btn = document.createElement("button"); btn.type = "button"; btn.className = "fa76-search-btn"; btn.setAttribute("aria-label", "بحث"); btn.innerHTML = ` `; const panel = document.createElement("div"); panel.className = "fa76-search-panel"; // ننشئ input جديد مرتبط بنفس الفورم (أفضل من نقل الأصلي لتجنب كسر الستايل) const input = document.createElement("input"); input.type = originalInput.type || "search"; input.name = originalInput.name || "q"; input.placeholder = originalInput.placeholder || "ابحث..."; input.autocomplete = "off"; panel.appendChild(input); wrap.appendChild(btn); wrap.appendChild(panel); // عند الإرسال: لو فيه فورم أصلي نستخدمه input.addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); // انسخ القيمة للأصلي (إن وجد) ثم submit try { originalInput.value = input.value; } catch(_){} if (originalForm && originalForm.tagName === "FORM") originalForm.submit(); else if (originalInput.form) originalInput.form.submit(); } if (e.key === "Escape") close(); }); function open() { wrap.classList.add("is-open"); setTimeout(() => input.focus(), 0); } function close() { wrap.classList.remove("is-open"); input.blur(); } function toggle() { wrap.classList.contains("is-open") ? close() : open(); } btn.addEventListener("click", toggle); // إغلاق عند الضغط خارج document.addEventListener("click", (e) => { if (!wrap.classList.contains("is-open")) return; if (!wrap.contains(e.target)) close(); }); // إغلاق بزر ESC عام document.addEventListener("keydown", (e) => { if (e.key === "Escape") close(); }); // نخفي البحث الأصلي على الديسكتوب فقط if (originalForm) { originalForm.dataset.fa76OriginalSearch = "1"; originalForm.style.display = "none"; } else { originalInput.style.display = "none"; } return wrap; } function mount() { if (!isDesktop()) return; // لا نعمل شيء للجوال // 1) إخفاء الإيميل const emailNode = findEmailNodeInHeader(); if (emailNode) { // نخفي أقرب عنصر "سطر" بدل ما نخفي جزء كبير const box = emailNode.closest("div,li,span,p,a") || emailNode; box.classList.add("fa76-hide-email"); } // 2) البحث المصغّر const searchInput = findSearchInput(); if (!searchInput) return; // لا تعيد التركيب لو موجود if (document.querySelector(".fa76-search-wrap")) return; const iconsArea = findHeaderIconsArea(); if (!iconsArea) return; const ui = createUI(searchInput); // نحاول نخليه يمين السلة: غالبًا أيقونات السلة داخل نفس المنطقة // فإذا أمكن نضيفه بجانب الأيقونات (آخر عنصر) iconsArea.appendChild(ui); } // تشغيل document.addEventListener("DOMContentLoaded", mount); // إعادة تركيب عند تغيير المقاس (بدون تخريب الجوال) window.addEventListener("resize", () => { // لو رجعنا للجوال: رجّع البحث الأصلي وامسح واجهتنا if (!isDesktop()) { const wrap = document.querySelector(".fa76-search-wrap"); if (wrap) wrap.remove(); const original = document.querySelector('[data-fa76-original-search="1"]'); if (original) original.style.display = ""; return; } // لو ديسكتوب: تأكد مركب mount(); }); })();