PageSourceSearch

https://sanseito.jp/nppoj/wp-content/themes/wp_310/js/pages/before_contact.js?1790587976

js sanseito.jp collected 2026-10-02 05:01:37 UTC 2,374 bytes, 85 lines download raw bytes

1/**
2 * FAQページ(/before-contact/)アコーディオン
3 * - 各設問を個別に開閉(他の設問は閉じない)
4 * - 開閉後に Lenis のスクロール範囲を再計算
5 * - ページ内リンクや URL のハッシュが設問を指す場合、その設問を自動で開く
6 * ※スクロール処理は nav-config.js/ブラウザ標準に任せ、このファイルでは行わない
7 */
8(function () {
9  'use strict';
10
11  function resetLenis() {
12    if (window.lenis && typeof window.lenis.resize === 'function') {
13      window.lenis.resize();
14    }
15  }
16
17  function safeDecode(str) {
18    try {
19      return decodeURIComponent(str);
20    } catch (err) {
21      return str;
22    }
23  }
24
25  function setItemState(item, open) {
26    var header = item.querySelector('.faq_item_header');
27    if (open) {
28      item.classList.add('active');
29    } else {
30      item.classList.remove('active');
31    }
32    if (header) {
33      header.setAttribute('aria-expanded', open ? 'true' : 'false');
34    }
35    resetLenis();
36  }
37
38  function openItemById(id) {
39    if (!id) return;
40    var target = document.getElementById(id);
41    if (target && target.classList.contains('faq_item') && !target.classList.contains('active')) {
42      setItemState(target, true);
43    }
44  }
45
46  function init() {
47    var page = document.querySelector('.faq_page');
48    if (!page) return;
49
50    var items = page.querySelectorAll('.faq_item');
51    items.forEach(function (item) {
52      var header = item.querySelector('.faq_item_header');
53      var panel = item.querySelector('.faq_item_panel');
54      if (!header) return;
55
56      header.addEventListener('click', function () {
57        setItemState(item, !item.classList.contains('active'));
58      });
59
60      if (panel) {
61        panel.addEventListener('transitionend', function (e) {
62          if (e.propertyName === 'grid-template-rows') {
63            resetLenis();
64          }
65        });
66      }
67    });
68
69    page.addEventListener('click', function (e) {
70      var link = e.target.closest('a[href^="#"]');
71      if (!link) return;
72      openItemById(safeDecode(link.getAttribute('href').slice(1)));
73    });
74
75    if (window.location.hash) {
76      openItemById(safeDecode(window.location.hash.slice(1)));
77    }
78  }
79
80  if (document.readyState === 'loading') {
81    document.addEventListener('DOMContentLoaded', init);
82  } else {
83    init();
84  }
85})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.