Hello world!

WordPress へようこそ。こちらは最初の投稿です。編集または削除し、コンテンツ作成を始めてください。

「Hello world!」への1件のフィードバック

コメントする

で囲んで貼り付けてください。 ・JavaScriptが無効でも、FAQを含むすべての本文が読めます。 =================================================================== */ (function () { 'use strict'; var root = document.getElementById('ailand-lp'); if (!root) { return; } /* JSが動いている印。これが付いたときだけFAQが閉じます。 */ root.classList.add('is-js'); var reduceMotion = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : false; /* ========================================================= 1. FAQアコーディオン ========================================================== */ function initAccordion() { var buttons = root.querySelectorAll('.c-accordion__button'); Array.prototype.forEach.call(buttons, function (button) { var item = button.closest('.c-accordion__item'); if (!item) { return; } button.setAttribute('aria-expanded', 'false'); item.classList.remove('is-open'); button.addEventListener('click', function () { var isOpen = button.getAttribute('aria-expanded') === 'true'; button.setAttribute('aria-expanded', isOpen ? 'false' : 'true'); item.classList.toggle('is-open', !isOpen); if (!isOpen) { sendEvent('faq_open', button.textContent.trim().slice(0, 40)); } }); }); } /* ========================================================= 2. スクロールで要素をふわっと表示 (JS無効時は最初から表示されたままになります) ========================================================== */ function initReveal() { if (reduceMotion || !('IntersectionObserver' in window)) { return; } var targets = root.querySelectorAll( '.c-section-head, .c-card, .c-steps__item, ' + '.c-mini-card, .c-chain__item, .c-case-list__item, .c-fee-list__item, ' + '.c-manga-placeholder, .c-compare, .c-accordion__item, .p-awareness__col, .p-awareness__message, ' + '.p-company__figure, .p-company__message, .c-cta' ); Array.prototype.forEach.call(targets, function (el) { el.classList.add('is-reveal'); }); var observer = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (!entry.isIntersecting) { return; } var el = entry.target; var siblings = el.parentElement ? el.parentElement.children : []; var index = Array.prototype.indexOf.call(siblings, el); var delay = Math.min(index * 80, 400); el.style.transitionDelay = delay + 'ms'; el.classList.add('is-visible'); observer.unobserve(el); }); }, { threshold: 0.15 }); Array.prototype.forEach.call(targets, function (el) { observer.observe(el); }); } /* ========================================================= 3. スマホ固定CTA FVのボタンが画面外に出たら表示/最終CTAが見えたら非表示 ========================================================== */ function initFixedCta() { var fixed = document.getElementById('lp-fixed-cta'); var heroCta = document.getElementById('hero-cta'); var finalCta = document.getElementById('lp-final-cta'); if (!fixed || !heroCta || !('IntersectionObserver' in window)) { return; } var heroVisible = true; var finalVisible = false; function update() { var show = !heroVisible && !finalVisible; fixed.classList.toggle('is-visible', show); fixed.setAttribute('aria-hidden', show ? 'false' : 'true'); var link = fixed.querySelector('a'); if (link) { link.setAttribute('tabindex', show ? '0' : '-1'); } } new IntersectionObserver(function (entries) { heroVisible = entries[0].isIntersecting; update(); }, { threshold: 0 }).observe(heroCta); if (finalCta) { new IntersectionObserver(function (entries) { finalVisible = entries[0].isIntersecting; update(); }, { threshold: 0 }).observe(finalCta); } update(); } /* ========================================================= 4. ページ内リンクのスムーススクロール ========================================================== */ function initSmoothScroll() { var links = root.querySelectorAll('a[href^="#"]'); Array.prototype.forEach.call(links, function (link) { link.addEventListener('click', function (event) { var id = link.getAttribute('href'); if (!id || id === '#') { return; } var target = document.querySelector(id); if (!target) { return; } event.preventDefault(); target.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'start' }); }); }); } /* ========================================================= 5. CTAクリックの計測 GA4(gtag)またはGTM(dataLayer)がある場合だけ送信します。 ========================================================== */ function sendEvent(name, label) { if (typeof window.gtag === 'function') { window.gtag('event', name, { lp_label: label }); } if (Array.isArray(window.dataLayer)) { window.dataLayer.push({ event: name, lp_label: label }); } } function initTracking() { var items = root.querySelectorAll('[data-analytics]'); Array.prototype.forEach.call(items, function (item) { item.addEventListener('click', function () { var label = item.getAttribute('data-analytics'); var name = 'cta_click'; if (label.indexOf('phone') === 0) { name = 'phone_click'; } if (label.indexOf('line') === 0) { name = 'line_click'; } sendEvent(name, label); }); }); } /* ========================================================= 初期化 ========================================================== */ function init() { initAccordion(); initReveal(); initFixedCta(); initSmoothScroll(); initTracking(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();