PageSourceSearch

https://jcie.or.jp/data/themes/jcie/js/common.js?v=1744172548

js jcie.or.jp collected 2026-10-02 06:35:36 UTC 9,689 bytes, 333 lines download raw bytes

1const PC_FIXED = false;
2const SP_FIXED = true;
3const SP_WIDTH = 769;
4const SPEED = 500;
5
6// 1. スクロール関連
7
8function scrollPosition(position) {
9  let offsetFromTop = $("header");
10  position -=
11    (PC_FIXED && $(window).innerWidth() >= SP_WIDTH) ||
12    (SP_FIXED && $(window).innerWidth() < SP_WIDTH)
13      ? offsetFromTop.innerHeight()
14      : 0;
15  $("html, body").animate(
16    {
17      scrollTop: position,
18    },
19    SPEED
20  );
21}
22
23$(function () {
24  let body = $(document.body);
25  let menu_open = false;
26  let menu_btn = $(".slidemenu-btn");
27  // let menu_img = $(".slidemenu-btn").find('img'); // 画像のスライドメニューボタン
28  // let menu_txt = $(".slidemenu-btn").find('.ttl'); // テキストのスライドメニューボタン
29
30  function slidemenuOpen() {
31    // $(menu_img).attr("src", $(menu_img).attr("src").replace("menu", "close"));
32    // $(menu_txt).text("close");
33    menu_btn.addClass("active");
34    body.addClass("open");
35    body.removeAttr("style");
36    menu_open = true;
37  }
38
39  function slidemenuClose() {
40    // $(menu_img).attr("src", $(menu_img).attr("src").replace("close", "menu"));
41    // $(menu_txt).text("menu");
42    menu_btn.removeClass("active");
43    body.removeClass("open");
44    body.removeAttr("style");
45    if (top != 0) {
46      // ページ内スクロールのため
47      $(window).scrollTop(top);
48      top = 0; //リセット
49    }
50    menu_open = false;
51  }
52
53  // <a href="#top">の様に記述すると滑らかにスクロールする。
54  $('a[href*="#"]').on("click", function (e) {
55    let current = location.pathname;
56    let full_current = location.origin + current;
57    let link = $(this).attr("href").split("#")[0];
58    // トップページ及びカテゴリトップの場合は、すべてindex.htmlありとして判定する
59    // aタグは@link()#00 or #00で指定すること(aaa.html#00は動きません)
60    if (link != "") {
61      if (link.indexOf(".html") == -1) {
62        if (link.slice(-1) == "/") {
63          link += "index.html";
64        } else {
65          link += "/index.html";
66        }
67      }
68      if (full_current.indexOf(".html") == -1) {
69        if (full_current.slice(-1) == "/") {
70          full_current += "index.html";
71        } else {
72          full_current += "/index.html";
73        }
74      }
75    }
76
77    if (current === link || full_current === link || link == "") {
78      if ($(this).attr("data-href")) {
79        // tabjsとの競合回避
80        return false;
81      } else {
82        e.preventDefault();
83        slidemenuClose();
84        let position = $(this.hash).length > 0 ? $(this.hash).offset().top : 0;
85        scrollPosition(position);
86      }
87    }
88  });
89
90  // スライドメニューの開閉
91  let top = 0;
92  menu_btn.on("click", function () {
93    if (!menu_open) {
94      top = $(window).scrollTop();
95    }
96    if (body.hasClass("open")) {
97      slidemenuClose();
98    } else {
99      slidemenuOpen();
100      body.css({
101        height: window.innerHeight,
102        top: -top,
103      });
104    }
105  });
106  // PC時overlayを設置する場合
107  // $("#overlay").on("click", function () {
108  //   slidemenuClose();
109  // });
110});
111
112// 一定量スクロールするとページトップに戻るが表示される(場所等の指定はcommon.scssにて)
113$(function () {
114  let top_btn = $(".pagetop");
115  top_btn.hide();
116  $(window).scroll(function () {
117    $(this).scrollTop() > 100 ? top_btn.fadeIn() : top_btn.fadeOut();
118  });
119
120  top_btn.click(function () {
121    scrollPosition(0);
122    return false;
123  });
124
125  // 1.5秒で表示消す
126  if ($(window).innerWidth() < SP_WIDTH) {
127    var scrollStopEvent = new $.Event("scrollstop");
128    var delay = 1500;
129    var timer;
130    function scrollStopEventTrigger() {
131      if (timer) {
132        clearTimeout(timer);
133      }
134      timer = setTimeout(function () {
135        top_btn.fadeOut();
136        $(window).trigger(scrollStopEvent);
137      }, delay);
138    }
139    $(window).on("scroll", scrollStopEventTrigger);
140  }
141});
142
143// アンカーリンク付きのページ遷移をするとき:ヘッダーが固定分調整するjs
144$(window).on("load", function () {
145  if (location.hash != "" && $(location.hash).length > 0) {
146    if (
147      (PC_FIXED && $(window).innerWidth() >= SP_WIDTH) ||
148      (SP_FIXED && $(window).innerWidth() < SP_WIDTH)
149    ) {
150      let pos = $(location.hash).offset().top - $("header").innerHeight();
151      $("html, body").animate(
152        {
153          scrollTop: pos,
154        },
155        1,
156        "swing"
157      );
158    } else {
159      return false;
160    }
161  }
162});
163
164// 2. rollover(_offと末尾についた画像をオンマウスで_onとついた画像に切り替える)
165$(function () {
166  $("img").hover(
167    function () {
168      $(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
169    },
170    function () {
171      $(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
172    }
173  );
174});
175
176// 3. 横幅375px以下のviewportの設定
177new ViewportExtra(375);
178
179document.addEventListener("DOMContentLoaded", function () {
180  // タブレット端末かどうかを判定
181  var ua = navigator.userAgent.toLowerCase();
182  var isSmartPhone =
183    ua.indexOf("iphone") > -1 ||
184    (ua.indexOf("android") > -1 && ua.indexOf("mobile") > -1);
185  var isTablet =
186    !isSmartPhone &&
187    (ua.indexOf("ipad") > -1 ||
188      (ua.indexOf("android") > -1 && ua.indexOf("mobile") === -1) ||
189      (ua.indexOf("macintosh") > -1 && "ontouchend" in document));
190
191  // タブレット端末でのみ最小幅を設定
192  if (isTablet) {
193    ViewportExtra.setContent({ minWidth: 1340 });
194  }
195});
196
197// 4. httpが含まれる場合にwordbreakを付与するjs
198// 直下のテキストのみを取得するプラグイン
199$.fn.textNodeText = function () {
200  let result = "";
201  $(this)
202    .contents()
203    .each(function () {
204      if (this.nodeType === 3 && this.data) {
205        result += jQuery.trim($(this).text());
206      }
207    });
208  return result;
209};
210//httpが含まれる場合にwordbreakを付与
211$(function () {
212  $("*").each(function () {
213    let http = $(this).textNodeText();
214    if (http.match(/http/)) {
215      $(this).css("word-break", "break-all");
216    }
217  });
218});
219
220// 5. youtubeの自動レスポンシブ対応
221// iframeタグの親要素に、divタグが追加される
222$(function () {
223  $('iframe[src*="youtube"]').wrap('<div class="youtube-wrap"></div>');
224});
225
226// ------------------------------------------------------------
227// 追加分ここから
228// スライドメニューに関しては、slidemenuOpen/slidemenuCloseへ記載する
229// ------------------------------------------------------------
230
231$(function () {
232  $(".tab-list, .tab-list02").tab();
233  $(".mh").matchHeight();
234  $(".accordion").accordion();
235
236  // SNSリストホバーアニメーション
237  $(".sns-list a")
238    .mouseenter(function () {
239      $(this).addClass("fa-beat");
240    })
241    .mouseleave(function () {
242      $(this).removeClass("fa-beat");
243    });
244
245  // FAQ開閉
246  $(".acc-ttl").on("click", function () {
247    $(this).next(".acc-txt").slideToggle();
248    $(this).toggleClass("active");
249    $(this).closest("li").toggleClass("open");
250  });
251});
252let detachedHeaderTab = null; // ← 事前に宣言(nullで初期化)
253let detachedSearchTab = null;
254
255// ヘッダーナビ
256$(document).ready(function () {
257  if ($(".h-navlist02-sub").css("opacity") == 1) {
258    $(".h-navlist02-sub").siblings("p").addClass("active");
259  }
260
261  // .h-navlist02-subのtransitionが終わった時の処理
262  $(".h-navlist02-sub").on(
263    "transitionend webkitTransitionEnd oTransitionEnd",
264    function () {
265      // 透明度が0ならactiveクラスを削除、透明度が1ならactiveクラスを追加
266      if ($(this).css("opacity") == 0) {
267        $(this).siblings("p").removeClass("active");
268      } else {
269        $(this).siblings("p").addClass("active");
270      }
271    }
272  );
273
274  // TABの調整(ヘッダー、ページを探す、スライドメニュー)
275  let headerTab = $("header .nav-tab-box");
276  let headerTabTarget = $("header .show-tab-content");
277
278  let searchTab = $(".search-sec .nav-tab-box");
279  let searchTabarget = $(".search-sec .show-tab-content");
280
281  $(".common-search-btn").on("click", function () {
282    if ($(this).hasClass("close")) {
283      // detachedHeaderTab が存在する場合のみ appendTo を実行
284      if (detachedHeaderTab) {
285        detachedHeaderTab.appendTo(headerTabTarget);
286        detachedHeaderTab = null; // 状態を戻す
287      }
288    } else {
289      detachedHeaderTab = headerTab.detach();
290      setTimeout(function () {
291        $(".search-body .tab-list02 li a").first().click();
292      }, 500);
293    }
294  });
295
296  $(document).ready(function () {
297    if ($(window).width() <= 768) {
298      detachedHeaderTab = headerTab.detach();
299      detachedSearchTab = searchTab.detach();
300
301      setTimeout(function () {
302        $(".slide-menu .tab-list02 li a").first().click();
303      }, 500);
304    } else {
305      if (detachedHeaderTab) {
306        detachedHeaderTab.appendTo(headerTabTarget);
307        detachedHeaderTab = null;
308      }
309      if (detachedSearchTab) {
310        detachedSearchTab.appendTo(searchTabarget);
311        detachedSearchTab = null;
312      }
313    }
314  });
315});
316
317// ページを探す 開閉
318$(function () {
319  const searchBtn = $(".common-search-btn");
320  const searchContent = $(".common-search-area");
321
322  searchBtn.on("click", function () {
323    searchContent.toggleClass("show");
324    searchBtn.toggleClass("close");
325    if (searchContent.hasClass("show")) {
326      searchBtn.text("");
327      searchBtn.html('<i class="fa-solid fa-xmark"></i>閉じる');
328    } else {
329      searchBtn.html('<i class="fa-solid fa-list-ul"></i>ページを探す');
330    }
331    $("body").toggleClass("lock");
332  });
333});

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.