//section
document.addEventListener('DOMContentLoaded', function () {
const path = window.location.pathname.replace(/\/+$/, '');
if (path !== '' && path !== '/index.html') return;
// سكشن (OUR PRODUCTS)
const photosSlider = document.querySelector('.s-block.s-block--photos-slider');
if (photosSlider) addAnimatedHeading(photosSlider, 'afterend', 'تسوق حسب الأقسام', 'ef-our-products-heading', 'blink');
});
function addAnimatedHeading(target, position, text, className, animName) {
const heading = document.createElement('h2');
heading.className = className;
document.head.insertAdjacentHTML('beforeend', `
`);
target.insertAdjacentElement(position, heading);
let i = 0;
let isDeleting = false;
let widthLocked = false;
function typeLoop() {
const current = text.substring(0, i);
heading.textContent = current;
if (!widthLocked && i === text.length) {
heading.style.width = heading.offsetWidth + 'px';
widthLocked = true;
}
if (!isDeleting && i < text.length) {
i++;
setTimeout(typeLoop, 150);
} else if (isDeleting && i > 1) {
i--;
setTimeout(typeLoop, 100);
} else {
if (!isDeleting) {
isDeleting = true;
setTimeout(typeLoop, 1500);
} else {
isDeleting = false;
setTimeout(typeLoop, 800);
}
}
}
typeLoop();
}
// سكشن مختصر عن قهوة بيشة العربية (قهوة + بهارات + طرق الدفع)
document.addEventListener("DOMContentLoaded", function () {
if (window.location.pathname !== "/" && window.location.pathname !== "/index.html") {
return;
}
const section = document.createElement("section");
section.className = "bisha-mini-section";
section.innerHTML = `
نكهات الأصالة... من بيشة إلى فنجانك
في قهوة بيشة العربية نحرص على تقديم مزيج فريد يجمع بين القهوة الأصيلة، والبهارات الغنية، وخيارات دفع مريحة تضمن تجربة تسوق لا تُنسى.
قهوة بيشة
حبوب مختارة بعناية، تعبّر عن الذوق السعودي الأصيل وتُحمّص لتناسب جميع الأذواق.
بهاراتنا المميزة
نقدم مجموعة متنوعة من البهارات الفاخرة والهيل والزعفران الأصلي.
طرق دفع آمنة
مدى – Apple Pay – STC Pay – الدفع عند الاستلام بكل سهولة وأمان.
`;
// تحديد مكان الإدراج
const testimonialsSection = document.querySelector(".s-block--testimonials");
if (testimonialsSection) {
testimonialsSection.parentNode.insertBefore(section, testimonialsSection);
} else {
document.body.appendChild(section);
}
// توليد الدواير الخلفية
const circlesContainer = section.querySelector(".floating-circles");
for (let i = 0; i < 12; i++) {
const span = document.createElement("span");
const size = 4 + Math.random() * 10;
span.style.width = `${size}px`;
span.style.height = `${size}px`;
span.style.top = `${Math.random() * 100}%`;
span.style.left = `${Math.random() * 100}%`;
span.style.animationDelay = `${Math.random() * 4}s`;
span.style.animationDuration = `${3 + Math.random() * 3}s`;
span.style.opacity = `${0.1 + Math.random() * 0.4}`;
circlesContainer.appendChild(span);
}
// إضافة CSS
const style = document.createElement("style");
style.textContent = `
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css');
:root {
--main-color: #053E77;
--second-color: #4387E8;
--third-color: #f5f5f5;
--fourth-color: #fff;
--orange-color: #4A3350;
}
.bisha-mini-section {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
color: var(--fourth-color);
background-color: var(--main-color);
direction: rtl;
overflow: hidden;
border-radius: 12px;
margin-top: 50px;
padding: 40px 20px;
}
.floating-circles {
position: absolute;
inset: 0;
overflow: hidden;
z-index: 0;
}
.floating-circles span {
position: absolute;
border-radius: 50%;
background: var(--second-color);
animation: floatMove 5s infinite ease-in-out alternate;
}
@keyframes floatMove {
0% { transform: translate(0, 0) scale(1); }
50% { transform: translate(10px, -10px) scale(1.1); }
100% { transform: translate(-10px, 10px) scale(1); }
}
.bisha-mini-image {
flex: 1;
max-width: 350px;
position: relative;
z-index: 1;
}
.bisha-mini-image img {
width: 100%;
height: auto;
object-fit: cover;
border-radius: 15px;
display: block;
margin: auto;
}
.bisha-mini-content {
flex: 1;
min-width: 50%;
z-index: 2;
padding: 20px 30px;
text-align: right;
}
.bisha-mini-title {
font-size: 26px;
font-weight: 700;
color: #EFD7B5;
margin-bottom: 15px;
}
.bisha-mini-desc {
font-size: 16px;
color: var(--third-color);
margin-bottom: 30px;
line-height: 1.8;
}
.bisha-mini-boxes {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
.bisha-mini-box {
display: flex;
align-items: flex-start;
gap: 15px;
}
.bisha-mini-box i {
font-size: 24px;
color: #EFD7B5;
flex-shrink: 0;
margin-top: 5px;
}
.bisha-mini-box h3 {
margin: 0;
font-size: 17px;
color: #fff;
}
.bisha-mini-box p {
margin: 5px 0 0;
font-size: 14px;
color: var(--third-color);
line-height: 1.6;
}
@media (max-width: 768px) {
.bisha-mini-section {
flex-direction: column;
padding: 30px 15px;
}
.bisha-mini-image {
margin-bottom: 25px;
max-width: 280px;
}
.bisha-mini-title {
font-size: 22px;
}
.bisha-mini-desc {
font-size: 15px;
}
}
`;
document.head.appendChild(style);
});
/* Add custom Js styles below */
// إ Font Awesome
const fa = document.createElement("link");
fa.rel = "stylesheet";
fa.href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css";
fa.crossOrigin = "anonymous";
fa.referrerPolicy = "no-referrer";
document.head.appendChild(fa);
//end icons
document.addEventListener("DOMContentLoaded", function () {
const priceElement = document.querySelector('.s-product-card-price');
const iconElement = document.querySelector('.s-button-btn');
if (priceElement && iconElement) {
priceElement.parentNode.insertBefore(iconElement, priceElement.nextSibling);
}
const styleTag = document.createElement("style");
styleTag.innerHTML = `
.enhanced-card {
opacity: 0;
transform: translateY(50px);
transition: all 0.6s ease;
}
.enhanced-card.visible {
opacity: 1 !important;
transform: translateY(0) !important;
}
`;
document.head.appendChild(styleTag);
function checkVisibility() {
document.querySelectorAll(".s-product-card-entry").forEach(product => {
const rect = product.getBoundingClientRect();
if (rect.top < window.innerHeight * 0.9 && rect.bottom >= 0) {
product.classList.add("visible");
} else {
product.classList.remove("visible");
}
});
}
function enhanceCards() {
document.querySelectorAll('.s-product-card-entry').forEach(card => {
// منع الازدواجية
if (card.querySelector('.stars')) return;
// نجوم التقييم
const stars = document.createElement('div');
stars.className = 'stars';
const rating = Math.floor(Math.random() * 2) + 4;
stars.style.setProperty('--rating', `${(rating / 5) * 100}%`);
card.querySelector('.s-product-card-content-main')?.appendChild(stars);
const badge = document.createElement('div');
badge.className = 'product-badge';
const badges = [
{ text: 'جديد ', bg: '#053E77' },
{ text: 'حصري ', bg: '#053E77' },
{ text: 'اشترِ الآن ', bg: '#053E77' },
{ text: 'حديثًا ', bg: '#053E77' }
];
const selected = badges[Math.floor(Math.random() * badges.length)];
badge.textContent = selected.text;
badge.style.cssText = `
position: absolute;
top: 10px; right: 10px;
background-color: ${selected.bg};
color: white;
padding: 4px 8px;
border-radius: 0.3rem;
font-size: 0.7rem;
font-weight: bold;
z-index: 10;
`;
card.style.position = 'relative';
card.classList.add('enhanced-card');
card.appendChild(badge);
});
}
let tries = 0;
const interval = setInterval(() => {
enhanceCards();
checkVisibility();
if (++tries > 10) clearInterval(interval);
}, 500);
window.addEventListener("scroll", checkVisibility);
});
// =========== 👆 BACK TO TOP BUTTON =========
const backToTopButton = document.createElement("div");
backToTopButton.id = "backToTop";
backToTopButton.innerHTML = `