PageSourceSearch

https://www.gaiainc.jp/wp-content/themes/gaiathemes/network/src_20…/common/scroll-hint-init.js?ver=1756735691

js gaiainc.jp collected 2026-10-08 23:28:36 UTC 3,998 bytes, 110 lines download raw bytes

1// ScrollHint 初期化
2// 対象: 横スクロールが想定される要素に .js-scrollable を付与しておく(既存DOMでもOK)
3// 参考: https://github.com/ignorant-ghost/scroll-hint
4
5
6(function () {
7  function ready(fn) {
8    if (document.readyState === 'loading') {
9      document.addEventListener('DOMContentLoaded', fn);
10    } else {
11      fn();
12    }
13  }
14
15  function ensureCss() {
16    var has = Array.prototype.some.call(
17      document.styleSheets,
18      function (s) { return (s.href || '').indexOf('scroll-hint') !== -1; }
19    );
20    if (has) return Promise.resolve();
21    return new Promise(function (resolve) {
22      var link = document.createElement('link');
23      link.rel = 'stylesheet';
24      link.href = (window.scrollHintLocalBase || '') + '/vendor/scroll-hint/scroll-hint.css';
25      link.onload = resolve;
26      link.onerror = resolve; // CSS失敗でも続行
27      document.head.appendChild(link);
28      console.log('append link', link);
29    });
30  }
31
32  function loadScript(url) {
33    return new Promise(function (resolve, reject) {
34      var s = document.createElement('script');
35      s.src = url;
36      s.defer = true;
37      s.onload = resolve;
38      s.onerror = reject;
39      document.head.appendChild(s);
40      console.log('append script', s);
41    });
42  }
43
44  function initScrollHint() {
45    if (window.__scrollHintInitialized) return;
46    window.__scrollHintInitialized = true;
47
48    // 既存のポイントセクション内の横スクロール領域を初期化
49    var targets = document.querySelectorAll(
50      '.p-sec-point__ctt__list__item__ft__table, .p-sec-point__ctt__list__item__ft__img, .p-sec-point__ctt__list__item__ft__img2'
51    );
52    targets.forEach(function (el) { el.classList.add('js-scrollable'); });
53
54    var DEBUG_STICKY = false; // 本番: デバッグ無効(必要時のみ true )
55    var sh = new ScrollHint('.js-scrollable', {
56      i18n: { scrollable: 'スクロールできます' },
57      // アコーディオン内で非表示のままタイムアウトしないよう、時間経過で消さない
58      remainingTime: -1,
59      applyToParents: false
60    });
61    try { window.__scrollHintInstance = sh; } catch (e) {}
62
63    // 画像やフォントの遅延読み込み後に判定を再実行
64    if (typeof window !== 'undefined') {
65      window.addEventListener('load', function () {
66        try { sh.updateItems && sh.updateItems(); } catch (e) {}
67      });
68      setTimeout(function () {
69        try { sh.updateItems && sh.updateItems(); } catch (e) {}
70      }, 400);
71    }
72  }
73
74  ready(function () {
75    // ローカルベースURLを算出(/wp-content/themes/.../network/src_202508)
76    try {
77      var cs = document.currentScript && document.currentScript.src;
78      if (cs) {
79        var u = new URL(cs, window.location.href);
80        var p = u.pathname; // /wp-content/themes/gaiathemes/network/src_202508/js/common/scroll-hint-init.js
81        var key = '/network/src_202508/';
82        var idx = p.indexOf(key);
83        if (idx !== -1) {
84          window.scrollHintLocalBase = u.origin + p.slice(0, idx + key.length - 1); // 末尾は /network/src_202508
85        }
86      }
87    } catch (e) {}
88
89    // 対象要素が無ければ何もしない(不要ページでは読み込まない)
90    var hasTargets = document.querySelector(
91      '.p-sec-point__ctt__list__item__ft__table, .p-sec-point__ctt__list__item__ft__img, .p-sec-point__ctt__list__item__ft__img2'
92    );
93    if (!hasTargets) return;
94
95    // ライブラリ未ロード時のみローカルから動的ロード
96    if (typeof ScrollHint === 'undefined') {
97      ensureCss().then(function(){
98        return loadScript((window.scrollHintLocalBase || '') + '/vendor/scroll-hint/scroll-hint.min.js');
99      }).then(function(){
100        if (typeof ScrollHint !== 'undefined') initScrollHint();
101      }).catch(function(){
102        // 失敗時は黙ってスキップ
103      });
104    } else {
105      ensureCss().then(initScrollHint);
106    }
107  });
108})();
109
110

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.