/* California Scrubs — navigation, color previews and size help */ (function(){ "use strict"; function route(p){ return location.hostname.indexOf('salla.sa') > -1 && location.pathname.indexOf('/sfot') === 0 ? '/sfot' + p : p; } function home(){ return document.querySelector('.ca-home'); } function menu(){ var target = document.querySelector( '.mobile-menu .main-menu, nav.mobile-menu ul, #mobile-menu .main-menu' ); if (!target || target.querySelector('.ca-native-menu')) return; var n = document.createElement('nav'); n.className = 'ca-native-menu'; n.setAttribute('aria-label', 'أقسام المتجر'); n.innerHTML = '' + 'سكرابالموديلان ←' + '' + '' + 'لاب كوتتسوق الآن ←' + '' + '' + 'وارمرتسوق الآن ←' + '' + '' + 'التطريز المخصصاطلب الآن ←' + '' + '' + '' + ''; target.appendChild(n); } function init(){ menu(); document.querySelectorAll('a[href*="wa.me/508516668"]').forEach(function(a){ a.href = a.href.replace( 'wa.me/508516668', 'wa.me/966508516668' ); }); var root = home(); if (root && !root.dataset.caReady){ root.dataset.caReady = '1'; root.querySelectorAll('a[href^="/"]').forEach(function(a){ a.setAttribute('href', route(a.getAttribute('href'))); }); document.body.classList.toggle( 'ca-only-scrubs', location.hash === '#ca-scrub-models' ); } } init(); var queued = false; new MutationObserver(function(){ if (queued) return; queued = true; requestAnimationFrame(function(){ queued = false; init(); }); }).observe(document.documentElement, { childList: true, subtree: true }); document.addEventListener('DOMContentLoaded', init, {once: true}); window.addEventListener('hashchange', function(){ document.body.classList.toggle( 'ca-only-scrubs', location.hash === '#ca-scrub-models' ); }); })(); /* California Scrubs — Style category pages: show every product assigned to each category. */ (function(){ 'use strict'; var stylePages = { '60392763': { title: 'سكراب طبي — ستايل 1' }, '295608529': { title: 'سكراب طبي — ستايل 2' }, '1007910163': { title: 'لابكوت طبي — ستايل 1' }, '1647730194': { title: 'لابكوت طبي — ستايل 2' } }; var busy = false; function applyStylePage(){ if (busy) return; var hit = location.pathname.split('/').filter(Boolean).pop(); var cat = hit && hit.charAt(0) === 'c' ? hit.slice(1) : ''; var config = stylePages[cat]; if (!config) return; busy = true; try { document.documentElement.classList.add('ca-style-category'); document.documentElement.dataset.caStyle = cat; var title = document.querySelector('main h1'); if (title && title.textContent.trim() !== config.title){ title.textContent = config.title; } var crumb = document.querySelector('main nav li:last-child'); if (crumb && crumb.textContent.trim() !== config.title){ crumb.textContent = config.title; } [].slice.call( document.querySelectorAll( 'main salla-products-list custom-salla-product-card[hidden]' ) ).forEach(function(card){ card.hidden = false; }); var oldPlaceholder = document.querySelector('.ca-style-placeholder'); if (oldPlaceholder){ oldPlaceholder.remove(); } } finally { busy = false; } } applyStylePage(); document.addEventListener( 'DOMContentLoaded', applyStylePage, {once: true} ); new MutationObserver(function(){ requestAnimationFrame(applyStylePage); }).observe(document.documentElement, { childList: true, subtree: true }); })(); /* California Scrubs — interactive homepage colour preview */ (function(){ "use strict"; var colors = { "الرمادي": { src: "https://cdn.files.salla.network/products/278511394/a48922fe-bd05-4828-a428-88959042710c-original.webp", alt: "سكراب ستايل 2 باللون الرمادي" }, "السماوي الفاتح": { src: "https://cdn.files.salla.network/products/278511394/369ce2c0-06cf-4548-9b93-798aae9f7ad0-original.webp", alt: "سكراب ستايل 2 باللون السماوي الفاتح" }, "الأزرق الملكي": { src: "https://cdn.files.salla.network/products/278511394/8bb1fd57-b8c9-4e41-8821-411ef5fada8b-original.webp", alt: "سكراب موديل 2 باللون الأزرق الملكي" }, "ستيل بلو": { src: "https://cdn.files.salla.network/products/278511394/4b4772f5-352a-4021-8af0-173928ee09fb-original.webp", alt: "سكراب ستايل 2 باللون ستيل بلو" }, "الكحلي": { src: "https://cdn.files.salla.network/products/278511394/ca9e56d7-abda-4b08-b7ef-4336744120c1-original.webp", alt: "سكراب ستايل 2 باللون الكحلي" } }; Object.keys(colors).forEach(function(k){ var p = new Image(); p.src = colors[k].src; }); function setup(){ var title = document.getElementById("ca-color-title"); var section = title && title.closest("section"); if (!section) return; var image = section.querySelector("img"); if (!image) return; var controls = section.querySelectorAll( "button,[role=button],input[type=radio],input[type=checkbox]" ); controls.forEach(function(control){ var name = ( control.getAttribute("aria-label") || control.textContent || "" ).trim(); if (!colors[name] || control.dataset.caColorReady) return; control.dataset.caColorReady = "1"; function choose(){ var item = colors[name]; image.src = item.src; image.removeAttribute("srcset"); image.setAttribute("data-src", item.src); image.alt = item.alt; controls.forEach(function(c){ c.classList.remove("is-active"); if (c.matches("button,[role=button]")){ c.setAttribute("aria-pressed", "false"); } }); control.classList.add("is-active"); if (control.matches("button,[role=button]")){ control.setAttribute("aria-pressed", "true"); } var leaves = section.querySelectorAll( "span,strong,b,small,p" ); for (var i = 0; i < leaves.length; i++){ if ( (leaves[i].textContent || "").trim() in colors && !leaves[i].querySelector("*") ){ leaves[i].textContent = name; break; } } } control.addEventListener("click", choose); control.addEventListener("change", choose); }); } setup(); document.addEventListener( "DOMContentLoaded", setup, {once: true} ); new MutationObserver(function(){ requestAnimationFrame(setup); }).observe(document.documentElement, { childList: true, subtree: true }); })(); /* California Scrubs — unified accordion navigation */ (function(){ 'use strict'; function route(p){ return location.hostname.indexOf('salla.sa') > -1 && location.pathname.indexOf('/sfot') === 0 ? '/sfot' + p : p; } function build(menu){ if (!menu || menu.dataset.caAccordionReady) return; menu.dataset.caAccordionReady = '1'; menu.innerHTML = '