/* Add custom Js styles below */
window.addEventListener('load', ()=> {
const body = document.querySelector('body');
/*=====================================
FUNCTION: CELEBRITY SLIDER
=====================================*/
function initCelebritySlider(mountSelector) {
const videos = [
{ id: 'kQ9zOXXm5PE', name: 'Celebrity 1' },
{ id: '4A5vKTX8dZE', name: 'Celebrity 2' },
{ id: 'icIygzCfazY', name: 'Celebrity 3' },
{ id: 'cFrtEvAYxOY', name: 'Celebrity 4' },
{ id: '_beNqQiM25M', name: 'Celebrity 5' },
{ id: 'ulesl99kkq8', name: 'Celebrity 6' }
];
function loadSwiper(callback) {
if (window.Swiper) {
callback();
return;
}
const css = document.createElement('link');
css.rel = 'stylesheet';
css.href = 'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css';
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js';
script.onload = callback;
document.head.appendChild(css);
document.head.appendChild(script);
}
function createSlider() {
const mountPoint = document.querySelector(mountSelector);
if (!mountPoint) return;
if(document.querySelector('#celebrity-video-slider')) return;
const container = document.createElement('div');
container.id = 'celebrity-video-slider';
container.innerHTML = `
شوف مشاهير العالم الي جربوها 👇
${videos.map(video=>`
▶
`).join('')}
`;
mountPoint.after(container);
container.querySelectorAll('.video-box').forEach(box=>{
box.addEventListener('click',function(){
const id=this.dataset.id;
this.innerHTML=`
`;
});
});
new Swiper(container.querySelector('.celebrity-swiper'),{
slidesPerView:3,
spaceBetween:20,
allowTouchMove:false,
navigation:{
nextEl:container.querySelector('.swiper-button-next'),
prevEl:container.querySelector('.swiper-button-prev'),
},
breakpoints:{
0:{slidesPerView:1},
640:{slidesPerView:2},
1024:{slidesPerView:3}
}
});
}
loadSwiper(createSlider);
}
/*=====================================
HOME PAGE
=====================================*/
if(body.classList.contains('index')){
const sections=document.querySelectorAll('body.index section.s-block.s-block--fixed-banner');
sections.forEach((section,index)=>{
section.classList.add(`banner-${index+1}`);
section.style.zIndex=`${99-index}`;
if(index===5){
initCelebritySlider('.banner-6');
}
});
const banner2 = document.querySelector('.banner-2 img');
banner2.src = 'https://i.ibb.co/CKV5qzQJ/Frame-1820548899-2.png';
const banner3 = document.querySelector('.banner-3 img');
banner3.src = 'https://i.ibb.co/yFJ0bfV8/Frame-1820548902-1.png';
const banner4= document.querySelector('.banner-4 img');
banner4.src = 'https://i.ibb.co/TqWbyXRr/Background-12-1-1.png';
const banner5 = document.querySelector('.banner-5 img');
banner5.src = 'https://i.ibb.co/PZfhgBzZ/Background-11.png';
const banner6 = document.querySelector('.banner-6 img');
banner6.src = 'https://i.ibb.co/GQyqxx54/Frame-1820548865-2-1.png';
const banner7 = document.querySelector('.banner-7 img');
banner7.src = 'https://i.ibb.co/3Yv8QMJ8/Frame-1820548861-1-1-2.png';
// const banner8 = document.querySelector('.banner-8 img');
// banner8.src = 'https://i.ibb.co/nsKg10Cw/Frame-1820548867-2-1.png';
const banner13 = document.querySelector('.banner-13 img');
banner13.src = 'https://i.ibb.co/zVtC1b42/Frame-1820548870-3-1-1.png';
}
/*=====================================
PRODUCT PAGE
=====================================*/
if(body.classList.contains('product-single')){
const location=window.location.href.split('/');
const last=location[location.length-1];
const clientsOpinons = `
`;
if(last==='p1341042682'){
/*=====================================
IMAGE SLIDER (SAFE VERSION)
=====================================*/
function initCelebrityImageSlider(mountSelector){
const images = [
'https://cdn.files.salla.network/homepage/932280209/d4c02021-2325-4bc0-8aab-67bd803e6051.webp',
'https://cdn.files.salla.network/homepage/932280209/0e19fc26-90aa-4495-9b38-707347fb3e4e.webp',
'https://cdn.files.salla.network/homepage/932280209/0e19fc26-90aa-4495-9b38-707347fb3e4e.webp',
'https://cdn.files.salla.network/homepage/932280209/0d3c9540-f39a-4619-8dd0-b93b545ab05a.webp',
'https://cdn.files.salla.network/homepage/932280209/352ee602-b805-4906-8ce5-e2ae0c732f3a.webp',
'https://cdn.files.salla.network/homepage/932280209/95168b36-6900-4a77-b582-f90d8244781f.webp',
'https://cdn.files.salla.network/homepage/932280209/4b11caa0-bc3f-4905-9142-3c17feeebf81.webp'
];
function loadSwiper(callback){
if(window.Swiper){
callback();
return;
}
const css=document.createElement('link');
css.rel='stylesheet';
css.href='https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css';
const script=document.createElement('script');
script.src='https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js';
script.onload=callback;
document.head.appendChild(css);
document.head.appendChild(script);
}
function createSlider(){
const mountPoint=document.querySelector(mountSelector);
if(!mountPoint) return;
// يمنع التكرار
if(mountPoint.nextElementSibling?.classList.contains('celebrity-image-slider')) return;
const container=document.createElement('div');
container.className='celebrity-image-slider';
container.innerHTML=`
${images.map(img=>`
`).join('')}
`;
mountPoint.after(container);
new Swiper(container.querySelector('.celebrity-image-swiper'),{
slidesPerView:3,
spaceBetween:20,
loop:false,
allowTouchMove:true,
navigation:{
nextEl:container.querySelector('.swiper-button-next'),
prevEl:container.querySelector('.swiper-button-prev'),
},
breakpoints:{
0:{slidesPerView:1},
640:{slidesPerView:2},
1024:{slidesPerView:3}
}
});
}
loadSwiper(createSlider);
}
const barQuantity = document.querySelector('.product-single .sticky-product-bar .sticky-product-bar__quantity');
barQuantity.style.display = 'none';
const productInfo=document.querySelector('#product-1341042682');
// https://cdn.files.salla.network/homepage/932280209/69067733-724e-4c63-af6b-ec031ded8104.webp
//
// https://cdn.files.salla.network/homepage/932280209/f83e9820-592e-4327-b73c-be06f61e77bb.webp
// https://cdn.files.salla.network/homepage/932280209/63333024-92a4-4b5b-a6da-1dbe60f92206.webp
// https://i.ibb.co/Z6nFHs7y/Frame-1820548897-1-1-1.png
const bannersSectionHTML=`
`;
productInfo.insertAdjacentHTML('afterend',bannersSectionHTML);
initCelebritySlider('.banner-17');
initCelebrityImageSlider('.banner-21')
// const sallaComments = document.querySelector('#main-content .container');
// sallaComments.insertAdjacentHTML('afterend',clientsOpinons);
}
}
});
// window.addEventListener('load', () => {
// const images = [
// 'https://b.top4top.io/p_3698ecgnz1.png',
// 'https://l.top4top.io/p_3698d2fki1.png',
// 'https://k.top4top.io/p_3698kwp391.png',
// 'https://d.top4top.io/p_3698kx3fm1.png',
// 'https://j.top4top.io/p_3698gfyu61.png',
// 'https://f.top4top.io/p_3698fkj0m1.png',
// 'https://g.top4top.io/p_3698ruqev1.png',
// 'https://i.top4top.io/p_3698hghad1.png',
// 'https://g.top4top.io/p_3698s9kwp1.png',
// 'https://f.top4top.io/p_3698snot71.png',
// 'https://l.top4top.io/p_3698j9izp1.png',
// 'https://e.top4top.io/p_3698wqeap1.png',
// 'https://h.top4top.io/p_3699qaboo1.png',
// 'https://b.top4top.io/p_36983aos51.png'
// ];
// const sections = document.querySelectorAll('body.index section.s-block.s-block--fixed-banner');
// // observer
// const observer = new IntersectionObserver((entries, obs) => {
// entries.forEach(entry => {
// if (entry.isIntersecting) {
// const section = entry.target;
// const index = section.dataset.index;
// const img = section.querySelector('.banner--fixed img');
// if (img && !img.dataset.loaded) {
// img.src = images[index] || 'https://l.top4top.io/p_3698xygm21.png';
// img.dataset.loaded = "true";
// }
// obs.unobserve(section);
// }
// });
// }, {
// rootMargin: "200px" // يبدأ التحميل قبل ما يظهر بشوية
// });
// sections.forEach((section, index) => {
// section.classList.add(`banner-${index + 1}`);
// section.style.zIndex = `${99 - index + 1}`;
// section.dataset.index = index;
// const img = section.querySelector('.banner--fixed img');
// if (img) {
// img.dataset.src = images[index];
// observer.observe(section);
// }
// });
// });
// window.addEventListener('load', () => {
// const images = [
// 'https://i.ibb.co/tPNVDHkc/Background-3.png',
// 'https://l.top4top.io/p_3698d2fki1.png',
// 'https://k.top4top.io/p_3698kwp391.png',
// 'https://d.top4top.io/p_3698kx3fm1.png',
// 'https://j.top4top.io/p_3698gfyu61.png',
// 'https://f.top4top.io/p_3698fkj0m1.png',
// 'https://g.top4top.io/p_3698ruqev1.png',
// 'https://i.top4top.io/p_3698hghad1.png',
// 'https://g.top4top.io/p_3698s9kwp1.png',
// 'https://f.top4top.io/p_3698snot71.png',
// 'https://l.top4top.io/p_3698j9izp1.png',
// 'https://e.top4top.io/p_3698wqeap1.png',
// 'https://h.top4top.io/p_3699qaboo1.png',
// 'https://b.top4top.io/p_36983aos51.png'
// ];
// const videosID = ['kQ9zOXXm5PE', 'icIygzCfazY', '4A5vKTX8dZE', 'cFrtEvAYxOY', '_beNqQiM25M', 'ulesl99kkq8'];
// const sections = document.querySelectorAll('body.index section.s-block.s-block--fixed-banner');
// // أول صورة تتحمل فوراً
// const firstImg = sections[0]?.querySelector('img');
// if (firstImg) firstImg.src = images[0];
// const observer = new IntersectionObserver((entries, obs) => {
// entries.forEach((entry, i) => {
// // if(i === 6) {
// // sections[i].classList.add('before-influencers-slider');
// // const influencersElement = document.querySelectorAll('#best-offers-7-slider .s-products-slider-card custom-salla-product-card');
// // influencersElement.forEach((element, index)=>{
// // const video = ``;
// // element.replaceWith(video);
// // });
// // }
// const influencersElement = document.querySelectorAll(
// '#best-offers-7-slider .s-products-slider-card custom-salla-product-card .s-product-card-image'
// );
// influencersElement.forEach((element, index) => {
// const iframe = document.createElement('iframe');
// iframe.src = `https://www.youtube.com/embed/${videosID[index]}`;
// iframe.loading = "lazy";
// iframe.allowFullscreen = true;
// iframe.style.width = "100%";
// iframe.style.height = "100%";
// iframe.style.border = "none";
// element.replaceWith(iframe);
// });
// if (entry.isIntersecting) {
// const section = entry.target;
// const index = section.dataset.index;
// const img = section.querySelector('img');
// if (img && !img.dataset.loaded) {
// const newImg = new Image();
// newImg.src = images[index];
// newImg.onload = () => {
// img.src = newImg.src;
// img.dataset.loaded = "true";
// };
// }
// obs.unobserve(section);
// }
// });
// }, {
// rootMargin: "300px"
// });
// sections.forEach((section, index) => {
// section.classList.add(`banner-${index + 1}`);
// section.style.zIndex = `${99 - index + 1}`;
// section.dataset.index = index;
// if (index !== 0) {
// observer.observe(section);
// }
// });
// });