PageSourceSearch

https://kato-iin.info/style/js/common.js?20261005184200

js kato-iin.info collected 2026-10-05 09:42:15 UTC 11,702 bytes, 387 lines download raw bytes

1// hamburger menu
2const baseElement = document.getElementById("js-hamburgerMenu");
3baseElement.addEventListener("click", function () {
4  baseElement.classList.toggle("u-hamburgerMenu__animated");
5  document.querySelector("#js-header__navi").classList.toggle("is-show");
6  document.body.classList.toggle("menu-open");
7
8  const expanded = baseElement.getAttribute("aria-expanded") === "false";
9  baseElement.setAttribute("aria-expanded", expanded ? "true" : "false");
10});
11
12// サブメニューが存在する項目にクラス追加
13document.addEventListener("DOMContentLoaded", function () {
14  const subMenus = document.querySelectorAll(".l-header__subMenu");
15  subMenus.forEach(function (subMenu) {
16    const parentNaviItem = subMenu.closest(".l-header__naviItem");
17    if (parentNaviItem) {
18      parentNaviItem.classList.add("is-have-subMenu");
19    }
20  });
21});
22
23// sp - サブメニューを持つ項目のリンクを無効にする
24function isWideEnough() {
25  return window.innerWidth <= 767;
26}
27const naviItems = document.querySelectorAll(".l-header__naviItem");
28naviItems.forEach(function (naviItem) {
29  const subMenu = naviItem.querySelector(".l-header__subMenu");
30  if (subMenu) {
31    const linkElement = naviItem.querySelector("a");
32
33    if (linkElement) {
34      linkElement.addEventListener("click", function (event) {
35        if (isWideEnough()) {
36          event.preventDefault();
37        }
38      });
39    }
40  }
41});
42
43// sp - subMenu アコーディオン
44document.addEventListener("DOMContentLoaded", function () {
45  const subLinks = document.querySelectorAll(".is-have-subMenu a");
46
47  subLinks.forEach(function (subLink) {
48    subLink.addEventListener("click", function () {
49      const subMenu = subLink.nextElementSibling;
50      if (subMenu && subMenu.classList.contains("l-header__subMenu")) {
51        subMenu.classList.toggle("is-active");
52        subLink.classList.toggle("is-active");
53      }
54    });
55  });
56});
57
58// PC - スクロール時ヘッダー固定
59function checkScroll() {
60  const header = document.querySelector(".l-header");
61  const scrollY = window.scrollY;
62  const windowWidth = window.innerWidth;
63
64  if (windowWidth >= 767) {
65    if (scrollY > 1000) {
66      header.classList.add("js-fixed");
67    } else {
68      header.classList.remove("js-fixed");
69    }
70  }
71}
72window.addEventListener("scroll", checkScroll);
73
74// ブレイクポイント通過時にリロード
75const breakpoint = window.matchMedia("(max-width:767px)");
76breakpoint.addEventListener("change", () => {
77  window.location.reload();
78});
79
80// アンカーリンクの位置調整
81$(function () {
82  const height = window.innerWidth >= 768 ? 280 : 100;
83
84  function scrollToAnchor(targetSelector, animate = true) {
85    const target = $(targetSelector);
86    if (target.length) {
87      const position = target.offset().top - height;
88      if (animate) {
89        const speed = 600;
90        $("body,html").animate({ scrollTop: position }, speed, "swing");
91      } else {
92        $("html, body").scrollTop(position);
93      }
94    }
95  }
96
97  if (window.location.hash) {
98    scrollToAnchor(window.location.hash, false);
99  }
100
101  $('a[href^="#"]')
102    .not('a[href="#!"]')
103    .click(function () {
104      const href = $(this).attr("href");
105      scrollToAnchor(href == "#" || href == "" ? "html" : href);
106      return false;
107    });
108});
109
110// top - main slider
111$(document).ready(function () {
112  if ($(".p-mainVisual__slideWrapper").length > 0) {
113    $(".p-mainVisual__slideWrapper").slick({
114      slidesToShow: 1,
115      fade: true,
116      autoplay: true,
117      autoplaySpeed: 4000,
118      arrows: false,
119    });
120  }
121});
122
123function updatePseudoSlides(slick, currentSlide) {
124  if (window.matchMedia("(min-width: 768px)").matches) {
125    let prevIndex = (currentSlide - 1 + slick.slideCount) % slick.slideCount;
126    let nextIndex = (currentSlide + 1) % slick.slideCount;
127
128    let prevImg = $('.slick-slide[data-slick-index="' + prevIndex + '"] img').attr('src');
129    let nextImg = $('.slick-slide[data-slick-index="' + nextIndex + '"] img').attr('src');
130
131    $('.pseudo-prev').css({ 'background-image': 'url(' + prevImg + ')', 'opacity': '1' });
132    $('.pseudo-next').css({ 'background-image': 'url(' + nextImg + ')', 'opacity': '1' });
133  } else {
134    $('.pseudo-prev, .pseudo-next').css({ 'opacity': '0' });
135  }
136}
137
138// ページ読み込み時に前後のスライドを設定(PCのみ)
139$('.p-mainVisual__slideWrapper').on('init', function (event, slick) {
140  updatePseudoSlides(slick, 0);
141});
142
143// スライド切り替え時に前後のスライドを設定(PCのみ)
144$('.p-mainVisual__slideWrapper').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
145  updatePseudoSlides(slick, nextSlide);
146});
147
148// nav - カレント付与
149document.addEventListener("DOMContentLoaded", function () {
150  // メインメニューの処理
151  const bodyId = document.body.id;
152
153  if (bodyId) {
154    const targetNavItem = document.querySelector(
155      `.l-header__naviItem.--${bodyId}`
156    );
157    if (targetNavItem) {
158      targetNavItem.classList.add("current");
159    }
160  }
161
162  // ローカルナビゲーションの処理
163  const currentUrl = window.location.pathname;
164  const localNavItems = document.querySelectorAll(".c-localNav__item a");
165  localNavItems.forEach(function (localNavItem) {
166    const localLinkUrl = localNavItem.getAttribute("href");
167
168    if (!localLinkUrl.startsWith("http") && !localLinkUrl.includes("#")) {
169      let absoluteLocalLinkUrl;
170      if (localLinkUrl.startsWith("/")) {
171        absoluteLocalLinkUrl = new URL(localLinkUrl, window.location.origin)
172          .pathname;
173      } else {
174        const currentPathWithoutFilename = currentUrl.substring(
175          0,
176          currentUrl.lastIndexOf("/") + 1
177        );
178        absoluteLocalLinkUrl = new URL(
179          localLinkUrl,
180          window.location.origin + currentPathWithoutFilename
181        ).pathname;
182      }
183
184      if (currentUrl === absoluteLocalLinkUrl) {
185        localNavItem.parentElement.classList.add("current");
186      }
187    }
188  });
189});
190
191// top お知らせのないときにクラス付与
192document.addEventListener("DOMContentLoaded", function () {
193  if (document.body.id === "home") {
194    var pointWrapElements = document.querySelectorAll(".pointWrap");
195    pointWrapElements.forEach(function (element) {
196      if (!element.querySelector(".point")) {
197        element.parentElement.classList.add("--point-none");
198      }
199    });
200  }
201});
202
203// top 新着情報 - <dd>が連続した場合にクラス付与
204document.addEventListener("DOMContentLoaded", function () {
205  const ddElements = document.querySelectorAll(".p-topNewsList dd");
206
207  for (let i = 1; i < ddElements.length; i++) {
208    if (ddElements[i].previousElementSibling.tagName.toLowerCase() === "dd") {
209      ddElements[i].classList.add("continuous");
210    }
211  }
212});
213
214// ページトップに戻るボタン
215document.addEventListener("DOMContentLoaded", function () {
216  const pagetop = document.getElementById("js-pageTop");
217
218  pagetop.addEventListener("click", function (e) {
219    e.preventDefault();
220    window.scrollTo({
221      top: 0,
222      behavior: "smooth",
223    });
224  });
225});
226
227// PC - 右下固定ボタン
228document.addEventListener("DOMContentLoaded", function () {
229  const footerButton = document.querySelector(".l-footer__buttonWrapper");
230
231  window.addEventListener("scroll", function () {
232    if (window.scrollY > 1000) {
233      footerButton.classList.add("is-show");
234    } else {
235      footerButton.classList.remove("is-show");
236    }
237  });
238});
239document.addEventListener('DOMContentLoaded', function () {
240  const pageTopBtn = document.getElementById('js-pageTop');
241
242  // 初期設定
243  pageTopBtn.style.opacity = '0';
244  pageTopBtn.style.transition = 'opacity 0.5s';
245  pageTopBtn.style.pointerEvents = 'none'; // 非表示中はクリック無効にする
246
247  window.addEventListener('scroll', function () {
248    if (window.scrollY > 1000) {
249      pageTopBtn.style.opacity = '1';
250      pageTopBtn.style.pointerEvents = 'auto';
251    } else {
252      pageTopBtn.style.opacity = '0';
253      pageTopBtn.style.pointerEvents = 'none';
254    }
255  });
256
257  // スムーススクロール(任意)
258  pageTopBtn.addEventListener('click', function (e) {
259    e.preventDefault();
260    window.scrollTo({
261      top: 0,
262      behavior: 'smooth'
263    });
264  });
265});
266
267// SP - マップを営業時間下に移動
268document.addEventListener("DOMContentLoaded", function () {
269  function moveMap() {
270    const map = document.querySelector(".l-footer__map");
271    const hoursWrapper = document.querySelector(".l-footer__addressWrapper");
272
273    if (window.innerWidth <= 767) {
274      if (map && hoursWrapper) {
275        hoursWrapper.after(map);
276      }
277    }
278  }
279  moveMap();
280});
281
282// 採用情報 - 項目数3つ以上でクラス追加
283document.addEventListener("DOMContentLoaded", function () {
284  const footerRecruit = document.querySelector(".c-footerRecruit");
285  if (footerRecruit) {
286    const buttons = footerRecruit.querySelectorAll(".c-footerRecruit__button");
287    if (buttons.length >= 3) {
288      footerRecruit.classList.add("--2column");
289    }
290  }
291});
292//料金表アコーディオン
293(function () {
294  "use strict";
295
296  var DURATION = 220; // アニメーション速度(ms)
297
298  document.addEventListener("DOMContentLoaded", function () {
299    var titles = document.querySelectorAll("h4.priceTitle");
300
301    titles.forEach(function (title) {
302      var panel = getNextElement(title);
303
304      // 直後が .priceContent のときだけ対象(誤爆防止)
305      if (!panel || !panel.classList.contains("priceContent")) return;
306
307      // クリックできるように(a11y寄り)
308      title.style.cursor = "pointer";
309      title.setAttribute("role", "button");
310      title.setAttribute("aria-expanded", "false");
311
312      // 初期表示がすでに開いているケースがあれば同期
313      if (isVisible(panel)) {
314        title.classList.add("is-open");
315        title.setAttribute("aria-expanded", "true");
316      }
317
318      title.addEventListener("click", function () {
319        var isOpen = title.classList.contains("is-open");
320
321        if (isOpen) {
322          closePanel(title, panel);
323        } else {
324          openPanel(title, panel);
325        }
326      });
327    });
328  });
329
330  function getNextElement(el) {
331    var next = el.nextSibling;
332    while (next && next.nodeType !== 1) next = next.nextSibling; // ELEMENT_NODE
333    return next;
334  }
335
336  function isVisible(el) {
337    return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
338  }
339
340  function openPanel(title, panel) {
341    title.classList.add("is-open");
342    title.setAttribute("aria-expanded", "true");
343
344    panel.style.display = "block";
345    panel.style.overflow = "hidden";
346    panel.style.height = "0px";
347
348    // 強制リフロー
349    panel.offsetHeight;
350
351    var targetHeight = panel.scrollHeight;
352    panel.style.transition = "height " + DURATION + "ms ease";
353    panel.style.height = targetHeight + "px";
354
355    window.setTimeout(function () {
356      panel.style.height = "";
357      panel.style.overflow = "";
358      panel.style.transition = "";
359    }, DURATION);
360  }
361
362  function closePanel(title, panel) {
363    title.classList.remove("is-open");
364    title.setAttribute("aria-expanded", "false");
365
366    if (!isVisible(panel)) {
367      panel.style.display = "none";
368      return;
369    }
370
371    panel.style.overflow = "hidden";
372    panel.style.height = panel.scrollHeight + "px";
373
374    // 強制リフロー
375    panel.offsetHeight;
376
377    panel.style.transition = "height " + DURATION + "ms ease";
378    panel.style.height = "0px";
379
380    window.setTimeout(function () {
381      panel.style.display = "none";
382      panel.style.height = "";
383      panel.style.overflow = "";
384      panel.style.transition = "";
385    }, DURATION);
386  }
387})();

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.