/* =========================
البار العلوي
=========================
window.addEventListener("load", function () {
const bar = document.createElement("div");
bar.innerHTML = `
🎉 عيد أضحى مبارك 🎉
يوم الجمعة 22/5 آخر يوم استقبال طلبات خارج الرياض
|
يوم الأحد 24/5 آخر يوم استقبال طلبات الرياض لوصولها قبل العيد
`;
Object.assign(bar.style, {
position: "fixed",
top: "0",
right: "0",
width: "100%",
background: "#000",
color: "#fff",
padding: "12px 20px",
textAlign: "center",
zIndex: "999999",
fontSize: "15px",
fontWeight: "bold",
direction: "rtl",
boxShadow: "0 2px 10px rgba(0,0,0,.2)"
});
document.body.prepend(bar);
document.body.style.paddingTop = "60px";
bar.animate([
{ transform: "translateY(-100%)" },
{ transform: "translateY(0)" }
], {
duration: 700,
easing: "ease"
});
});
/* =========================
البوب أب الأول
المنتج p53625361
========================= */
document.addEventListener("DOMContentLoaded", function () {
if (!window.location.href.includes("p53625361")) return;
setTimeout(function () {
if (document.getElementById("mzaya-overlay")) return;
const popup = document.createElement("div");
popup.innerHTML = `
🎁
وفر أكثر مع باقة دخون مزايا
هذا المنتج من الأكثر طلبًا لدى عملائنا.
احصل على قيمة أكبر وهدايا إضافية مع باقة دخون مزايا المميزة.
مشاهدة الباقة 🎁
`;
document.body.appendChild(popup);
document
.getElementById("close-mzaya-popup")
.addEventListener("click", function () {
document
.getElementById("mzaya-overlay")
.remove();
});
}, 3000);
});
/* =========================
البوب أب الثاني
المنتج p315543078
========================= */
document.addEventListener("DOMContentLoaded", function () {
// يظهر فقط في صفحة منتج مسك مزايا
if (!window.location.href.includes("p315543078")) return;
setTimeout(function () {
if (document.getElementById("national-overlay")) return;
const popup = document.createElement("div");
popup.innerHTML = `
🎁
وفر أكثر مع مسك مزايا
هذا المنتج من الأكثر طلبًا لدى عملائنا.
احصل على قيمة أكبر وهدايا إضافية مع مسك مزايا المميز.
مشاهدة الباقة 🎁
`;
document.body.appendChild(popup);
document
.getElementById("close-national-popup")
.addEventListener("click", function () {
document
.getElementById("national-overlay")
.remove();
});
}, 3000);
});
/********************/
document.addEventListener("DOMContentLoaded", function () {
// منتج مخمريه للجسم والشعر
if (!window.location.href.includes("p2002105390")) return;
setTimeout(function () {
if (document.getElementById("national-overlay")) return;
const popup = document.createElement("div");
popup.innerHTML = `
🎁
وفر أكثر مع مخمريه مزايا
هذا المنتج من الأكثر طلبًا لدى عملائنا.
احصل على قيمة أكبر وهدايا إضافية مع مخمريه مزايا المميزة.
مشاهدة الباقة 🎁
`;
document.body.appendChild(popup);
document
.getElementById("close-national-popup")
.addEventListener("click", function () {
document
.getElementById("national-overlay")
.remove();
});
}, 3000);
});
/* =========================
Animation
========================= */
const style = document.createElement("style");
style.innerHTML = `
@keyframes popupShow {
from {
opacity: 0;
transform: scale(.8);
}
to {
opacity: 1;
transform: scale(1);
}
}
`;
document.head.appendChild(style);
(function () {
"use strict";
/* ==================================================
MZAYA BUNDLES
================================================== */
var MZAYA_BUNDLES = {
/* ==============================================
الباقة الأولى
============================================== */
"850394324": {
title: "باقة تعطير مزايا الكامل",
products: [
{
id: 1179297748,
name: "عطر سبيشل",
image: "",
url: "https://mzayaalteeb.com/عطر-سبيشل/p1179297748"
},
{
id: 960848253,
name: "بخور معمول ملكي",
image: "",
url: "https://mzayaalteeb.com/بخور-معمول-ملكي/p960848253"
},
{
id: 1795398961,
name: "برفيوم الشعر",
image: "",
url: "https://mzayaalteeb.com/برفيوم-الشعر/p1795398961"
}
]
},
/* ==============================================
الباقة الثانية
============================================== */
"1804246283": {
title: "باقة إهداء مزايا",
products: [
{
id: 503967876,
name: "عطر راء 1994",
image: "",
url: "https://mzayaalteeb.com/عطر-راء/p503967876"
},
{
id: 266595162,
name: "عطر عنبر عود",
image: "",
url: "https://mzayaalteeb.com/عطر-عنبر-عود/p266595162"
},
{
id: 960848253,
name: "معمول ملكي صغير",
image: "",
url: "https://mzayaalteeb.com/بخور-معمول-ملكي/p960848253"
}
]
},
/* ==============================================
الباقة الثالثة
ملاحظة:
ID الباقة نفسها ليس بالضرورة ID المنتج الأول.
لذلك هنا نعرض المنتجات التي أرسلتي روابطها.
============================================== */
"234925736": {
title: "باقة العود",
products: [
{
id: 234925736,
name: "عود مسقي",
image: "",
url: "https://mzayaalteeb.com/عود-مسقي/p234925736"
},
{
id: 359667953,
name: "عود طبيعي محسن",
image: "",
url: "https://mzayaalteeb.com/عود-طبيعي-محسن/p359667953"
},
{
id: 1599474833,
name: "لبان مسقى",
image: "",
url: "https://mzayaalteeb.com/لبان-مسقى/p1599474833"
}
]
}
};
/* ==================================================
GET CURRENT PRODUCT ID
================================================== */
function getCurrentID() {
var match =
window.location.pathname.match(
/\/p(\d+)/
);
return match
? match[1]
: null;
}
/* ==================================================
FIND BUNDLE
================================================== */
function getBundle() {
var id = getCurrentID();
if (!id) {
return null;
}
return MZAYA_BUNDLES[id] || null;
}
/* ==================================================
CREATE POPUP
================================================== */
function createPopup(bundle) {
if (
document.getElementById(
"mz-bundle-overlay"
)
) {
return;
}
var overlay =
document.createElement("div");
overlay.id =
"mz-bundle-overlay";
overlay.className =
"mz-bundle-overlay";
/* ============================================
PRODUCTS HTML
============================================ */
var productsHTML = "";
bundle.products.forEach(
function (product) {
/*
* مهم:
* لو مفيش صورة محددة،
* نستخدم صورة بسيطة placeholder.
*/
var image =
product.image ||
"data:image/svg+xml;charset=UTF-8," +
encodeURIComponent(
""
);
productsHTML += `
${product.name}
`;
}
);
/* ============================================
POPUP
============================================ */
overlay.innerHTML = `
${bundle.title}
محتويات الباقة
${productsHTML}
`;
document.body.appendChild(
overlay
);
/* ============================================
CLOSE
============================================ */
var closeButton =
overlay.querySelector(
".mz-bundle-close"
);
closeButton.addEventListener(
"click",
function () {
overlay.remove();
document.body.style.overflow = "";
}
);
/* ============================================
CLICK OUTSIDE
============================================ */
overlay.addEventListener(
"click",
function (event) {
if (
event.target === overlay
) {
overlay.remove();
document.body.style.overflow = "";
}
}
);
/* ============================================
ESC
============================================ */
function escapeHandler(event) {
if (
event.key === "Escape" &&
document.getElementById(
"mz-bundle-overlay"
)
) {
overlay.remove();
document.body.style.overflow = "";
document.removeEventListener(
"keydown",
escapeHandler
);
}
}
document.addEventListener(
"keydown",
escapeHandler
);
/* ============================================
CART BUTTONS
============================================ */
var buttons =
overlay.querySelectorAll(
".mz-bundle-add"
);
buttons.forEach(
function (button) {
button.addEventListener(
"click",
function () {
addProduct(
button
);
}
);
}
);
/*
* Lock background
*/
document.body.style.overflow =
"hidden";
}
/* ==================================================
ADD PRODUCT
================================================== */
function addProduct(button) {
var productID =
Number(
button.getAttribute(
"data-product-id"
)
);
var productURL =
button.getAttribute(
"data-product-url"
);
/*
* تأكد أن Salla SDK موجود
*/
if (
typeof window.salla === "undefined"
) {
console.warn(
"Salla SDK is not ready"
);
window.location.href =
productURL;
return;
}
if (
!salla.cart ||
typeof salla.cart.quickAdd !== "function"
) {
console.warn(
"Salla quickAdd is not available"
);
window.location.href =
productURL;
return;
}
button.classList.add(
"loading"
);
button.disabled = true;
button.textContent =
"جاري الإضافة...";
/*
* Salla Quick Add
*/
salla.cart.quickAdd(
productID
)
.then(
function () {
button.classList.remove(
"loading"
);
button.classList.add(
"success"
);
button.textContent =
"✓ تمت الإضافة";
setTimeout(
function () {
button.classList.remove(
"success"
);
button.disabled =
false;
button.textContent =
"أضف للسلة";
},
1800
);
}
)
.catch(
function (error) {
console.error(
"MZAYA CART ERROR:",
error
);
/*
* لو المنتج يحتاج خيارات
* نفتح صفحة المنتج.
*/
button.classList.remove(
"loading"
);
button.disabled =
false;
button.textContent =
"اختاري المنتج";
setTimeout(
function () {
window.location.href =
productURL;
},
400
);
}
);
}
/* ==================================================
INIT
================================================== */
function initMZAYA() {
/*
* منع التكرار
*/
if (
document.getElementById(
"mz-bundle-overlay"
)
) {
return;
}
var bundle =
getBundle();
console.log(
"MZAYA CURRENT ID:",
getCurrentID()
);
if (!bundle) {
console.log(
"MZAYA: Not a bundle page"
);
return;
}
console.log(
"MZAYA BUNDLE FOUND:",
bundle.title
);
/*
* نفتح البوب أب
*/
createPopup(
bundle
);
}
/* ==================================================
RUN
================================================== */
if (
document.readyState === "loading"
) {
document.addEventListener(
"DOMContentLoaded",
function () {
setTimeout(
initMZAYA,
1200
);
}
);
} else {
setTimeout(
initMZAYA,
1200
);
}
})();
/* مزايا الطيب — بوب أب "باقة دخون مزايا" بعد إضافة أي منتج للسلة (Salla / Celia) */
(function () {
if (window.__mzPkgPopupLoaded) return;
window.__mzPkgPopupLoaded = true;
/* ====== إعدادات تقدر تعدّلها ====== */
var CFG = {
PRODUCT_ID: 1842124140,
NAME: 'باقة دخون مزايا',
DESC: 'معمول مسبق + عود مسبق + دقة مروكي بيور',
PRICE: '229',
URL: 'https://mzayaalteeb.com/%D8%A8%D8%A7%D9%82%D8%A9-%D8%AF%D8%AE%D9%88%D9%86-%D9%85%D8%B2%D8%A7%D9%8A%D8%A7/p1842124140',
IMAGE: 'https://cdn.salla.sa/ZYGVQb/28088fe9-d840-4f98-ab16-e87771034990-500x500-M2s0cTEWEp4MMWnBn6ojhWFuzjY7Sb1fgv4SEsL3.jpg',
DELAY_MS: 500, // تأخير بسيط عشان إشعار Salla يظهر الأول
ONCE_PER_SESSION: false // true = يظهر مرة واحدة بس في الجلسة
};
/* ألوان الهوية (تقديرية من الموقع) */
var COLORS = {
bg: '#0f1f19', card: '#162b22', gold: '#c9a56b',
text: '#f4eee3', muted: '#b8b0a0', line: 'rgba(201,165,107,.35)'
};
var css =
'.mz-pkg{position:fixed;inset:0;z-index:99999;display:none;align-items:center;justify-content:center;font-family:inherit;direction:rtl}' +
'.mz-pkg.is-open{display:flex}' +
'.mz-pkg__overlay{position:absolute;inset:0;background:rgba(0,0,0,.65);animation:mzFade .25s ease}' +
'.mz-pkg__box{position:relative;width:min(92vw,400px);max-height:92vh;overflow:auto;background:' + COLORS.bg + ';color:' + COLORS.text + ';border:1px solid ' + COLORS.line + ';border-radius:16px;padding:22px 20px 20px;text-align:center;box-shadow:0 20px 60px rgba(0,0,0,.5);animation:mzUp .3s ease}' +
'.mz-pkg__x{position:absolute;top:10px;left:10px;width:32px;height:32px;border:0;border-radius:50%;background:transparent;color:' + COLORS.muted + ';font-size:24px;line-height:1;cursor:pointer}' +
'.mz-pkg__x:hover{color:' + COLORS.gold + '}' +
'.mz-pkg__ok{font-size:13px;color:' + COLORS.muted + ';margin:0 0 6px}' +
'.mz-pkg__title{font-size:20px;font-weight:700;color:' + COLORS.gold + ';margin:0 0 14px}' +
'.mz-pkg__img{display:block;width:200px;height:200px;max-width:100%;object-fit:cover;margin:0 auto 12px;border-radius:12px;border:1px solid ' + COLORS.line + '}' +
'.mz-pkg__name{font-size:17px;font-weight:700;margin:0 0 4px;color:' + COLORS.text + ';text-decoration:none;display:block}' +
'.mz-pkg__desc{font-size:13px;color:' + COLORS.muted + ';margin:0 0 10px}' +
'.mz-pkg__price{font-size:22px;font-weight:700;color:' + COLORS.text + ';margin:0 0 16px}' +
'.mz-pkg__price i{font-size:18px;margin-inline-start:4px}' +
'.mz-pkg__add{width:100%;border:0;border-radius:10px;padding:13px;background:' + COLORS.gold + ';color:' + COLORS.bg + ';font-size:16px;font-weight:700;font-family:inherit;cursor:pointer;transition:opacity .2s}' +
'.mz-pkg__add:hover{opacity:.9}.mz-pkg__add[disabled]{opacity:.6;cursor:wait}' +
'.mz-pkg__skip{margin-top:10px;background:none;border:0;color:' + COLORS.muted + ';font-size:14px;font-family:inherit;cursor:pointer;text-decoration:underline}' +
'@keyframes mzFade{from{opacity:0}to{opacity:1}}@keyframes mzUp{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:none}}' +
'@media(max-width:640px){.mz-pkg{align-items:flex-end}.mz-pkg__box{width:100%;border-radius:16px 16px 0 0;animation:mzSheet .3s ease}@keyframes mzSheet{from{transform:translateY(100%)}to{transform:none}}}';
var root, addBtn, busy = false, prevOverflow = '';
function build() {
if (root) return;
var style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
root = document.createElement('div');
root.className = 'mz-pkg';
root.setAttribute('role', 'dialog');
root.setAttribute('aria-modal', 'true');
root.setAttribute('aria-labelledby', 'mz-pkg-title');
root.innerHTML =
'' +
'' +
'
' +
'
تمت الإضافة للسلة ✓
' +
'
لا تفوّت ' + CFG.NAME + '
' +
'

' +
'
' + CFG.NAME + '' +
'
' + CFG.DESC + '
' +
'
' + CFG.PRICE + '
' +
'
' +
'
' +
'
';
document.body.appendChild(root);
addBtn = root.querySelector('.mz-pkg__add');
root.addEventListener('click', function (e) {
if (e.target.closest('[data-mz-close]')) close();
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && root.classList.contains('is-open')) close();
});
addBtn.addEventListener('click', addPackage);
}
function open() {
build();
if (root.classList.contains('is-open')) return;
prevOverflow = document.documentElement.style.overflow;
document.documentElement.style.overflow = 'hidden';
root.classList.add('is-open');
addBtn.focus();
}
function close() {
if (!root) return;
root.classList.remove('is-open');
document.documentElement.style.overflow = prevOverflow;
}
function addPackage() {
if (busy) return;
if (!(window.salla && salla.cart && salla.cart.addItem)) {
window.location.href = CFG.URL;
return;
}
busy = true;
addBtn.disabled = true;
Promise.resolve(salla.cart.addItem({ id: CFG.PRODUCT_ID, quantity: 1 }))
.then(close)
.catch(function () {})
.then(function () { busy = false; addBtn.disabled = false; });
}
function onItemAdded(response, productId) {
var id = Number(
productId ||
(response && response.data && (response.data.product_id || (response.data.cart_item && response.data.cart_item.product_id))) || 0
);
if (busy || id === CFG.PRODUCT_ID) { close(); return; } // الباقة نفسها اتضافت: ما نظهرش البوب أب
try {
if (CFG.ONCE_PER_SESSION) {
if (sessionStorage.getItem('mzPkgShown')) return;
sessionStorage.setItem('mzPkgShown', '1');
}
} catch (e) {}
setTimeout(open, CFG.DELAY_MS);
}
function init() {
salla.event.on('cart::item.added', onItemAdded);
}
(function wait(n) {
if (window.salla && salla.event && salla.event.on) return init();
if (n < 100) setTimeout(function () { wait(n + 1); }, 100);
})(0);
})();