PageSourceSearch

https://www.thomasandfriends.jp/wp/wp-content/themes/thomasandfrie…/assets/js/thomas.common.js?2026092

js thomasandfriends.jp collected 2026-09-24 18:15:58 UTC 6,793 bytes, 250 lines download raw bytes

1"use strict";
2
3var breakPointSp = 767;
4var mql = window.matchMedia("screen and (min-width: ".concat(breakPointSp + 1, "px)"));
5mql.addListener(handleMediaQuery);
6var ua = navigator.userAgent.toLowerCase();
7
8// 画面サイズ取得
9var winWidth = window.innerWidth;
10var winHeight = window.innerHeight;
11var pcFlg;
12var $body = $('body');
13var $container = $('.l-container');
14$(function () {
15  domContentLoadEvent();
16});
17$(window).on('load', function () {
18  initLoadEvent();
19});
20$(window).on('resize', function () {
21  if (winWidth !== innerWidth) {
22    if (!pcFlg) {
23      menu.setMaxHeight();
24    }
25  }
26  winWidth = innerWidth;
27});
28
29// html読み込み完了後に実行
30function domContentLoadEvent() {
31  handleMediaQuery(mql);
32  $body = $('body');
33  $container = $('.l-container');
34  textSplit('.js-split');
35  menu.init();
36  $body.addClass('is-ready');
37  scrollEffect.init();
38}
39
40// 全てのファイル読み込み完了後に実行
41function initLoadEvent() {
42  footer.slide.init();
43  setTimeout(function () {
44    $body.addClass('is-load');
45  }, 200);
46  if (pcFlg) {
47    smoothScroll(0, 650, 'easeOutCubic');
48  } else {
49    var _headerH = $('.c-header__top').outerHeight() + 10;
50    smoothScroll(_headerH, 650, 'easeOutCubic');
51  }
52  if (scrollEffect.instance) {
53    scrollEffect.instance.Update();
54  }
55}
56
57// メディアクエリに応じて実行したい処理
58function handleMediaQuery(mql) {
59  if (mql.matches) {
60    pcFlg = true;
61  } else {
62    pcFlg = false;
63  }
64}
65var menu = {
66  spped: 350,
67  state: {
68    open: false
69  },
70  $dropDownEl: $('.js-dropdown'),
71  init: function init() {
72    var _this = this;
73    this.$dropDownEl = $('.js-dropdown');
74    $('#hamburger').on('click', function () {
75      if (menu.state.open) {
76        menu.close();
77      } else {
78        menu.open();
79      }
80    });
81    if (pcFlg) {
82      _this.pcMenu();
83    } else {
84      _this.spMenu();
85    }
86  },
87  pcMenu: function pcMenu() {
88    var _this = this;
89    var $_has_dropdown = $('.js-dropdown-trigger');
90    $_has_dropdown.on({
91      'mouseenter': function mouseenter() {
92        _this.open_dropdown($(this));
93      },
94      'mouseleave': function mouseleave() {
95        _this.close_dropdown($(this));
96      }
97    });
98  },
99  spMenu: function spMenu() {
100    var $_lg_category = $('.js-dropdown-trigger .c-gNav__menu-cell');
101    $_lg_category.on('click', function () {
102      var $_target = $(this).next('.js-dropdown');
103      $_lg_category.not(this).parents('.c-gNav__menu-item').removeClass('is-open');
104      $(this).parents('.c-gNav__menu-item').toggleClass('is-open');
105      menu.$dropDownEl.not($_target).stop().slideUp(menu.spped);
106      $_target.stop().slideToggle(menu.spped);
107    });
108    $('.c-header__bg').on('click', function () {
109      menu.close();
110    });
111    this.setMaxHeight();
112  },
113  setMaxHeight: function setMaxHeight() {
114    $('.c-header__btm').css({
115      'maxHeight': "".concat(innerHeight - $('.c-header__top').outerHeight(), "px")
116    });
117  },
118  open_dropdown: function open_dropdown(el) {
119    $(el).find('.js-dropdown').stop().slideDown(menu.spped, 'easeOutCubic');
120  },
121  close_dropdown: function close_dropdown(el) {
122    $(el).find('.js-dropdown').stop().slideUp(menu.spped, 'easeOutCubic');
123  },
124  open: function open() {
125    $body.addClass('is-menu-open');
126    this.state.open = true;
127  },
128  close: function close() {
129    $body.removeClass('is-menu-open');
130    this.state.open = false;
131
132    // 全てのドロップダウンメニューを閉じる
133    menu.$dropDownEl.stop().slideUp(0);
134  }
135};
136
137// スムーススクロール
138function smoothScroll(gap, duration, easing) {
139  var urlHash = location.hash;
140  if (urlHash) {
141    $('body,html').stop().scrollTop(0);
142    setTimeout(function () {
143      var $_target = $(urlHash);
144      if (!$_target.length) return;
145      var $_targetY = $_target.offset().top - gap;
146      $('body,html').stop().animate({
147        scrollTop: $_targetY
148      }, duration, easing);
149    }, 50);
150  }
151  $('a[href*="#"]').on('click', function () {
152    var $_target = $(this.hash);
153    if (!$_target.length) return;
154    var $_targetY = $_target.offset().top - gap;
155    $('html,body').animate({
156      scrollTop: $_targetY
157    }, duration, easing);
158    return false;
159  });
160}
161
162// text split
163function textSplit(target) {
164  var _target = document.querySelectorAll(target);
165  var _nodes = [];
166  for (var i = 0; i < _target.length; i++) {
167    _nodes.push(_target[i].childNodes);
168  }
169  var _htmlList = [];
170  for (var _i2 = 0; _i2 < _nodes.length; _i2++) {
171    var _html = [];
172    for (var index = 0; index < _nodes[_i2].length; index++) {
173      if (_nodes[_i2][index].nodeType === 3) {
174        var _text = _nodes[_i2][index].textContent;
175        var _array = _text.split('');
176        for (var _i = 0; _i < _array.length; _i++) {
177          _html.push('<span>' + _array[_i] + '</span>');
178        }
179      } else {
180        _html.push(_nodes[_i2][index].outerHTML);
181      }
182    }
183    _htmlList.push(_html);
184  }
185  $(target).each(function (index, val) {
186    $(this).html(_htmlList[index]);
187  });
188}
189function getRandomInt(min, max) {
190  return Math.floor(Math.random() * (max - min) + min);
191}
192var footer = {
193  slide: {
194    instance: undefined,
195    option: {
196      spaceBetween: 16,
197      speed: 600,
198      slidesPerView: 4,
199      loop: true,
200      navigation: {
201        nextEl: '.c-footer__bnr-slide-button-next',
202        prevEl: '.c-footer__bnr-slide-button-prev'
203      },
204      autoplay: {
205        delay: 4000,
206        disableOnInteraction: false
207      },
208      breakpoints: {
209        600: {
210          slidesPerView: 1,
211          spaceBetween: 10
212        },
213        767: {
214          slidesPerView: 2,
215          spaceBetween: 15
216        }
217      }
218    },
219    init: function init() {
220      var _this = this;
221      // 画像が4枚以上ある場合slide起動
222      if ($('.c-footer__bnr-slide-slide').length > 4) {
223        _this.instance = new Swiper('.c-footer__bnr-slide-container', _this.option);
224      } else {
225        // prev/nextボタン削除
226        $('.c-footer__bnr-slide-button-prev').hide();
227        $('.c-footer__bnr-slide-button-next').hide();
228      }
229    }
230  }
231};
232
233// スクロール演出
234var scrollEffect = {
235  instance: undefined,
236  init: function init() {
237    if ($('.js-scroll').length) {
238      var _this = this;
239      _this.instance = new SCROLL_EFFECT_MODULE({
240        elem: '.js-scroll',
241        firstElem: '.js-scroll--first',
242        displayRatio: 0.85,
243        displayReverse: false,
244        firstDelay: 0,
245        firstDelaySteps: 100,
246        addClassNameActive: 'is-active'
247      });
248    }
249  }
250};

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.