/* Add custom Js code below */
const body = document.querySelector('body');
const storefeatures = `
`;
document.addEventListener("DOMContentLoaded", () => {
if (body.classList.contains('product-single')) {
const productSingleInner = document.querySelector('.product-more-info');
productSingleInner.insertAdjacentHTML("afterend"
, storefeatures);
}
});
document.addEventListener("DOMContentLoaded", function () {
const options = document.querySelectorAll(".product-single__option, .s-product-options-wrapper");
options.forEach(function(option) {
if (option.innerHTML.includes("<")) {
option.style.display = "none";
}
});
});
document.addEventListener("DOMContentLoaded", function () {
const products = document.querySelectorAll(".product-card");
products.forEach(function (card) {
const img = card.querySelector("img");
const title = card.querySelector(".product-title"); // نحدد بناءً على العنوان
if (title && title.textContent.includes("سوار")) {
img.style.maxHeight = "200px";
img.style.width = "auto";
img.style.height = "auto";
img.style.objectFit = "contain";
img.style.display = "block";
img.style.margin = "0 auto";
}
});
});
document.addEventListener("DOMContentLoaded", function () {
const images = document.querySelectorAll('.product-card .product-card__image img');
images.forEach(function(img) {
img.style.height = 'auto';
img.style.width = '100%';
img.style.objectFit = 'contain';
img.style.display = 'block';
img.style.margin = '0 auto';
img.style.maxHeight = '300px'; // عدّل الرقم لو تبيها أكبر أو أصغر
});
const cards = document.querySelectorAll('.product-card');
cards.forEach(function(card) {
card.style.minHeight = 'unset';
card.style.height = 'auto';
card.style.padding = '10px';
});
});
target.parentElement.appendChild(slider);
}
}, 500);
});
document.addEventListener("DOMContentLoaded", function () {
// تأكد من وجود عنصر السعر في الصفحة
const priceElement = document.querySelector(".total-price");
// تأكد من أنك في الصفحة الرئيسية فقط (أو ضع شرطًا حسب الحاجة)
if (priceElement) {
// محاولة العثور على عنصر سعر ديناميكي موجود في نفس الصفحة مثل
const dynamicPrice = document.querySelector("salla-product-price");
if (dynamicPrice) {
// انتظر حتى يتم تحميل السعر من الـ component
setTimeout(() => {
const newPrice = dynamicPrice.textContent.trim();
if (newPrice) {
priceElement.innerHTML = newPrice + ' ';
}
}, 1000); // تأخير بسيط لإعطاء الوقت للـ component كي يُحمّل السعر
}
}
});
document.addEventListener("DOMContentLoaded", function () {
if (window.innerWidth <= 768) {
const section = document.querySelector("div.flex-1.grid.lg\\:grid-cols-2");
if (!section) return;
const children = section.children;
if (children.length !== 2) return;
const featured = children[0];
const others = children[1];
// نضيف كلاسات للتحكم
section.classList.add("custom-mobile-layout");
featured.classList.add("featured-mobile");
others.classList.add("others-mobile");
}
});
document.addEventListener("DOMContentLoaded", function () {
const allTitles = document.querySelectorAll(".s-slider-block__title h2");
allTitles.forEach(title => {
if (title.textContent.includes("هدايا هويتنا")) {
const parent = title.closest(".s-slider-block__title");
if (parent) {
parent.style.backgroundColor = "#00bfb3";
parent.style.padding = "20px";
parent.style.borderRadius = "8px";
parent.style.marginTop = "20px";
title.style.color = "#fff";
title.style.fontSize = "24px";
title.style.fontWeight = "bold";
title.style.textAlign = "center";
}
}
});
});
document.addEventListener("DOMContentLoaded", function () {
const allTitles = document.querySelectorAll(".s-slider-block__title h2");
allTitles.forEach(title => {
if (title.textContent.includes("هدايا هويتنا")) {
// إظهار العنوان لو كان مخفي
title.style.display = "block";
title.style.visibility = "visible";
title.style.opacity = "1";
// تنسيق الخلفية
const parent = title.closest(".s-slider-block__title");
if (parent) {
parent.style.backgroundColor = "#00bfb3"; // تركواز
parent.style.padding = "20px";
parent.style.borderRadius = "8px";
parent.style.marginTop = "20px";
}
// تنسيق الخط
title.style.color = "#fff";
title.style.fontSize = "24px";
title.style.fontWeight = "bold";
title.style.textAlign = "center";
}
});
});
document.addEventListener("DOMContentLoaded", function () {
// نبحث عن كل عناوين الأقسام
const titles = document.querySelectorAll('.s-slider-block__title h2');
titles.forEach(title => {
if (title.textContent.includes('هدايا هويتنا')) {
// نكشف العنوان لو مخفي
title.style.display = 'block';
title.style.visibility = 'visible';
title.style.opacity = '1';
// نكشف كامل قسم العنوان
const section = title.closest('.s-slider-block__title');
if (section) {
section.style.display = 'block';
section.style.visibility = 'visible';
section.style.opacity = '1';
// نضيف تنسيق الخلفية
section.style.backgroundColor = '#00bfb3';
section.style.padding = '20px';
section.style.borderRadius = '8px';
section.style.marginTop = '30px';
}
// تنسيق نص العنوان
title.style.color = '#fff';
title.style.fontSize = '24px';
title.style.fontWeight = 'bold';
title.style.textAlign = 'center';
}
});