/* Add custom JS code below */ (() => { const POPUP_ID = 'plush-rebrand-overlay'; /* * سيبه فاضي في البداية. * الكود هيحاول ياخد نفس لوجو المتجر من الـ Header. */ const MANUAL_LOGO_URL = 'https://i.ibb.co/whpv8h6k/plush-logo-transparent.png'; function findStoreLogo() { if (MANUAL_LOGO_URL.trim()) { return MANUAL_LOGO_URL.trim(); } const selectors = [ 'header .navbar-brand img', 'header [class*="logo"] img', 'header img[alt*="Plush" i]', 'header img[alt*="logo" i]' ]; for (const selector of selectors) { const image = document.querySelector(selector); if (!image) { continue; } const source = image.currentSrc || image.getAttribute('src'); if (source) { return source; } } return ''; } function openPlushPopup() { if (!document.body) { return; } /* * منع تكرار نفس الـ Popup مرتين * داخل نفس الصفحة فقط. */ if (document.getElementById(POPUP_ID)) { return; } const previouslyFocused = document.activeElement; const previousOverflow = document.body.style.overflow; const overlay = document.createElement('div'); overlay.id = POPUP_ID; overlay.innerHTML = ` `; document.body.appendChild(overlay); document.body.style.overflow = 'hidden'; /* * استخدام نفس لوجو المتجر */ const logo = overlay.querySelector('#plush-rebrand-logo'); const logoFallback = overlay.querySelector('#plush-rebrand-fallback'); const logoURL = findStoreLogo(); if (logoURL) { logo.src = logoURL; logo.hidden = false; logoFallback.hidden = true; logo.addEventListener( 'error', () => { logo.hidden = true; logoFallback.hidden = false; }, { once: true } ); } const closeButton = overlay.querySelector('#plush-rebrand-close'); function closePopup() { document.body.style.overflow = previousOverflow; document.removeEventListener( 'keydown', handleKeyboard ); overlay.remove(); if ( previouslyFocused && typeof previouslyFocused.focus === 'function' ) { try { previouslyFocused.focus({ preventScroll: true }); } catch (error) { /* No action needed */ } } } function handleKeyboard(event) { if (event.key === 'Escape') { closePopup(); } } /* * قفل من X */ closeButton.addEventListener( 'click', closePopup, { once: true } ); /* * قفل بالضغط خارج الـ Popup */ overlay.addEventListener( 'click', (event) => { if (event.target === overlay) { closePopup(); } } ); /* * قفل بزر ESC */ document.addEventListener( 'keydown', handleKeyboard ); try { closeButton.focus({ preventScroll: true }); } catch (error) { closeButton.focus(); } } /* * يظهر مع كل تحميل / Refresh للصفحة */ if (document.readyState === 'loading') { document.addEventListener( 'DOMContentLoaded', openPlushPopup, { once: true } ); } else { openPlushPopup(); } })();