window.addEventListener("load", function () {
if (window.location.href.indexOf("/checkout/") > -1) {
var div = document.createElement("div");
div.id = "wa-selia-checkout";
div.style.cssText = "position:fixed;bottom:20px;right:20px;z-index:99999;background:#22c55e;border-radius:50%;width:55px;height:55px;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 10px rgba(0,0,0,0.3);";
div.innerHTML = '';
document.body.appendChild(div);
}
});
document.addEventListener("DOMContentLoaded", function () {
// شيل أي فوتر قديم
document.querySelectorAll('footer:not(.custom-footer)').forEach(function(el) {
el.remove();
});
if (!document.querySelector('.custom-footer')) {
const footerHTML = `
`;
document.body.insertAdjacentHTML("beforeend", footerHTML);
}
});
(function () {
function isHomePage() {
var path = window.location.pathname;
return (
path === "/" ||
path === "" ||
path === "/potionperfumes.shop" ||
path === "/potionperfumes.shop/" ||
path.endsWith("/potionperfumes.shop") ||
path.endsWith("/potionperfumes.shop/")
);
}
function showPopup() {
if (!isHomePage()) return;
if (document.getElementById("eid-popup")) return;
var popup = document.createElement("div");
popup.innerHTML = `
`;
document.body.appendChild(popup);
document.getElementById("eid-popup").onclick = function (e) {
if (e.target.id === "eid-popup") {
document.getElementById("eid-popup").remove();
}
};
}
window.addEventListener("load", function () {
setTimeout(showPopup, 1200);
});
})();
document.addEventListener('DOMContentLoaded', function() {
function initSticky() {
var slider = document.querySelector('.product-single__slider');
var info = document.querySelector('.product-single__info');
if (!slider || !info) return;
if (window.innerWidth < 768) return;
var img = slider.querySelector('img');
if (img && !img.complete) {
img.addEventListener('load', function() {
setTimeout(setup, 100);
});
} else {
setup();
}
function setup() {
var placeholder = document.createElement('div');
placeholder.style.width = slider.offsetWidth + 'px';
placeholder.style.height = slider.offsetHeight + 'px';
placeholder.style.flexShrink = '0';
placeholder.style.visibility = 'hidden';
slider.parentElement.insertBefore(placeholder, slider);
var headerHeight = 80;
var sliderWidth = placeholder.offsetWidth;
var sliderHeight = placeholder.offsetHeight;
function getSliderRight() {
return window.innerWidth - placeholder.getBoundingClientRect().right;
}
slider.style.cssText = [
'position:absolute',
'top:0',
'right:0',
'width:' + sliderWidth + 'px',
'max-width:' + sliderWidth + 'px'
].join(';');
slider.parentElement.style.position = 'relative';
function updateSlider() {
if (window.innerWidth < 768) {
slider.style.cssText = '';
slider.parentElement.style.position = '';
return;
}
var scrollY = window.scrollY;
var placeholderTop = placeholder.getBoundingClientRect().top + scrollY;
var infoBottom = info.getBoundingClientRect().bottom + scrollY;
var stickyStart = placeholderTop - headerHeight;
var stickyEnd = infoBottom - sliderHeight - headerHeight;
if (scrollY < stickyStart) {
slider.style.cssText = [
'position:absolute',
'top:0',
'right:0',
'width:' + sliderWidth + 'px',
'max-width:' + sliderWidth + 'px'
].join(';');
slider.parentElement.style.position = 'relative';
} else if (scrollY >= stickyStart && scrollY <= stickyEnd) {
slider.style.cssText = [
'position:fixed',
'top:' + headerHeight + 'px',
'right:' + getSliderRight() + 'px',
'width:' + sliderWidth + 'px',
'max-width:' + sliderWidth + 'px',
'z-index:10'
].join(';');
slider.parentElement.style.position = 'relative';
} else {
slider.style.cssText = [
'position:absolute',
'top:' + (infoBottom - placeholderTop - sliderHeight) + 'px',
'right:0',
'width:' + sliderWidth + 'px',
'max-width:' + sliderWidth + 'px',
'z-index:10'
].join(';');
slider.parentElement.style.position = 'relative';
}
}
window.addEventListener('scroll', updateSlider);
window.addEventListener('resize', function() {
if (window.innerWidth < 768) {
slider.style.cssText = '';
slider.parentElement.style.position = '';
return;
}
sliderWidth = placeholder.offsetWidth;
sliderHeight = placeholder.offsetHeight;
updateSlider();
});
updateSlider();
}
}
initSticky();
});
(function () {
// ديسكتوب بس
if (window.innerWidth < 768) return;
var style = document.createElement('style');
style.innerHTML = `
body.mm-ocd-opened { overflow: hidden !important; margin: 0 !important; width: 100% !important; }
.mm-ocd { z-index: 99999 !important; }
.mm-ocd__backdrop { z-index: 99998 !important; }
.mm-ocd__content { position: relative !important; padding-top: 55px !important; height: 100% !important; overflow-y: auto !important; background: #fff !important; }
.mm-ocd__content::before {
content: "القائمة الرئيسية" !important;
position: absolute !important; top: 15px !important; right: 20px !important;
font-size: 16px !important; font-weight: 700 !important; color: #000 !important;
}
.mm-ocd__content .mobile-menu-clone .main-menu {
display: block !important;
flex-direction: unset !important;
padding: 11px 71px !important;
margin: 0 !important;
}
.mm-ocd__content .mobile-menu-clone li.\\!hidden { display: none !important; }
.mm-ocd__content .mobile-menu-clone .main-menu > li.lg\\:hidden {
display: block !important;
border-bottom: 1px solid #f0f0f0 !important;
list-style: none !important;
}
.mm-ocd__content .mobile-menu-clone .main-menu > li.lg\\:hidden > a,
.mm-ocd__content .mobile-menu-clone .main-menu > li.lg\\:hidden > span {
display: flex !important;
align-items: center !important;
justify-content: space-between !important;
padding: 24px 0 !important;
font-size: 14px !important;
font-weight: 600 !important;
color: #000 !important;
cursor: pointer !important;
width: 100% !important;
direction: rtl !important;
text-decoration: none !important;
}
.mm-ocd__content .mobile-menu-clone .main-menu > li.lg\\:hidden > ul {
display: none !important;
padding-right: 15px !important;
margin: 0 !important;
}
.mm-ocd__content .mobile-menu-clone .main-menu > li.lg\\:hidden.is-open > ul {
display: block !important;
}
.mm-ocd__content .mobile-menu-clone ul ul li.\\!hidden { display: none !important; }
.mm-ocd__content .mobile-menu-clone ul ul li.lg\\:hidden {
display: block !important;
list-style: none !important;
}
.mm-ocd__content .mobile-menu-clone ul ul li.lg\\:hidden > a,
.mm-ocd__content .mobile-menu-clone ul ul li.lg\\:hidden > span {
display: flex !important;
align-items: center !important;
justify-content: space-between !important;
padding: 20px 0 !important;
font-size: 14px !important;
color: #555 !important;
direction: rtl !important;
border-bottom: 1px solid #f5f5f5 !important;
text-decoration: none !important;
}
.mm-ocd__content .mobile-menu-clone ul ul li.lg\\:hidden > ul {
display: none !important;
padding-right: 15px !important;
}
.mm-ocd__content .mobile-menu-clone ul ul li.lg\\:hidden.is-open > ul {
display: block !important;
}
.mm-ocd__content .mobile-menu-clone img {
width: 55px !important;
height: 55px !important;
border-radius: 50% !important;
margin-left: -87px !important;
}
.mm-ocd__content .btn--close { display: none !important; }
.menu-arrow { font-size: 16px; transition: transform 0.3s; color: #999; flex-shrink: 0; }
.is-open > a > .menu-arrow, .is-open > span > .menu-arrow { transform: rotate(90deg); }
#sticky-menu-btn {
margin-top: 22px;
position: relative;
width: 32px;
height: 21px;
background: none;
border: none;
padding: 0;
cursor: pointer;
overflow: hidden;
}
#sticky-menu-btn::before,
#sticky-menu-btn::after,
#sticky-menu-btn span.bar {
content: '';
display: block;
width: 100%;
height: 2px;
background: currentColor;
border-radius: 2px;
position: absolute;
left: 0;
right: 0;
}
#sticky-menu-btn::before { top: 0; }
#sticky-menu-btn span.bar { top: 50%; transform: translateY(-50%); }
#sticky-menu-btn::after { bottom: 0; }
@keyframes slideOutLeft {
0% { transform: translateX(0); opacity: 1; }
100% { transform: translateX(-120%); opacity: 0; }
}
@keyframes slideInRight {
0% { transform: translateX(120%); opacity: 0; }
100% { transform: translateX(0); opacity: 1; }
}
#sticky-menu-btn:hover::before {
animation: slideOutLeft 0.15s ease forwards, slideInRight 0.2s ease 0.15s forwards;
}
#sticky-menu-btn:hover span.bar {
animation: slideOutLeft 0.15s ease 0.05s forwards, slideInRight 0.2s ease 0.2s forwards;
}
#sticky-menu-btn:hover::after {
animation: slideOutLeft 0.15s ease 0.1s forwards, slideInRight 0.2s ease 0.25s forwards;
}
`;
document.head.appendChild(style);
function buildMenu() {
var mmContent = document.querySelector('.mm-ocd__content');
if (!mmContent || document.querySelector('.mobile-menu-clone')) return;
var mobileMenu = document.getElementById('mobile-menu');
if (!mobileMenu) return;
var cloned = mobileMenu.cloneNode(true);
cloned.removeAttribute('id');
cloned.className = 'mobile-menu-clone';
cloned.style.cssText = 'display:block !important;';
mmContent.appendChild(cloned);
var closeBtn = document.createElement('button');
closeBtn.innerHTML = '✕';
closeBtn.style.cssText = 'position:absolute; top:15px; left:15px; background:none; border:none; font-size:20px; cursor:pointer; color:#000; z-index:10;';
closeBtn.onclick = function () {
var mmOcd = document.querySelector('.mm-ocd');
if (mmOcd) mmOcd.classList.remove('mm-ocd--open');
document.body.classList.remove('mm-ocd-opened');
};
mmContent.appendChild(closeBtn);
function setupAccordion(container) {
var items = container.querySelectorAll(':scope > li.lg\\:hidden');
items.forEach(function (li) {
var subMenu = li.querySelector(':scope > ul');
if (!subMenu) return;
var trigger = li.querySelector(':scope > a, :scope > span');
if (!trigger) return;
var arrow = document.createElement('span');
arrow.className = 'menu-arrow';
arrow.innerHTML = '›';
trigger.appendChild(arrow);
trigger.addEventListener('click', function (e) {
e.preventDefault();
var isOpen = li.classList.contains('is-open');
items.forEach(function (other) { other.classList.remove('is-open'); });
if (!isOpen) li.classList.add('is-open');
});
setupAccordion(subMenu);
});
}
var mainMenu = cloned.querySelector('.main-menu');
if (mainMenu) setupAccordion(mainMenu);
}
window.addEventListener('scroll', function () {
// تأكيد تاني عند كل scroll
if (window.innerWidth < 768) return;
var header = document.getElementById('mainnav');
if (!header) return;
var stickyBtn = document.getElementById('sticky-menu-btn');
if (window.scrollY > 100) {
if (!stickyBtn) {
var btn = document.createElement('button');
btn.id = 'sticky-menu-btn';
btn.innerHTML = '';
btn.style.cssText = 'display:flex; align-items:center; cursor:pointer;';
btn.onclick = function () {
buildMenu();
var mmOcd = document.querySelector('.mm-ocd');
if (!mmOcd) return;
if (mmOcd.classList.contains('mm-ocd--open')) {
mmOcd.classList.remove('mm-ocd--open');
document.body.classList.remove('mm-ocd-opened');
} else {
mmOcd.classList.add('mm-ocd--open');
document.body.classList.add('mm-ocd-opened');
}
};
var firstChild = header.querySelector('.flex.items-stretch');
if (firstChild) firstChild.prepend(btn);
}
stickyBtn.style.display = 'flex';
} else {
if (stickyBtn) stickyBtn.style.display = 'none';
}
});
})();
/* Add custom Js styles below */
(function () {
function initDynamicPopup() {
// إذا أغلق العميل النافذة سابقاً في هذه الجلسة، لا تظهرها
if (sessionStorage.getItem('eid_popup_closed')) return;
// البحث عن العناصر التي لا تظهر إلا في هوم بيدج سلة
// سنبحث عن السلايدر أو قسم المميزات
var homeElements = document.querySelector('.main-slider, .s-block-banners, .s-block-features-grid');
if (homeElements) {
if (!document.getElementById("eid-popup-ultimate")) {
renderPopup();
}
} else {
// إذا لم يجد عناصر الصفحة الرئيسية، يحذف البوب أب (في حال انتقل لصفحة أخرى)
var existing = document.getElementById("eid-popup-ultimate");
if (existing) existing.remove();
}
}
function renderPopup() {
var popup = document.createElement("div");
popup.id = "eid-popup-ultimate";
// تنسيق يضمن الظهور فوق كل شيء
popup.style.cssText = "position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.85);display:flex;align-items:center;justify-content:center;z-index:999999999;direction:rtl;";
popup.innerHTML = `
حبة عليك… والثانية علينا
اشترِ حبة واحصل على الثانية مجاناً
اطلب الآن
`;
document.body.appendChild(popup);
document.getElementById("close-eid-final").onclick = function() {
popup.remove();
sessionStorage.setItem('eid_popup_closed', 'true');
};
popup.onclick = function(e) {
if (e.target === popup) {
popup.remove();
sessionStorage.setItem('eid_popup_closed', 'true');
}
};
}
// فحص مستمر كل ثانية لأن سلة تغير المحتوى ديناميكياً
setInterval(initDynamicPopup, 1000);
})();