Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
, hoặc enqueue file này. */ (function(){ // FAQ accordion document.addEventListener('click', function(e){ var btn = e.target.closest('.ikc-faq-q'); if(!btn) return; var item = btn.closest('.ikc-faq-item'); var open = item.classList.contains('is-open'); item.parentNode.querySelectorAll('.ikc-faq-item.is-open').forEach(function(x){ x.classList.remove('is-open'); x.querySelector('.ikc-faq-q').setAttribute('aria-expanded','false'); }); if(!open){ item.classList.add('is-open'); btn.setAttribute('aria-expanded','true'); } }); // Reveal on scroll if('IntersectionObserver' in window){ var io = new IntersectionObserver(function(en,obs){ en.forEach(function(x){ if(x.isIntersecting){ x.target.classList.add('is-in'); obs.unobserve(x.target); } }); },{rootMargin:'0px 0px -10% 0px'}); document.querySelectorAll('.ikc-reveal').forEach(function(el){ if(el.getBoundingClientRect().top < window.innerHeight*0.9) el.classList.add('is-in'); else io.observe(el); }); } else { document.querySelectorAll('.ikc-reveal').forEach(function(el){el.classList.add('is-in');}); } // Contact form -> email var form = document.getElementById('ikc-form'); if(form){ form.addEventListener('submit', function(e){ e.preventDefault(); var msg = form.querySelector('.ikc-form-msg'); var btn = form.querySelector('button[type=submit]'); var name = (form.elements.name.value||'').trim(); var phoneRaw = form.elements.phone.value||''; var phone = phoneRaw.replace(/[\s.\-()]/g,''); if(form.elements.company.value) return; function say(t, ok){ msg.textContent = t; msg.classList.toggle('is-ok', !!ok); } if(!name) return say('Vui lòng nhập họ và tên.', false); if(!/^(0|\+84)\d{9,10}$/.test(phone)) return say('Số điện thoại chưa hợp lệ. Ví dụ: 0799989889.', false); btn.disabled = true; btn.dataset.label = btn.textContent; btn.textContent = 'ĐANG GỬI…'; say('Đang gửi…', true); fetch('https://formsubmit.co/ajax/tamdnx@gmail.com',{ method:'POST', headers:{'Content-Type':'application/json',Accept:'application/json'}, body: JSON.stringify({ _subject:'Yêu cầu tư vấn điện mặt trời — '+name, _template:'table', 'Họ và tên':name, 'Số điện thoại':phoneRaw, 'Loại công trình':form.elements.type.value, 'Tiền điện hàng tháng':form.elements.bill.value, 'Nhu cầu':form.elements.need.value, 'Ghi chú':form.elements.note.value||'—' }) }).then(function(r){ if(!r.ok) throw new Error('http'); say('Đã gửi. Chúng tôi sẽ liên hệ trong thời gian sớm nhất.', true); form.reset(); }).catch(function(){ say('Không gửi được. Vui lòng gọi 0799 989 889 để được hỗ trợ ngay.', false); }).then(function(){ btn.disabled = false; btn.textContent = btn.dataset.label || 'NHẬN TƯ VẤN'; }); }); } // Header sticky + mobile menu var hd = document.getElementById('ikc-header'); if(hd){ var onScroll = function(){ hd.classList.toggle('is-solid', window.scrollY > 40); }; window.addEventListener('scroll', onScroll, {passive:true}); onScroll(); var bg = hd.querySelector('.ikc-burger'); if(bg) bg.addEventListener('click', function(){ var open = hd.classList.toggle('is-open'); bg.setAttribute('aria-expanded', open ? 'true' : 'false'); }); hd.querySelectorAll('.ikc-mobile-menu a').forEach(function(a){ a.addEventListener('click', function(){ hd.classList.remove('is-open'); }); }); } })();