(function () { "use strict"; /* بيانات التواصل والحسابات */ const SETTINGS = { phoneDisplay: "0559992648", phoneLink: "0559992648", email: "lawazmisa@gmail.com", tiktok: "https://www.tiktok.com/@lawazmisa", snapchat: "https://www.snapchat.com/@lawazmisa", instagram: "https://www.instagram.com/lawazmisa/", x: "https://x.com/LawazmiSA" }; const BAR_ID = "lawazmi-custom-contact-bar"; let contactBar = null; let storeHeader = null; let resizeObserver = null; let updateScheduled = false; /* تحميل مكتبة الأيقونات */ function loadFontAwesome() { if (document.getElementById("custom-font-awesome")) { return; } const fontAwesome = document.createElement("link"); fontAwesome.id = "custom-font-awesome"; fontAwesome.rel = "stylesheet"; fontAwesome.href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"; document.head.appendChild(fontAwesome); } /* إنشاء شريط التواصل */ function createContactBar() { const bar = document.createElement("div"); bar.id = BAR_ID; bar.className = "custom-contact-bar"; bar.setAttribute("dir", "rtl"); bar.innerHTML = `
`; return bar; } /* العثور على رأس متجر سلة */ function findStoreHeader() { return ( document.querySelector("header.store-header") || document.querySelector(".store-header") || document.querySelector("salla-header") || document.querySelector("header") || document.querySelector(".main-nav-container") ); } /* حساب ارتفاع الشريطين تلقائيًا */ function updateFixedHeights() { if (!contactBar || !contactBar.isConnected) { return; } const topBarHeight = Math.ceil( contactBar.getBoundingClientRect().height ); let headerHeight = 0; if (storeHeader && storeHeader.isConnected) { headerHeight = Math.ceil( storeHeader.getBoundingClientRect().height ); } document.documentElement.style.setProperty( "--custom-topbar-height", (topBarHeight || 42) + "px" ); document.documentElement.style.setProperty( "--custom-header-height", (headerHeight || 90) + "px" ); } /* جدولة تحديث المقاسات */ function scheduleHeightUpdate() { if (updateScheduled) { return; } updateScheduled = true; requestAnimationFrame(function () { updateScheduled = false; updateFixedHeights(); }); } /* تثبيت شريط التواصل ورأس الصفحة */ function mountFixedBars() { loadFontAwesome(); /* حذف أي شريط قديم مكرر */ document .querySelectorAll(".custom-contact-bar") .forEach(function (element) { if (element.id !== BAR_ID) { element.remove(); } }); contactBar = document.getElementById(BAR_ID); if (!contactBar) { contactBar = createContactBar(); } const detectedHeader = findStoreHeader(); if (!detectedHeader) { if (!contactBar.isConnected) { document.body.prepend(contactBar); } scheduleHeightUpdate(); return; } storeHeader = detectedHeader; /* هذا السطر يربط الهيدر بكود التثبيت في CSS */ storeHeader.classList.add("custom-fixed-store-header"); /* هذا السطر يترك مساحة للشريطين أعلى الصفحة */ document.body.classList.add("has-custom-fixed-bars"); /* وضع شريط التواصل مباشرة فوق رأس المتجر */ if ( contactBar.parentNode !== storeHeader.parentNode || contactBar.nextElementSibling !== storeHeader ) { storeHeader.parentNode.insertBefore( contactBar, storeHeader ); } /* تحديث مراقبة أحجام الشريط والهيدر */ if (resizeObserver) { resizeObserver.disconnect(); } if ("ResizeObserver" in window) { resizeObserver = new ResizeObserver( scheduleHeightUpdate ); resizeObserver.observe(contactBar); resizeObserver.observe(storeHeader); } scheduleHeightUpdate(); setTimeout(scheduleHeightUpdate, 300); setTimeout(scheduleHeightUpdate, 1000); } /* تشغيل الكود */ function start() { mountFixedBars(); window.addEventListener("load", mountFixedBars); window.addEventListener("resize", scheduleHeightUpdate); /* إعادة تطبيق التثبيت إذا أعاد ثيم سلة تحميل الهيدر */ const pageObserver = new MutationObserver(function () { requestAnimationFrame(mountFixedBars); }); pageObserver.observe(document.body, { childList: true, subtree: true }); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", start); } else { start(); }(function () { "use strict"; function fixSectionTitleBackgrounds() { const titleSelectors = [ ".s-block__title", ".s-slider-block__title", ".section-title", ".section--title", ".title--section" ].join(","); document.querySelectorAll(titleSelectors).forEach(function (title) { title.classList.add("lawazmi-section-title-fix"); /* خلفية حاوية العنوان */ title.style.setProperty( "background", "#fafafa", "important" ); title.style.setProperty( "background-color", "#fafafa", "important" ); title.style.setProperty( "background-image", "none", "important" ); title.style.setProperty( "border", "0", "important" ); title.style.setProperty( "box-shadow", "none", "important" ); /* تنسيق العنوان الداخلي */ title.querySelectorAll("h1, h2, h3, h4").forEach( function (heading) { heading.classList.add( "lawazmi-section-heading-fix" ); heading.style.setProperty( "background", "transparent", "important" ); heading.style.setProperty( "background-color", "transparent", "important" ); heading.style.setProperty( "background-image", "none", "important" ); heading.style.setProperty( "border", "0", "important" ); heading.style.setProperty( "box-shadow", "none", "important" ); heading.style.setProperty( "text-align", "center", "important" ); heading.style.setProperty( "margin-left", "auto", "important" ); heading.style.setProperty( "margin-right", "auto", "important" ); } ); /* * تغيير الحاويات البيضاء المحيطة بالعنوان. * يتوقف بعد الوصول إلى عنصر القسم. */ let parent = title.parentElement; let level = 0; while (parent && level < 4) { const background = window.getComputedStyle(parent).backgroundColor; const isWhite = background === "rgb(255, 255, 255)" || background === "rgba(255, 255, 255, 1)"; if (isWhite) { parent.style.setProperty( "background", "#fafafa", "important" ); parent.style.setProperty( "background-color", "#fafafa", "important" ); parent.style.setProperty( "background-image", "none", "important" ); } if (parent.tagName === "SECTION") { break; } parent = parent.parentElement; level++; } }); } function startTitleFix() { fixSectionTitleBackgrounds(); let updatePending = false; const observer = new MutationObserver(function () { if (updatePending) return; updatePending = true; requestAnimationFrame(function () { updatePending = false; fixSectionTitleBackgrounds(); }); }); observer.observe(document.body, { childList: true, subtree: true }); } if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", startTitleFix ); } else { startTitleFix(); } })(); })();