/* ========================================================================== 1) 💬 زر التواصل العائم + قائمة السوشيال + طلب صيانة ========================================================================== */ (function () { 'use strict'; var CONFIG = { phone: '+966559862175', whatsapp: '966559862175', social: { instagram: 'https://instagram.com/YOUR_PAGE', twitter: 'https://x.com/YOUR_PAGE', snapchat: 'https://snapchat.com/add/YOUR_PAGE', tiktok: 'https://tiktok.com/@YOUR_PAGE', facebook: 'https://facebook.com/YOUR_PAGE' }, badgeText: '1', tooltipText: 'طلب مساعدة؟', showTooltipDelay: 2500, hideTooltipAfter: 7500, showBadgeDelay: 1500 }; function createHTML() { if (document.getElementById('chatWidget')) return; var html = `
${CONFIG.tooltipText}

تواصل معنا

اختر الطريقة المناسبة لك

اتصل بنا
واتساب
راسلنا الآن
تابعنا

طلب صيانة

املأ بياناتك وسيتم تجهيز رسالة واتساب مباشرة

سيتم فتح واتساب مع رسالة جاهزة

`; var wrap = document.createElement('div'); wrap.innerHTML = html; while (wrap.firstChild) document.body.appendChild(wrap.firstChild); } function closeMenu() { var w = document.getElementById('chatWidget'); var o = document.getElementById('chatOverlay'); if (w) w.classList.remove('open'); if (o) o.classList.remove('show'); document.body.style.overflow = ''; } function openMenu() { var w = document.getElementById('chatWidget'); var o = document.getElementById('chatOverlay'); var t = document.getElementById('chatTooltip'); var b = document.getElementById('chatBadge'); if (w) w.classList.add('open'); if (o) o.classList.add('show'); if (t) t.classList.remove('show'); if (b) b.classList.remove('show'); document.body.style.overflow = 'hidden'; } function openMaint() { closeMenu(); var el = document.getElementById('maintOverlay'); if (el) { el.classList.add('active'); document.body.style.overflow = 'hidden'; } } function closeMaint() { var el = document.getElementById('maintOverlay'); if (el) el.classList.remove('active'); document.body.style.overflow = ''; } function onSubmit(e) { e.preventDefault(); e.stopPropagation(); var name = (document.getElementById('fullName') || {}).value || ''; var phone = (document.getElementById('phone') || {}).value || ''; var city = (document.getElementById('city') || {}).value || ''; var district = (document.getElementById('district') || {}).value || ''; var product = (document.getElementById('productType') || {}).value || ''; var time = ((document.getElementById('preferredTime') || {}).value || '').trim() || 'أي وقت'; var problem = (document.getElementById('problem') || {}).value || ''; name = name.trim(); phone = phone.trim(); city = city.trim(); district = district.trim(); problem = problem.trim(); if (!name || !phone || !city || !district || !product || !problem) { alert('يرجى تعبئة جميع الحقول المطلوبة'); return; } var msg = `🔧 *طلب صيانة جديد* 👤 *الاسم:* ${name} 📱 *الجوال:* ${phone} 🏙️ *المدينة:* ${city} 📍 *الحي:* ${district} 📦 *نوع المنتج:* ${product} 🕐 *الوقت المناسب:* ${time} 📝 *وصف المشكلة:* ${problem} --- تم الإرسال من المتجر`; window.open('https://wa.me/' + CONFIG.whatsapp + '?text=' + encodeURIComponent(msg), '_blank'); closeMaint(); var f = document.getElementById('maintForm'); if (f) f.reset(); } // Event Delegation — يعمل حتى لو سلة أعادت رسم الصفحة if (!window.__npqBound) { window.__npqBound = true; document.addEventListener('click', function (e) { var t = e.target; if (t.closest('#chatToggle')) { e.preventDefault(); e.stopPropagation(); var w = document.getElementById('chatWidget'); if (w && w.classList.contains('open')) closeMenu(); else openMenu(); return; } if (t.closest('#chatOverlay')) { closeMenu(); return; } // زر طلب صيانة if (t.closest('#openMaintBtn') || t.closest('.chat-action.maintenance')) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); openMaint(); return; } if (t.closest('#closeMaintBtn')) { e.preventDefault(); closeMaint(); return; } if (t.id === 'maintOverlay') { closeMaint(); } }, true); document.addEventListener('submit', function (e) { if (e.target && e.target.id === 'maintForm') onSubmit(e); }, true); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { if (document.getElementById('maintOverlay') && document.getElementById('maintOverlay').classList.contains('active')) { closeMaint(); } else { closeMenu(); } } }); } function init() { createHTML(); var w = document.getElementById('chatWidget'); if (!w || w.dataset.npqInit === '1') return; w.dataset.npqInit = '1'; var badge = document.getElementById('chatBadge'); var tooltip = document.getElementById('chatTooltip'); if (badge) setTimeout(function () { badge.classList.add('show'); }, CONFIG.showBadgeDelay); if (tooltip) { setTimeout(function () { if (!w.classList.contains('open')) tooltip.classList.add('show'); }, CONFIG.showTooltipDelay); setTimeout(function () { tooltip.classList.remove('show'); }, CONFIG.hideTooltipAfter); } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } window.addEventListener('load', function () { setTimeout(init, 500); setTimeout(init, 1500); }); // إعادة الإنشاء لو سلة حذفت العنصر new MutationObserver(function () { if (!document.getElementById('chatWidget')) setTimeout(init, 400); }).observe(document.body, { childList: true, subtree: true }); })(); /* ========================================================================== 2) ⭐ آراء العملاء — الفقاعات + نافذة إضافة رأي ========================================================================== */ (function () { 'use strict'; /* ✏️ عدّل رقم الواتساب هنا (بدون + وبدون أصفار في البداية) */ var NPQ_WHATSAPP_NUMBER = '966559862175'; var reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; var bubblesDone = false; var selectedRating = 5; function initBubbles() { var layer = document.getElementById('npqRevBubbles'); if (!layer || bubblesDone) return !!layer; bubblesDone = true; try { if (!reduceMotion) { var count = window.innerWidth < 768 ? 4 : 8; for (var i = 0; i < count; i++) { var b = document.createElement('span'); b.className = 'npq-rev-bubble'; var s = 3 + Math.random() * 6; b.style.width = s + 'px'; b.style.height = s + 'px'; b.style.left = (Math.random() * 100) + '%'; b.style.animationDuration = (10 + Math.random() * 8) + 's'; b.style.animationDelay = (Math.random() * 8) + 's'; layer.appendChild(b); } } } catch (err) {} return true; } function renderStars() { var starPicker = document.getElementById('npqStarPicker'); if (!starPicker) return; var stars = starPicker.querySelectorAll('.npq-star'); stars.forEach(function (star) { var val = parseInt(star.getAttribute('data-star'), 10); if (val <= selectedRating) star.classList.add('active'); else star.classList.remove('active'); }); } function openModal() { var overlay = document.getElementById('npqRevOverlay'); if (!overlay) return; overlay.classList.add('active'); document.body.style.overflow = 'hidden'; renderStars(); } function closeModal() { var overlay = document.getElementById('npqRevOverlay'); if (!overlay) return; overlay.classList.remove('active'); document.body.style.overflow = ''; } function submitReview(form) { var name = (document.getElementById('npqRevName') || {}).value || ''; var city = (document.getElementById('npqRevCity') || {}).value || ''; var text = (document.getElementById('npqRevText') || {}).value || ''; name = name.trim(); city = city.trim(); text = text.trim(); if (!name || !city || !text) { alert('يرجى تعبئة جميع الحقول'); return; } var starsLine = '★'.repeat(selectedRating) + '☆'.repeat(5 - selectedRating); var msg = '⭐ *رأي جديد من عميل*\n\n' + '👤 *الاسم:* ' + name + '\n' + '🏙️ *المدينة:* ' + city + '\n' + '📊 *التقييم:* ' + starsLine + ' (' + selectedRating + '/5)\n\n' + '📝 *الرأي:*\n' + text + '\n\n' + '---\n' + 'تم الإرسال من صفحة آراء العملاء'; window.open('https://wa.me/' + NPQ_WHATSAPP_NUMBER + '?text=' + encodeURIComponent(msg), '_blank'); closeModal(); form.reset(); selectedRating = 5; renderStars(); } // Event Delegation — يعمل حتى لو العناصر انضافت بعد تحميل الصفحة أو أعاد سلة رسمها if (!window.__npqRevBound) { window.__npqRevBound = true; document.addEventListener('click', function (e) { var t = e.target; if (t.closest('#npqOpenReviewBtn')) { e.preventDefault(); openModal(); return; } if (t.closest('#npqRevCloseBtn')) { e.preventDefault(); closeModal(); return; } if (t.id === 'npqRevOverlay') { closeModal(); return; } var star = t.closest('.npq-star'); if (star && star.closest('#npqStarPicker')) { selectedRating = parseInt(star.getAttribute('data-star'), 10); renderStars(); return; } }, true); document.addEventListener('submit', function (e) { if (e.target && e.target.id === 'npqRevForm') { e.preventDefault(); submitReview(e.target); } }, true); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { var overlay = document.getElementById('npqRevOverlay'); if (overlay && overlay.classList.contains('active')) closeModal(); } }); } function init() { initBubbles(); renderStars(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } window.addEventListener('load', function () { setTimeout(init, 500); setTimeout(init, 1500); }); // إعادة المحاولة لو سلة أضافت القسم لاحقًا أو أعادت رسم الصفحة new MutationObserver(function () { if (!bubblesDone) initBubbles(); }).observe(document.documentElement, { childList: true, subtree: true }); })(); /* ========================================================================== 3) 🌊 شاشة افتتاحية (Splash Screen) — شعار نقاء الساحل (خلفية شفافة) + رسالة ترحيبية ========================================================================== */ (function () { 'use strict'; var NPQ_LOGO_B64 = 'https://cdn.files.salla.network/theme/1972536714/8747eae8-883b-44ee-a6f0-bc81c0b02f13_500x500.png'; /* ✏️ عدّل الرسالة الترحيبية هنا */ var NPQ_WELCOME_TEXT = 'أهلاً بك في نقاء الساحل 🌊'; var HOLD_MS = 1200; // مدة بقاء الشاشة ثابتة قبل بدء التلاشي var FADE_MS = 500; // مدة التلاشي (يطابق transition في CSS) // يظهر مرة واحدة فقط لكل جلسة تصفح (ما يتكرر بالتنقل بين الصفحات) try { if (sessionStorage.getItem('npqSplashShown')) return; sessionStorage.setItem('npqSplashShown', '1'); } catch (err) {} function build() { if (document.getElementById('npqSplash')) return; var el = document.createElement('div'); el.id = 'npqSplash'; el.innerHTML = '
' + 'نقاء الساحل' + '

' + NPQ_WELCOME_TEXT + '

' + '
'; var htmlEl = document.documentElement; htmlEl.style.overflow = 'hidden'; document.body.appendChild(el); setTimeout(function () { el.classList.add('npq-splash-out'); htmlEl.style.overflow = ''; }, HOLD_MS); setTimeout(function () { if (el && el.parentNode) el.parentNode.removeChild(el); }, HOLD_MS + FADE_MS + 60); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', build); } else { build(); } })();