/* Three Lines Productions: تفاعلات الموقع */ (function () { var WA = '966558492766'; var PREVIEW = /preview\.salla\.design$/.test(location.hostname); /* في رابط المعاينة نخلي روابط الأقسام على نفس الصفحة */ var HOME = PREVIEW ? '' : '/'; var STORE = 'https://th-plus.com'; var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; var LOGO = 'THREELINESPRODUCTIONS'; function logo(a) { if (!a || a.querySelector('.tlp-logo')) return; Array.prototype.forEach.call(a.querySelectorAll('img, h3'), function (el) { el.style.display = 'none'; }); var s = document.createElement('span'); s.className = 'tlp-logo'; s.innerHTML = LOGO; a.appendChild(s); a.setAttribute('aria-label', 'Three Lines Productions'); } function header() { logo(document.querySelector('a.site-header__brand, .store-header a.navbar-brand')); var menu = document.querySelector('nav.site-header__mainmenu, .store-header custom-main-menu'); if (menu && !document.querySelector('.tlp-nav')) { var nav = document.createElement('nav'); nav.className = 'tlp-nav'; nav.innerHTML = 'الرئيسيةأعمالناالباقاتالأسئلةاحجز موعدك'; menu.parentNode.insertBefore(nav, menu.nextSibling); } footer(); } /* قائمة الجوال الجانبية: روابط الموقع الجديدة بدل تصنيفات وصفحات المتجر القديمة */ function drawer() { var root = document.querySelector('.site-nav-drawer-root'); if (!root) return; logo(root.querySelector('a.site-nav-drawer__brand')); var list = root.querySelector('ul.site-nav-drawer__list'); if (!list || list.querySelector('.tlp-dl')) return; [['', 'الرئيسية'], ['#tlp-work', 'أعمالنا'], ['#tlp-plans', 'الباقات'], ['#tlp-faq', 'الأسئلة الشائعة'], ['#tlp-policy', 'سياسة الحجز والإلغاء'], ['#tlp-book', 'احجز موعدك']].forEach(function (it) { var li = document.createElement('li'), a = document.createElement('a'); li.className = 'tlp-dl'; a.className = 'site-nav-drawer__link'; a.href = HOME + it[0]; a.textContent = it[1]; a.addEventListener('click', function () { var c = root.querySelector('.site-nav-drawer__close'); if (c) c.click(); }); li.appendChild(a); list.appendChild(li); }); if (!root.getAttribute('data-tlp-obs') && window.MutationObserver) { root.setAttribute('data-tlp-obs', '1'); new MutationObserver(function () { try { drawer(); } catch (e) {} }).observe(root, { childList: true, subtree: true }); } } function footer() { /* الفوتر يتكرر داخل نافذة "حسابي" في الجوال، فنعالج كل النسخ */ Array.prototype.forEach.call(document.querySelectorAll('.store-footer'), footerOne); Array.prototype.forEach.call(document.querySelectorAll('a.store-footer__logo'), logo); sheetLinks(); } var FLINKS = [['#tlp-plans', 'الباقات'], ['#tlp-work', 'أعمالنا'], ['#tlp-faq', 'الأسئلة الشائعة'], ['#tlp-policy', 'سياسة الحجز والإلغاء'], ['#tlp-book', 'احجز موعدك']]; /* نافذة "روابط مهمة" في الجوال: نفس روابط الفوتر الجديدة */ function sheetLinks() { Array.prototype.forEach.call(document.querySelectorAll('.s-menu-footer-list'), function (list) { if (list.closest('.store-footer__links') || list.querySelector('.tlp-fl')) return; FLINKS.forEach(function (it) { var a = document.createElement('a'); a.className = 's-menu-footer-item tlp-fl'; a.href = HOME + it[0]; a.textContent = it[1]; a.addEventListener('click', function () { var r = list.closest('.bottom-sheet-root'), c = r && r.querySelector('.bottom-sheet__close'); if (c) c.click(); }); list.appendChild(a); }); }); } function footerOne(f) { var desc = f.querySelector('.store-footer__desc'); if (desc && !desc.getAttribute('data-tlp')) { desc.setAttribute('data-tlp', '1'); desc.textContent = 'نؤمن أن اللحظات الحلوة تستحق أن تدوم. نوثّق تفاصيل مناسباتكم في الرياض بكل حب، صورة وفيديو، لتبقى ذكرى جميلة للأبد.'; } var links = f.querySelector('.store-footer__links'); if (links && !links.querySelector('.tlp-flinks')) { Array.prototype.forEach.call(links.children, function (c) { if (c.tagName !== 'H3') c.style.display = 'none'; }); var d = document.createElement('div'); d.className = 'tlp-flinks'; d.innerHTML = 'الباقاتأعمالناالأسئلة الشائعةسياسة الحجز والإلغاءاحجز موعدك'; links.appendChild(d); } Array.prototype.forEach.call(f.querySelectorAll('a[href*="instagram.com"]'), function (a) { a.href = 'https://www.instagram.com/threelinepro'; }); Array.prototype.forEach.call(f.querySelectorAll('a[href*="x.com"], a[href*="twitter.com"]'), function (a) { (a.closest('li') || a).style.display = 'none'; }); var bottom = f.querySelector('.store-footer__bottom') || f; var tw = document.createTreeWalker(bottom, NodeFilter.SHOW_TEXT), tn; while ((tn = tw.nextNode())) { if (tn.nodeValue.indexOf('TH+') > -1) tn.nodeValue = tn.nodeValue.replace('TH+', 'Three Lines Productions'); } } function home() { var root = document.getElementById('tlp-home'); if (!root || root.getAttribute('data-on')) return; root.setAttribute('data-on', '1'); root.classList.add('tlp-js'); /* ظهور عند التمرير + عدّاد السعر */ function count(el) { var to = parseInt(el.getAttribute('data-count'), 10), t0 = null; if (reduce || !to) return; function step(t) { if (!t0) t0 = t; var p = Math.min((t - t0) / 1400, 1), e = 1 - Math.pow(1 - p, 3); el.textContent = Math.round(to * e).toLocaleString('en-US'); if (p < 1) requestAnimationFrame(step); } requestAnimationFrame(step); } var items = root.querySelectorAll('[data-r]'); if ('IntersectionObserver' in window) { var io = new IntersectionObserver(function (es) { es.forEach(function (e) { if (!e.isIntersecting) return; e.target.classList.add('is-in'); var c = e.target.querySelector('[data-count]'); if (c) count(c); io.unobserve(e.target); }); }, { threshold: 0.15 }); items.forEach(function (el) { io.observe(el); }); } else { items.forEach(function (el) { el.classList.add('is-in'); }); } /* عدّاد التسجيل */ var tc = document.getElementById('tlp-tc'), sec = 0; if (tc && !reduce) setInterval(function () { sec++; var h = Math.floor(sec / 3600), m = Math.floor(sec / 60) % 60, s = sec % 60; tc.textContent = [h, m, s].map(function (n) { return (n < 10 ? '0' : '') + n; }).join(':'); }, 1000); /* إضاءة تتبع المؤشر في الهيرو */ var hero = root.querySelector('.tlp-hero'); if (hero && !reduce) hero.addEventListener('pointermove', function (e) { var r = hero.getBoundingClientRect(); hero.style.setProperty('--mx', (e.clientX - r.left) + 'px'); hero.style.setProperty('--my', (e.clientY - r.top) + 'px'); }); /* ميلان بطاقات الباقات */ if (!reduce && window.matchMedia('(hover:hover) and (min-width:861px)').matches) { root.querySelectorAll('.tlp-plan').forEach(function (card) { card.addEventListener('pointermove', function (e) { var r = card.getBoundingClientRect(); var x = (e.clientX - r.left) / r.width - 0.5, y = (e.clientY - r.top) / r.height - 0.5; card.style.setProperty('--ry', (x * 7).toFixed(2) + 'deg'); card.style.setProperty('--rx', (-y * 7).toFixed(2) + 'deg'); }); card.addEventListener('pointerleave', function () { card.style.setProperty('--ry', '0deg'); card.style.setProperty('--rx', '0deg'); }); }); } /* عارض الصور */ var shots = Array.prototype.slice.call(root.querySelectorAll('.tlp-shot')); var lb = document.createElement('div'), cur = 0; lb.className = 'tlp-lb'; lb.innerHTML = ''; document.body.appendChild(lb); var lbImg = lb.querySelector('img'); function src(i) { var bg = getComputedStyle(shots[i].querySelector('i')).backgroundImage; return bg.replace(/^url\(["']?/, '').replace(/["']?\)$/, ''); } function show(i) { cur = (i + shots.length) % shots.length; lbImg.src = src(cur); lbImg.alt = shots[cur].textContent.trim(); lb.classList.add('on'); } function hide() { lb.classList.remove('on'); } shots.forEach(function (f, i) { f.addEventListener('click', function () { show(i); }); f.addEventListener('keydown', function (e) { if (e.key === 'Enter') show(i); }); }); lb.addEventListener('click', function (e) { if (e.target.classList.contains('tlp-lb-p')) show(cur - 1); else if (e.target.classList.contains('tlp-lb-n')) show(cur + 1); else if (e.target !== lbImg) hide(); }); document.addEventListener('keydown', function (e) { if (!lb.classList.contains('on')) return; if (e.key === 'Escape') hide(); if (e.key === 'ArrowLeft') show(cur - 1); if (e.key === 'ArrowRight') show(cur + 1); }); /* نموذج الحجز: يجهز رسالة واتساب */ var send = document.getElementById('tlp-f-send'); function val(id) { var el = document.getElementById(id); return el ? el.value.trim() : ''; } function build() { var lines = ['السلام عليكم، أبغى أحجز ' + val('tlp-f-plan')]; if (val('tlp-f-date')) lines.push('تاريخ المناسبة: ' + val('tlp-f-date')); if (val('tlp-f-place')) lines.push('المكان: ' + val('tlp-f-place')); if (val('tlp-f-note')) lines.push('ملاحظات: ' + val('tlp-f-note')); send.href = 'https://wa.me/' + WA + '?text=' + encodeURIComponent(lines.join('\n')); } if (send) { ['tlp-f-plan', 'tlp-f-date', 'tlp-f-place', 'tlp-f-note'].forEach(function (id) { var el = document.getElementById(id); if (el) { el.addEventListener('input', build); el.addEventListener('change', build); } }); send.addEventListener('click', build); build(); } /* روابط الدفع مكتوبة كاملة على دومين المتجر؛ لو تغيّر الدومين لاحقًا تتبعه تلقائيًا */ try { var su = String(window.salla && salla.config.get('store.url') || '').replace(/\/$/, ''); if (su && su !== STORE && !PREVIEW) root.querySelectorAll('a[href^="' + STORE + '/"]').forEach(function (a) { a.href = su + a.getAttribute('href').slice(STORE.length); }); } catch (e) {} /* روابط الدفع: في المعاينة تروح لصفحة الباقة على المتجر نفسه */ if (PREVIEW) root.querySelectorAll('a[href^="/"]').forEach(function (a) { a.href = STORE + a.getAttribute('href'); a.target = '_blank'; }); /* وعدنا: الكلمات تضيء والخطوط الثلاثة تكتمل مع التمرير */ var sayBox = root.querySelector('.tlp-say'), say = root.querySelector('.tlp-say-t'), words = []; if (sayBox && say && !reduce) { var parts = say.textContent.trim().split(/\s+/); say.textContent = ''; parts.forEach(function (p, i) { var w = document.createElement('span'); w.className = 'w'; w.textContent = p; say.appendChild(w); if (i < parts.length - 1) say.appendChild(document.createTextNode(' ')); words.push(w); }); } function sayMove() { if (!words.length) return; var r = sayBox.getBoundingClientRect(), vh = window.innerHeight; if (r.bottom < -80 || r.top > vh + 80) return; var p = Math.max(0, Math.min(1, (vh * 0.82 - r.top) / (vh * 0.32 + r.height / 2))); var n = Math.round(p * words.length); words.forEach(function (w, i) { w.classList.toggle('on', i < n); }); for (var k = 0; k < 3; k++) sayBox.style.setProperty('--p' + (k + 1), Math.max(0, Math.min(1, p * 3 - k)).toFixed(3)); } /* شريط التقدم + حركة الخطوط مع التمرير */ var prog = document.createElement('div'); prog.className = 'tlp-prog'; document.body.appendChild(prog); var lines = root.querySelectorAll('.tlp-line'), ticking = false; function onMove() { ticking = false; var max = document.documentElement.scrollHeight - window.innerHeight; prog.style.transform = 'scaleX(' + (max > 0 ? Math.min(window.scrollY / max, 1) : 0) + ')'; sayMove(); if (!reduce && window.scrollY < window.innerHeight * 1.2) { lines.forEach(function (l, i) { l.style.setProperty('--py', (window.scrollY * (0.04 + i * 0.05)).toFixed(1) + 'px'); }); } } window.addEventListener('scroll', function () { if (!ticking) { ticking = true; requestAnimationFrame(onMove); } }, { passive: true }); onMove(); /* مؤشر دائري فوق صور المعرض */ if (!reduce && window.matchMedia('(hover:hover) and (min-width:861px)').matches) { var ring = document.createElement('div'); ring.className = 'tlp-cur'; ring.textContent = 'عرض'; document.body.appendChild(ring); var grid = root.querySelector('.tlp-grid'); if (grid) { var ringOff = function () { ring.classList.remove('on'); }; grid.addEventListener('pointermove', function (e) { if (lb.classList.contains('on')) return; ring.style.left = e.clientX + 'px'; ring.style.top = e.clientY + 'px'; ring.classList.add('on'); }); grid.addEventListener('pointerleave', ringOff); grid.addEventListener('click', ringOff); window.addEventListener('scroll', ringOff, { passive: true }); window.addEventListener('blur', ringOff); } /* أزرار تنجذب للمؤشر */ root.querySelectorAll('.tlp-hero .tlp-btn, .tlp-end .tlp-btn').forEach(function (b) { b.addEventListener('pointermove', function (e) { var r = b.getBoundingClientRect(); b.style.translate = ((e.clientX - r.left - r.width / 2) * 0.18).toFixed(1) + 'px ' + ((e.clientY - r.top - r.height / 2) * 0.3).toFixed(1) + 'px'; }); b.addEventListener('pointerleave', function () { b.style.translate = '0 0'; }); }); } /* الأسئلة: سؤال واحد مفتوح في كل مرة */ var qs = root.querySelectorAll('.tlp-faq details'); qs.forEach(function (d) { d.addEventListener('toggle', function () { if (d.open) qs.forEach(function (o) { if (o !== d) o.open = false; }); }); }); /* زر الحجز الثابت في الجوال */ var sticky = document.getElementById('tlp-sticky'), book = document.getElementById('tlp-book'); if (sticky && hero && book) { var onScroll = function () { var past = hero.getBoundingClientRect().bottom < 0; var atBook = book.getBoundingClientRect().top < window.innerHeight * 0.7; sticky.classList.toggle('on', past && !atBook); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); } } /* بيانات منظمة لمحركات البحث */ function ld(id, data) { if (document.getElementById(id)) return; var s = document.createElement('script'); s.type = 'application/ld+json'; s.id = id; s.textContent = JSON.stringify(data); document.head.appendChild(s); } function schema() { var o = location.origin; ld('tlp-ld-biz', { '@context': 'https://schema.org', '@type': 'ProfessionalService', name: 'Three Lines Productions', description: 'تصوير أعراس ومناسبات في الرياض: تصوير فوتوغرافي وفيديو وتصوير جوي بالدرون مع مونتاج احترافي.', url: o + '/', telephone: '+966558492766', image: 'https://cdn.files.salla.network/products/543900639/4ac568c4-7c27-4047-9a0b-ac93aa6ac65c-standard.webp', address: { '@type': 'PostalAddress', addressLocality: 'الرياض', addressCountry: 'SA' }, areaServed: { '@type': 'City', name: 'الرياض' }, sameAs: ['https://www.instagram.com/threelinepro'], makesOffer: [ { '@type': 'Offer', name: 'الباقة الأولى: تغطية احترافية للحفلات والأعراس', price: '3000', priceCurrency: 'SAR', url: o + '/تصوير-اعراس-الرياض-الباقة-الاولى/p460538359' }, { '@type': 'Offer', name: 'الباقة الثانية: تغطية مميزة مع تصوير جوي', price: '4000', priceCurrency: 'SAR', url: o + '/تصوير-اعراس-درون-الرياض-الباقة-الثانية/p250161208' } ] }); var qs = document.querySelectorAll('#tlp-home .tlp-faq details'); if (qs.length) ld('tlp-ld-faq', { '@context': 'https://schema.org', '@type': 'FAQPage', mainEntity: Array.prototype.map.call(qs, function (d) { return { '@type': 'Question', name: d.querySelector('summary').textContent.trim(), acceptedAnswer: { '@type': 'Answer', text: d.querySelector('p').textContent.trim() } }; }) }); Array.prototype.forEach.call(document.querySelectorAll('#tlp-home .tlp-shot'), function (f) { if (!f.getAttribute('aria-label')) { f.setAttribute('role', 'img'); f.setAttribute('aria-label', 'تصوير أعراس الرياض: ' + f.textContent.trim()); } }); } function init() { try { header(); } catch (e) {} try { drawer(); } catch (e) {} try { home(); } catch (e) {} try { if (!PREVIEW) schema(); } catch (e) {} } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init(); window.addEventListener('load', init); /* قائمة الجوال تُبنى عند أول فتح، فنراقب إضافتها للصفحة */ function watchDrawer() { if (!document.body || document.body.getAttribute('data-tlp-dw')) return; document.body.setAttribute('data-tlp-dw', '1'); if (window.MutationObserver) new MutationObserver(function () { try { drawer(); } catch (e) {} }).observe(document.body, { childList: true }); var again = function () { try { drawer(); } catch (e) {} try { footer(); } catch (e) {} }; document.addEventListener('click', function (e) { /* أي أيقونة إنستغرام في المتجر تفتح حساب Three Lines مهما تأخر تحميلها */ var ig = e.target && e.target.closest && e.target.closest('a[href*="instagram.com"]'); if (ig) ig.href = 'https://www.instagram.com/threelinepro'; [60, 400, 1500, 3500].forEach(function (ms) { setTimeout(again, ms); }); }, true); } if (document.body) watchDrawer(); else document.addEventListener('DOMContentLoaded', watchDrawer); /* عناصر سلة تظهر بعد تحميل الصفحة، فنعيد المحاولة لثوانٍ */ var tries = 0, timer = setInterval(function () { init(); if (++tries > 40) clearInterval(timer); }, 300); })();