PageSourceSearch

https://kurogyou.jp/_themes/site/js/site.js

js kurogyou.jp collected 2026-10-02 12:14:07 UTC 9,701 bytes, 294 lines download raw bytes

1// ページナビ SPの時削除
2$(function(){
3  const mediaQuery = window.matchMedia('(max-width: 959px)');
4  let eventElem;
5  // 関数を定義
6  function checkWindow(windowSize) {
7    if (windowSize.matches) {
8      eventElem = $("#pageNavi #globalNavi").detach();
9      console.log('PC');
10    } else {
11      $("#pageNavi").append(eventElem);
12      console.log('SP');
13    }
14  }
15  // ロード時に判定
16  checkWindow(mediaQuery);
17  // ブレイクポイントが切り替わったら判定
18  mediaQuery.addEventListener('change', checkWindow);
19  
20  // Function end
21});
22
23
24$(function() {
25  // breadCrumbs
26  if ($("#breadCrumbs ol:nth-child(2)")[0]) {
27    // パンくずリストが複数存在する場合
28    $("#breadCrumbs ol:last-of-type").prependTo("#breadCrumbs .pieceBody");
29    $("#breadCrumbs ol:not(:last-child").wrapAll('<div class="wrap"></div>');
30    $("#breadCrumbs .pieceBody").append(
31      '<div class="bc-more"><a href="#">カテゴリを全て表示する</a></div>'
32    );
33    $("#breadCrumbs .wrap").hide();
34    $("#breadCrumbs ol").show();
35    $("#breadCrumbs .bc-more a").on("click", function(e) {
36      e.preventDefault();
37      if ($(this).hasClass("active")) {
38        $(this).text("カテゴリを全て表示する");
39      } else {
40        $(this).text("カテゴリを非表示にする");
41      }
42      $(this).toggleClass("active");
43      $("#breadCrumbs .wrap").slideToggle();
44    });
45  }
46
47  // pageTop
48  var pagetop = $("#pageTop a, a[href^=#top]");
49  $(window).on("scroll", function() {
50    if ($(this).scrollTop() > 300) {
51      pagetop.fadeIn();
52    } else {
53      pagetop.fadeOut();
54    }
55  });
56  pagetop.on("click", function(e) {
57    e.preventDefault();
58    $("body,html").animate({
59        scrollTop: 0,
60      },
61      500
62    );
63    $(".nocssread a").focus();
64  });
65
66  // globalNavi
67  if ($("#globalNavi")[0]) {
68    if (window.innerWidth >= 960) {
69      var menuBtn = "";
70
71      function menuOpen(e) {
72        var self = $(e.currentTarget);
73        if (self.hasClass("open")) {
74          self.removeClass("open");
75          self.parents("li").removeClass("current");
76          self.attr("aria-expanded", "false");
77          self.parents("li").find(".subMenu").attr("aria-hidden", "true");
78        } else {
79          self.addClass("open");
80          self.parents("li").addClass("current");
81          self.attr("aria-expanded", "true");
82          self.parents("li").find(".subMenu").attr("aria-hidden", "false");
83        }
84      }
85      $("#globalNavi .subMenu").attr("aria-hidden", "true");
86      $("#globalNavi .subMenu").each(function(e) {
87        e = e + 1;
88        $(this).attr("id", "subMenu" + e);
89      });
90      $("#pageNavi #globalNavi ul.mainMenu > li > a").focusin(function(e) {
91        $("#globalNavi ul.mainMenu > li > a").removeClass("focus");
92        $(e.currentTarget).addClass("focus");
93        $("#globalNavi .subMenu").attr("aria-hidden", "true");
94        $("#globalNavi ul.mainMenu > li")
95          .removeClass("current")
96          .find("span.btn")
97          .remove();
98        var listIndex = $(this).parents("li").index();
99        listIndex = listIndex + 1;
100        $(this).after(
101          '<span class="btn"><a href="javascript:void(0);" aria-controls="subMenu' +
102          listIndex +
103          '" aria-expanded="false">下層メニューを開く</a></span>'
104        );
105        menuBtn = $(this).parent("li").find("span.btn a");
106        menuBtn.click(menuOpen);
107      });
108    } else {
109      $("#globalNavi .subMenu").attr("aria-hidden", "true");
110    }
111  }
112
113  // Function end
114});
115
116// navi toggle
117$(function () {
118  if (window.innerWidth <= 960) {
119    const acBtn = $(".accessibilityButton");
120    const acNav = $("#accessibilityTool");
121    const acNavitem = $("#accessibilityTool a");
122    const acNavBg = $(".accessibilityToolBg");
123    const drawerBtn = $(".naviButton");
124    const drawerNav = $("#hamburgerNavi");
125    const drawerNavitem = $("#hamburgerNavi a");
126    const drawerNavBg = $(".hamburgerNaviBg");
127    const body = $("body");
128
129    // メニューの表示状態を切替
130    function toggleMenuNavi(closeOnly) {
131      let isExpandedNavi = drawerBtn.attr("aria-expanded") === "true";
132      let isExpandedAc = acBtn.attr("aria-expanded") === "true";
133
134      if (closeOnly && !isExpandedNavi) {
135        return; // メニューが既に閉じている場合は何もしない
136      }
137      drawerBtn.attr("aria-expanded", !isExpandedNavi);
138      drawerBtn.attr("aria-label", "メニューを閉じる");
139      drawerNav.attr("aria-hidden", "false");
140
141      // メニューが開いている場合はbodyにスタイルを適用、閉じている場合は削除
142      if (isExpandedNavi) {
143        body.css({ height: "", overflow: "" });
144      } else if (!isExpandedNavi) {
145        body.css({ height: "100%", overflow: "hidden" });
146      }
147
148      if (isExpandedNavi) {
149        drawerBtn.attr("aria-label", "メニューを開く");
150        drawerNav.attr("aria-hidden", "true");
151      }
152      // Function toggleMenu end
153    }
154    function toggleMenuAc(closeOnly) {
155      let isExpandedNavi = drawerBtn.attr("aria-expanded") === "true";
156      let isExpandedAc = acBtn.attr("aria-expanded") === "true";
157
158      if (closeOnly && !isExpandedAc) {
159        return; // メニューが既に閉じている場合は何もしない
160      }
161
162      acBtn.attr("aria-expanded", !isExpandedAc);
163      acBtn.attr("aria-label", "アクセシビリティツールを閉じる");
164      acNav.attr("aria-hidden", "false");
165
166      // メニューが開いている場合はbodyにスタイルを適用、閉じている場合は削除
167      if (isExpandedAc) {
168        body.css({ height: "", overflow: "" });
169      } else if (!isExpandedAc) {
170        body.css({ height: "100%", overflow: "hidden" });
171      }
172
173      if (isExpandedAc) {
174        acBtn.attr("aria-label", "アクセシビリティツールを開く");
175        acNav.attr("aria-hidden", "true");
176      }
177      // Function toggleMenu end
178    }
179
180    // ハンバーガーボタンがクリックされた時のイベントハンドラ
181    drawerBtn.click(function(){
182      toggleMenuNavi();
183    });
184    acBtn.click(function(){
185      toggleMenuAc();
186    });
187
188    // #hamburgerNavi aがクリックされた時のイベントハンドラ
189    drawerNavitem.click(function(){
190      body.css({ height: "", overflow: "" });
191      drawerBtn.attr("aria-expanded", "false");
192      drawerBtn.attr("aria-label", "メニューを開く");
193      drawerNav.attr("aria-hidden", "true");
194    });
195
196    // .naviButtonがクリックされた時のイベントハンドラ
197    acBtn.click(function(){
198      drawerBtn.attr("aria-expanded", "false");
199      drawerBtn.attr("aria-label", "メニューを開く");
200      drawerNav.attr("aria-hidden", "true");
201    });
202
203    // .naviButtonがクリックされた時のイベントハンドラ
204    drawerBtn.click(function(){
205      acBtn.attr("aria-expanded", "false");
206      acBtn.attr("aria-label", "アクセシビリティツールを開く");
207      acNav.attr("aria-hidden", "true");
208    });
209
210    // .js-nav__bgがクリックされた時のイベントハンドラ
211    drawerNavBg.click(function(){
212      toggleMenuNavi(true);
213    });
214    acNavBg.click(function(){
215      toggleMenuAc(true);
216    });
217
218    // キーボードイベントハンドラを追加
219    $(document).keydown(function (e) {
220      // Escキーが押された場合、メニューを閉じる
221      if (e.key === "Escape") {
222        toggleMenuNavi(true);
223        toggleMenuAc(true);
224      }
225    });
226
227    // ナビゲーションメニューの背景にフォーカスが移った時のイベントハンドラ
228    drawerNavBg.on('focus', function () {
229      drawerBtn.focus();
230    });
231    acNavBg.on('focus', function () {
232      acBtn.focus();
233    });
234  }
235
236  // Function end
237});
238
239
240// 外部リンクにtargetやnofollow、noopenerを追記
241$(function(){
242  var website = window.location.hostname;
243  var internalLinkRegex = new RegExp('^((((http:\\/\\/|https:\\/\\/)(www\\.)?)?'
244  + website
245  + ')|(localhost:\\d{4})|(\\/.*))(\\/.*)?$', '');
246  $('a').not('#printBtn a, a[href^="tel:"], a[href^="mailto:"], #accessibilityTool a, a[href^="#"]').filter(function() {
247  var href = $(this).attr('href');
248    return !internalLinkRegex.test(href);
249  })
250  .each(function() {
251    $(this).attr('target', '_blank');
252    $(this).attr('rel', 'noopener nofollow');
253  });
254
255  // Function end
256});
257
258
259// パンくずリスト 不要なタグ削除
260$(function(){
261  const bcCategory = $('#breadCrumbs ol li a[href="/category/"]');
262  const bcCategoryBunya = $('#breadCrumbs ol li a[href="/category/bunya/"]');
263  const bcCategoryKubun = $('#breadCrumbs ol li a[href="/category/kubun/"]');
264  const bcFdkBunya = $('#breadCrumbs ol li a[href="/fdk-119/bunya/"]');
265  const bcFdkKubun = $('#breadCrumbs ol li a[href="/fdk-119/kubun/"]');
266  if(bcCategory.length){
267    bcCategory.parent().remove();
268  }
269  if(bcCategoryBunya.length){
270    bcCategoryBunya.parent().remove();
271  }
272  if(bcCategoryKubun.length){
273    bcCategoryKubun.parent().remove();
274  }
275  if(bcFdkBunya.length){
276    bcFdkBunya.parent().remove();
277  }
278  if(bcFdkKubun.length){
279    bcFdkKubun.parent().remove();
280  }
281
282  // Function end
283});
284
285
286// 記事お問い合わせのTEL、FAX名称変更
287$(function(){
288  if ($(".inquiry")[0]) {
289    $(".inquiry .tel .label").text("電話");
290    $(".inquiry .fax .label").text("ファックス");
291  }
292
293  // Function end
294});

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.