PageSourceSearch

https://www.futako-dental.com/js/common.js

js futako-dental.com collected 2026-10-06 06:15:35 UTC 3,464 bytes, 115 lines download raw bytes

1/* =========================
2   UA判定(no-webp 付与)
3========================= */
4var ua = window.navigator.userAgent.toLowerCase();
5if (
6  ua.indexOf('trident') !== -1 ||
7  (ua.indexOf('safari') !== -1 && ua.indexOf('chrome') === -1)
8) {
9  if (ua.indexOf('iphone') === -1) {
10    $('body').addClass('no-webp');
11  }
12}
13
14document.addEventListener('DOMContentLoaded', function () {
15
16  /* =========================
17     ハンバーガーメニュー
18  ========================= */
19  const menuBtn = document.querySelector('.menu-btn');
20  const fixMenu = document.querySelector('.fix-menu');
21
22  if (menuBtn && fixMenu) {
23    menuBtn.addEventListener('click', function () {
24      this.classList.toggle('active');
25      fixMenu.classList.toggle('active');
26    });
27  }
28
29  /* =========================
30     ドロップダウン(カクつき改善:実高さ height アニメ)
31     ※SPメニューが開いている時だけ動作(PCは通常遷移)
32  ========================= */
33  document.querySelectorAll('.fix-menu .dropdown > a').forEach(function (link) {
34    link.addEventListener('click', function (e) {
35
36      // ハンバーガーが存在しないページでは何もしない(JS停止防止)
37      if (!fixMenu) return;
38
39      // SPメニューが開いてない=PC扱い:リンク遷移を優先
40      if (!fixMenu.classList.contains('active')) return;
41
42      // SPメニューが開いている時だけドロップダウン開閉
43      e.preventDefault();
44
45      const parentLi = this.parentElement;
46      const menu = parentLi.querySelector('.dropdown-menu');
47      if (!menu) return;
48
49      const isOpen = parentLi.classList.contains('open');
50
51      if (isOpen) {
52        // 閉じる:現在の高さ → 0
53        const current = menu.scrollHeight;
54        menu.style.height = current + 'px';
55        menu.offsetHeight;          // reflow
56        menu.style.height = '0px';
57        parentLi.classList.remove('open');
58      } else {
59        // 開く:0 → 実高さ
60        parentLi.classList.add('open');
61
62        menu.style.height = 'auto';
63        const target = menu.scrollHeight;
64
65        menu.style.height = '0px';
66        menu.offsetHeight;          // reflow
67        menu.style.height = target + 'px';
68
69        // 開き終わったら height:auto に戻す(中身が増減しても崩れない)
70        const onEnd = function (ev) {
71          if (ev.propertyName !== 'height') return;
72          menu.style.height = 'auto';
73          menu.removeEventListener('transitionend', onEnd);
74        };
75        menu.addEventListener('transitionend', onEnd);
76      }
77    });
78  });
79
80});
81
82
83
84
85
86/* =========================
87   スムーズスクロール
88========================= */
89$('a[href^="#"]').click(function () {
90  var speed = 500;
91  var href = $(this).attr('href');
92  var target = $(href === '#' || href === '' ? 'html' : href);
93  var position = target.offset().top - 100;
94  $('html, body').animate({ scrollTop: position }, speed, 'swing');
95  return false;
96});
97
98/* =========================
99   ハッシュ付き遷移補正
100========================= */
101$(window).on('load', function () {
102  const hash = window.location.hash;
103
104  if (
105    hash === '#staff_link' ||
106    hash === '#attending_doctor_list' ||
107    hash === '#questionnaire'
108  ) {
109    const target = $(hash);
110    if (target.length) {
111      const offset = target.offset().top - 80;
112      $('html, body').animate({ scrollTop: offset }, 500);
113    }
114  }
115});

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.