PageSourceSearch

https://www.cando-web.co.jp/js/common.js?20250609_1

js cando-web.co.jp collected 2026-10-03 19:01:04 UTC 55,895 bytes, 1,696 lines download raw bytes

1(function ($) {
2  'use strict';
3
4// PC/SP判定
5// スクロールイベント
6// リサイズイベント
7// スムーズスクロール
8
9  /* ここから */
10  var break_point = 767; //ブレイクポイント(767px以下でSP)
11  var mql = window.matchMedia('screen and (max-width: '+break_point+'px)');//、MediaQueryListの生成
12  var deviceFlag = mql.matches ? 1 : 0; // 0 : PC ,  1 : SP
13
14
15// vh取得
16  const setVh = () => {
17    const vh = window.innerHeight * 0.01;
18    document.documentElement.style.setProperty('--vh', `${vh}px`);
19  };
20  const setVhOnLoad = () => {
21    const vh = window.innerHeight * 0.01;
22    document.documentElement.style.setProperty('--vh-onload', `${vh}px`);
23  };
24  window.addEventListener('load', setVh);
25  window.addEventListener('resize', setVh);
26  window.addEventListener('load', setVhOnLoad);
27
28
29  // URLのパラメータを取得
30  var pub_get_parameter = location.search.substring(1);
31  var pub_param_array = {};
32  // URLにパラメータが存在する場合
33  if(pub_get_parameter) {
34    // 「&」が含まれている場合は「&」で分割
35    var param = pub_get_parameter.split('&');
36
37    // 用意した配列にパラメータを格納
38    for (var i = 0; i < param.length; i++) {
39      var paramItem = param[i].split('=');
40      pub_param_array[paramItem[0]] = paramItem[1];
41    }
42  }
43
44// pagetop
45  var timer = null;
46  var $pageTop = $('#pagetop');
47  $pageTop.hide();
48
49// スクロールイベント
50  $(window).on('scroll touchmove', function () {
51
52    // スクロール中か判定
53    if (timer !== false) {
54      clearTimeout(timer);
55    }
56
57    // 200ms後にフェードイン
58    timer = setTimeout(function () {
59      if ($(this).scrollTop() > 100) {
60        $('#pagetop').fadeIn('normal');
61      } else {
62        $pageTop.fadeOut();
63      }
64    }, 200);
65
66    var scrollHeight = $(document).height();
67    var scrollPosition = $(window).height() + $(window).scrollTop();
68    var footHeight = parseInt($('#footer').innerHeight());
69
70
71    if ( deviceFlag === 0 ) { // → PC
72      if ( scrollHeight - scrollPosition  <= footHeight - 15 ) {
73        // 現在の下から位置が、フッターの高さの位置にはいったら
74        $pageTop.css({
75          'position':'absolute',
76          'top': -100,
77          'bottom': 'unset'
78        });
79      } else {
80        $pageTop.css({
81          'position':'fixed',
82          'bottom': 10,
83          'top': 'unset'
84        });
85      }
86    } else {
87      if ( scrollHeight - scrollPosition  <= footHeight - 15 ) {
88        // 現在の下から位置が、フッターの高さの位置にはいったら
89        $pageTop.css({
90          'position':'absolute',
91          'top': -70,
92          'bottom': 'unset'
93        });
94      } else {
95        $pageTop.css({
96          'position':'fixed',
97          'bottom': 10,
98          'top': 'unset'
99        });
100      }
101    }
102
103  });
104
105// リサイズイベント
106
107  const change_tabindex_768 = function() {
108    const footer = $('.c-footer');
109    const footerBtn = footer.find('.js-aco-btn');
110    const footerList = footer.find('.sub-link');
111
112    if(window.innerWidth > break_point){
113      footerBtn.each(function() {
114        $(this).removeAttr('aria-expanded');
115      });
116      footerList.each(function() {
117        $(this).removeAttr('aria-hidden');
118      })
119    } else {
120      footerBtn.each(function() {
121        $(this).attr('aria-expanded', 'false');
122      })
123      footerList.each(function() {
124        $(this).attr('aria-hidden', 'true');
125      })
126    }
127  } // tab
128
129  var checkBreakPoint = function (mql) {
130    deviceFlag = mql.matches ? 1 : 0;// 0 : PC ,  1 : SP
131    // → PC
132    if (deviceFlag == 0) {
133      change_tabindex_768();
134    } else {
135      // →SP
136      change_tabindex_768();
137    }
138    deviceFlag = mql.matches;
139  }
140
141// ブレイクポイントの瞬間に発火
142  mql.addListener(checkBreakPoint);//MediaQueryListのchangeイベントに登録
143
144// 初回チェック
145  checkBreakPoint(mql);
146
147
148/* TABサイズ用
149------------------------------*/
150  var break_point2 = 1024; //ブレイクポイント(1024px以下でtab_min)
151  var mql2 = window.matchMedia('screen and (max-width: '+break_point2+'px)');//、MediaQueryListの生成
152  var deviceFlag2 = mql2.matches ? 1 : 0; // 0 : PC ,  1 : SP
153
154  // tabindexの制御
155  const change_tabindex = function() {
156    if(window.innerWidth > break_point2){ // tab
157      $('.c-nav').find('a, button').attr('tabindex', '0');
158      $('.c-nav .sp-aco-area:not(.mega-menu-wrap) .js-aco-cont').find('a, button').attr('tabindex', '-1');
159      $('.js-support_popup button').attr('tabindex', '-1');
160
161      $('.c-nav .nav-list > li > .btn').attr('tabindex', '0');
162      $('[href^=tel]').attr('tabindex', '-1');
163
164      // 読み上げ制御(PC時に表示しないメガメニュー要素を読み上げないように)
165      $('.c-nav .sp-aco-area:not(.mega-menu-wrap) .js-aco-cont').attr('aria-hidden', 'true');
166
167      $('.c-nav .nav-list .btn span').attr('aria-hidden', 'true');
168
169
170    } else { // tab_min
171      $('.c-nav').find('a, button').attr('tabindex', '-1');
172      $('.c-nav .sp-aco-area .js-aco-cont').find('a, button').attr('tabindex', '-1');
173
174      $('.c-nav').attr('tabindex', '-1');
175      $('.c-nav').attr('aria-hidden', true);
176      $('[href^=tel]').attr('tabindex', '-1');
177
178      // 読み上げ制御(読み上げに含む)
179      $('.c-nav .sp-aco-area .js-aco-cont').attr('aria-hidden', 'true');
180
181      $('.c-nav .nav-list .btn span').removeAttr('aria-hidden');
182    }
183  }
184
185  // リサイズイベント
186  var checkBreakPoint2 = function (mql2) {
187    deviceFlag2 = mql2.matches ? 1 : 0;// 0 : tab ,  1 : tab_min
188    // → tab
189    if (deviceFlag == 0) {
190      change_tabindex();
191    } else {
192      // →tab_min
193      change_tabindex();
194    }
195    deviceFlag2 = mql2.matches;
196  }
197
198// ブレイクポイントの瞬間に発火
199  mql2.addListener(checkBreakPoint2);//MediaQueryListのchangeイベントに登録
200
201// 初回チェック
202  checkBreakPoint2(mql2);
203
204  // ★初期読み込み時★tabindexの制御
205  $(function(){
206    if($('.c-header')[0]){
207      change_tabindex();
208    }
209  });
210
211
212/* get url
213------------------------------*/
214  var pagePath = location.pathname,
215      pageDir = pagePath.substring(0, pagePath.lastIndexOf('/')) + '/',
216      pageHash = location.hash,
217      domain = window.location.protocol + '//' + window.location.host;
218
219/* smooth scroll
220------------------------------*/
221  var scrollSpeed = 500;
222
223  $(function(){
224    /* current page */
225    $('a[href*="#"]').each(function() {
226      var href = $(this).attr('href'),
227          path = href.replace(domain, ''),
228          dir = path.substring(0, path.lastIndexOf('/')) + '/',
229          hash = href.match(/#.+$/);
230
231      // 完全一致したらhrefをハッシュのみにする
232      if (hash && pageDir === dir) {
233        $(this).attr('href', hash);
234      }
235    });
236
237    /* other page */
238    if (pageHash) { $('body,html').stop().scrollTop(0); }
239  });
240
241  $(window).on('load',function(){
242    /* smooth scroll on current page */
243    $('a[href^="#"]').on('click', function () {
244      var href = $(this).attr('href'),
245          hash = href.match(/#.+$/);
246      var target = $(href == '#' || href == '' ? 'html' : href);
247      var headerHeight = $('.c-header').outerHeight();
248      var position = target.offset().top - headerHeight;
249      $('body,html').stop().animate({scrollTop: position}, scrollSpeed, 'swing');
250
251      $(target).attr('tabindex', '0');
252      target.focus();
253      return false;
254    });
255
256    /* smooth scroll on other page */
257    // リロード・ブラウザバックを除く
258    if (window.performance.navigation.type === 0) {
259      if (pageHash) {
260        setTimeout(function(){
261          var position = $(pageHash).offset().top - $('.c-header').outerHeight();
262          $('body,html').stop().animate({scrollTop:position}, scrollSpeed, 'swing');
263        }, 600);
264      }
265    }
266  });
267
268/* menu
269------------------------------*/
270  /* scroll control
271  ------------------------------*/
272  var isScrollable = true;
273  var winScroll;
274  var getScrollPos = function () {
275    if (!isScrollable) {
276      return;
277    }
278    winScroll = window.scrollY || window.pageYOffset;
279  }
280
281  $(window).on('scroll touchmove', function () {
282    getScrollPos();
283  });
284
285  function scrollOff() {
286    $('body').css({
287      'position': 'fixed',
288      'width': '100%',
289      'top': -winScroll
290    });
291    $('body').addClass('is-fixed');
292    isScrollable = false;
293  };
294  function scrollOn() {
295    $('body').css({
296      'position': '',
297      'top': ''
298    });
299    $('body').removeClass('is-fixed');
300    window.scrollTo(0, winScroll);
301    isScrollable = true;
302  };
303
304  /* menu
305  ------------------------------*/
306  function menuClose() {
307    $('.c-header').removeClass('is-open');
308    $('.c-nav').removeClass('is-open');
309    $('.c-nav-btn').removeClass('is-open');
310  };
311  function menuOpen() {
312    $('.c-header').addClass('is-open');
313    $('.c-nav').addClass('is-open');
314    $('.c-nav-btn').addClass('is-open');
315  };
316
317  /* menu開閉 */
318  $('body').on('click', '.c-nav-btn', function() {
319    if ($('.c-nav-btn').hasClass('is-open')) {
320      scrollOn();
321      menuClose();
322      $(this).attr('aria-expanded', 'false');
323
324      $('.c-nav').attr('aria-hidden', 'true');
325      $('.c-nav').attr('tabindex', '-1');
326      $('.c-nav .nav-list').find('.aco-btn, .btn, .acc-btn, .sp-nav-wrap a').attr('tabindex', '-1');
327      $('.c-nav .nav-list').find('.sub-nav-list a').attr('tabindex', '-1');
328
329      $('.c-nav').find('.sp-nav-wrap a').attr('tabindex', '-1');
330
331    } else {
332      scrollOff();
333      menuOpen();
334      $(this).attr('aria-expanded', 'true');
335
336      $('.c-nav').attr('aria-hidden', 'false');
337      $('.c-nav').attr('tabindex', '0');
338      $('.c-nav .nav-list').find('.aco-btn, .btn, .acc-btn, .sp-nav-wrap a').attr('tabindex', '0');
339
340      $('.c-nav .js-aco-btn.is-active').each(function () {
341        $(this).next('.js-aco-cont').find('a').attr('tabindex', '0');
342      });
343      $('.c-nav').find('.sp-nav-wrap a').attr('tabindex', '0');
344    }
345  });
346
347  let navFocusOutTimer = null;
348
349  $('.c-nav').on('focusout', function () {
350    if (window.innerWidth < break_point2) {
351      // 少し遅延を入れて、フォーカスが本当に外に出たかを確認
352      navFocusOutTimer = setTimeout(() => {
353        if (!$('.c-nav').find(':focus').length) {
354          // フォーカスがどこにもない=外に出た
355          scrollOn();
356          menuClose();
357          $('.c-nav-btn').attr('aria-expanded', false);
358          $('.c-nav').attr('aria-hidden', true).attr('tabindex', '-1');
359          $('.c-nav .nav-list').find('.aco-btn, .btn, .sub-nav-list a').attr('tabindex', '-1');
360          $('.c-nav').find('.sp-nav-wrap a').attr('tabindex', '-1');
361        }
362      }, 10);
363    }
364  });
365
366  // 念のため、戻ってきた場合はタイマーキャンセル
367  $('.c-nav').on('focusin', function () {
368    if (navFocusOutTimer) clearTimeout(navFocusOutTimer);
369  });
370
371  /* header scroll */
372  $(window).on('scroll', function() {
373    var scrollAmount = $(this).scrollTop();
374    var header = $('.c-header');
375    if(scrollAmount > 100) {
376      header.addClass('is-shadow');
377    }
378    else {
379      header.removeClass('is-shadow');
380    }
381  });
382
383
384  /* c-contact-link-wrap
385  ------------------------------*/
386  (function () {
387    $('.c-contact-link-wrap').find('.contact-list').attr('aria-hidden', true);
388
389    $('.c-contact-link-wrap .c-contact-link').on('click', function(){
390      // 開閉
391      if($(this).parents('.c-contact-link-wrap').hasClass('is-active')) {
392        $(this).parents('.c-contact-link-wrap').removeClass('is-active');
393        $(this).parents('.c-contact-link-wrap').find('.c-contact-link').attr('aria-expanded', false);
394        $(this).parents('.c-contact-link-wrap').find('.contact-list').attr('aria-hidden', true);
395      } else {
396        $(this).parents('.c-contact-link-wrap').addClass('is-active');
397        $(this).parents('.c-contact-link-wrap').find('.c-contact-link').attr('aria-expanded', true);
398        $(this).parents('.c-contact-link-wrap').find('.contact-list').attr('aria-hidden', false);
399      }
400    });
401
402    $(document).click(function(e) {
403      // エリア外をクリックしたら閉じる
404      if(!$(e.target).closest('.c-contact-link-wrap').length) {
405        $('.c-contact-link-wrap').removeClass('is-active');
406        $('.c-contact-link-wrap').find('.c-contact-link').attr('aria-expanded', false);
407        $('.c-contact-link-wrap').find('.contact-list').attr('aria-hidden', true);
408      }
409    });
410
411    let navFocusOutTimer = null;
412    //フォーカスアウト
413    $('.c-contact-link-wrap').on('focusout', function () {
414      navFocusOutTimer = setTimeout(() => {
415        if (!$('.c-contact-link-wrap').find(':focus').length) {
416          $('.c-contact-link-wrap').removeClass('is-active');
417          $('.c-contact-link-wrap').find('.c-contact-link').attr('aria-expanded', false);
418          $('.c-contact-link-wrap').find('.contact-list').attr('aria-hidden', true);
419        }
420      }, 10);
421    });
422
423    // 念のため、戻ってきた場合はタイマーキャンセル
424    $('.c-contact-link-wrap').on('focusin', function () {
425      if (navFocusOutTimer) clearTimeout(navFocusOutTimer);
426    });
427  }());
428
429
430  /* c-language-link
431  ------------------------------*/
432  (function () {
433    $('.c-language-link').find('.lang-list').attr('aria-hidden', true);
434
435    $('.c-language-link .label-txt').on('click', function(){
436      // 開閉
437      if($(this).parents('.c-language-link').hasClass('is-active')) {
438        $(this).parents('.c-language-link').removeClass('is-active');
439        $(this).parents('.c-language-link').find('.label-txt').attr('aria-expanded', false);
440        $(this).parents('.c-language-link').find('.lang-list').attr('aria-hidden', true);
441      } else {
442        $(this).parents('.c-language-link').addClass('is-active');
443        $(this).parents('.c-language-link').find('.label-txt').attr('aria-expanded', true);
444        $(this).parents('.c-language-link').find('.lang-list').attr('aria-hidden', false);
445      }
446    });
447
448    $(document).click(function(e) {
449      // エリア外をクリックしたら閉じる
450      if(!$(e.target).closest('.c-language-link').length) {
451        $('.c-language-link').removeClass('is-active');
452        $('.c-language-link').find('.label-txt').attr('aria-expanded', false);
453        $('.c-language-link').find('.lang-list').attr('aria-hidden', true);
454      }
455    });
456
457    let navFocusOutTimer = null;
458
459    //フォーカスアウト
460    $('.c-language-link .lang-list').on('focusout', function () {
461      navFocusOutTimer = setTimeout(() => {
462        if (!$('.c-language-link .lang-list').find(':focus').length) {
463          $('.c-language-link').removeClass('is-active');
464          $('.c-language-link').find('.label-txt').attr('aria-expanded', false);
465          $('.c-language-link').find('.lang-list').attr('aria-hidden', true);
466        }
467      }, 10);
468    });
469    // 念のため、戻ってきた場合はタイマーキャンセル
470    $('.c-language-link .lang-list').on('focusin', function () {
471      if (navFocusOutTimer) clearTimeout(navFocusOutTimer);
472    });
473  }());
474
475
476  /* c-sp-language-link
477  ------------------------------*/
478  (function () {
479    $('.c-sp-language-link').find('.lang-list').attr('aria-hidden', true);
480
481    $('.c-sp-language-link .label-txt').on('click', function(){
482      // 開閉
483      if($(this).parents('.c-sp-language-link').hasClass('is-active')) {
484        $(this).parents('.c-sp-language-link').removeClass('is-active');
485        $(this).parents('.c-sp-language-link').find('.label-txt').attr('aria-expanded', false);
486        $(this).parents('.c-sp-language-link').find('.lang-list').attr('aria-hidden', true);
487        $(this).parents('.c-sp-language-link').find('.lang-list a').attr('aria-hidden', true);
488        $(this).parents('.c-sp-language-link').find('.lang-list a').attr('tabindex', '-1');
489      } else {
490        $(this).parents('.c-sp-language-link').addClass('is-active');
491        $(this).parents('.c-sp-language-link').find('.label-txt').attr('aria-expanded', true);
492        $(this).parents('.c-sp-language-link').find('.lang-list').attr('aria-hidden', false);
493        $(this).parents('.c-sp-language-link').find('.lang-list a').attr('aria-hidden', false);
494        $(this).parents('.c-sp-language-link').find('.lang-list a').attr('tabindex', '0');
495      }
496    });
497
498    $('.c-sp-language-link .lang-list li').on('click', function() {
499      // 表示用テキストの切り替え
500      var langText = $(this).attr('data-lang');
501      $('.c-sp-language-link .label-txt').text(langText);
502
503      // データ属性に設定したURLに遷移
504      var langUrl = $(this).attr('data-url');
505      window.location.href = langUrl;
506    });
507
508    $(document).click(function(e) {
509      // エリア外をクリックしたら閉じる
510      if(!$(e.target).closest('.c-sp-language-link').length) {
511        $('.c-sp-language-link').removeClass('is-active');
512        $('.c-sp-language-link').find('.label-txt').attr('aria-expanded', false);
513        $('.c-sp-language-link').find('.lang-list').attr('aria-hidden', true);
514        $('.c-sp-language-link').find('.lang-list a').attr('aria-hidden', true);
515        $('.c-sp-language-link').find('.lang-list a').attr('tabindex', '-1');
516      }
517    });
518
519    let navFocusOutTimer = null;
520
521    //フォーカスアウト
522    $('.c-sp-language-link .lang-list').on('focusout', function () {
523      navFocusOutTimer = setTimeout(() => {
524        if (!$('.c-sp-language-link .lang-list').find(':focus').length) {
525          $('.c-sp-language-link').removeClass('is-active');
526          $('.c-sp-language-link').find('.label-txt').attr('aria-expanded', false);
527          $('.c-sp-language-link').find('.lang-list').attr('aria-hidden', true);
528          $('.c-sp-language-link').find('.lang-list a').attr('aria-hidden', true);
529          $('.c-sp-language-link').find('.lang-list a').attr('tabindex', '-1');
530        }
531      }, 10);
532    });
533    // 念のため、戻ってきた場合はタイマーキャンセル
534    $('.c-sp-language-link .lang-list').on('focusin', function () {
535      if (navFocusOutTimer) clearTimeout(navFocusOutTimer);
536    });
537  }());
538
539
540/* --------------------------------
541Splide
542----------------------------------- */
543  /* top */
544
545  // KVのリンクが切れている場合は非表示にする
546  if ( $('.home-mv-section')[0] ) {
547    var slide_num = $('.home-mv-section a').length;
548    var slide_check_count = 0;
549    var slide_url_array = [];
550    $('.home-mv-section a').each(function() {
551      var this_href = $(this).attr('href');
552      slide_url_array.push(this_href);
553    });
554    // URLをまとめて通信
555      $.ajax({
556        url: 'https://www.cando-web.co.jp/my_cgi/get_target_url_status.php',
557        type: 'POST',
558        dataType: 'json',
559        data: { 'target_urls': slide_url_array },
560      }).done(function(data, textStatus, jqXHR){
561        $.each(data, function(index, value) {
562          if ( value.status !== 'OK' ) {
563            $('.home-mv-section a[href="' + value.target_url + '"]').remove();
564          }
565        });
566
567      }).fail(function(jqXHR, textStatus, errorThrown){
568      }).always(function(data, textStatus, jqXHR){
569        const homeMvSplide = new Splide('.home-mv-section .splide', {
570          autoplay: 'pause',
571          type: 'loop',
572          padding: '0',
573          pauseOnHover: true,
574          pauseOnFocus: true,
575          keyboard: true,
576          interval: 3000,
577          speed: 1000,
578
579          intersection: {
580            inView: {
581              autoplay: true,
582            },
583            outView: {
584              autoplay: false,
585            },
586          }
587        }).mount(window.splide.Extensions);
588        $('.loader').hide();
589      });
590
591  }
592
593
594  if($('.home-sns-section .splide')[0]) {
595    const homeSnsSplide = new Splide('.home-sns-section .splide', {
596      autoplay: true,
597      perPage: 2,
598      gap: 10,
599      type: 'loop',
600      pauseOnHover: false,
601      pauseOnFocus: false,
602      interval: 3000,
603      speed: 1000,
604      breakpoints: {
605        768: {
606          perPage: 1,
607        }
608      },
609    }).mount();
610  }
611
612
613
614/* --------------------------------
615ヘッダー 重要なお知らせエリア
616----------------------------------- */
617if($('.c-important-notice-area')[0]) {
618  const area = $('.c-important-notice-area');
619  const moreBtn = area.find('.js-notice-more-btn');
620  const content = area.find('.js-notice-more-content');
621  const links = content.find('a');
622  const closeBtn = content.find('.js-notice-close-btn');
623
624  const closeContent = () => {
625    content.attr('aria-hidden', true);
626    links.attr({'aria-hidden': true, 'tabindex': '-1'});
627    closeBtn.attr({'aria-hidden': true, 'tabindex': '-1'});
628  }
629
630  const openContent = () => {
631    content.attr('aria-hidden', false);
632    links.attr({'aria-hidden': false, 'tabindex': '0'});
633    closeBtn.attr({'aria-hidden': false, 'tabindex': '0'});
634  }
635
636  closeContent();
637
638  moreBtn.on('click', function(){
639    if (moreBtn.hasClass('is-active')) {
640      closeContent();
641
642      $(this).removeClass('is-active');
643      content.removeClass('is-active');
644    } else {
645      openContent();
646
647      $(this).toggleClass('is-active');
648      content.toggleClass('is-active');
649    }
650  });
651
652  closeBtn.on('click', function(){
653    closeContent();
654
655    moreBtn.removeClass('is-active');
656    content.removeClass('is-active');
657  });
658
659  let focusOutTimer;
660
661  area.on('focusout', function () {
662      // 少し遅延を入れて、フォーカスが本当に外に出たかを確認
663    focusOutTimer = setTimeout(() => {
664      if (!area.find(':focus').length) {
665        closeContent();
666
667        moreBtn.removeClass('is-active');
668        content.removeClass('is-active');
669      }
670    }, 10);
671  });
672
673  // 念のため、戻ってきた場合はタイマーキャンセル
674  area.on('focusin', function () {
675    if (navFocusOutTimer) clearTimeout(focusOutTimer);
676  });
677
678  // 重要なお知らせの時限設定
679  const now = new Date();
680  var important_count = parseInt($('[data-important-count]').attr('data-important-count'));
681  $('.c-important-notice-area [data-start]').each(function() {
682    const start = new Date($(this).attr('data-start'));
683    if ( $(this).attr('data-end') === undefined ) {
684      if (now < start) {
685        if ( $(this).closest('.head')[0] ) {
686          important_count --;
687        }
688        $(this).remove();
689      }
690    }
691    else {
692      const end = new Date($(this).attr('data-end'));
693      if (now < start || now > end) {
694        if ( $(this).closest('.head')[0] ) {
695          important_count --;
696        }
697        $(this).remove();
698      }
699    }
700  });
701  $('.c-important-notice-area [data-end]').each(function() {
702    const end = new Date($(this).attr('data-end'));
703    if ( $(this).attr('data-start') === undefined ) {
704      if (now > end) {
705        if ( $(this).closest('.head')[0] ) {
706          important_count --;
707        }
708        $(this).remove();
709      }
710    }
711    else {
712      const start = new Date($(this).attr('data-start'));
713      if (now < start || now > end) {
714        if ( $(this).closest('.head')[0] ) {
715          important_count --;
716        }
717        $(this).remove();
718      }
719    }
720  });
721  $('[data-important-count]').attr('data-important-count', important_count);
722  $('[data-important-count]').text(important_count + 'ä»¶');
723  if ( important_count <= 0 ) {
724    $('.c-important-notice-area').remove();
725  }
726}
727
728/* --------------------------------
729TOP NEWSタブ切り替え
730----------------------------------- */
731if($('.home-news-section')[0]) {
732  // 後で消す
733  $('.js-tab-btn-list .btn').on('click', function() {
734
735    $('.js-tab-wrap .tab').removeClass('is-current');
736    $('.js-tab-btn-list .btn').removeClass('is-current');
737
738    $(this).addClass('is-current');
739    var index = $('.js-tab-btn-list .btn').index(this);
740    $('.js-tab-wrap .tab').eq(index).addClass('is-current');
741  });
742}
743
744if ( $('[role="tab"]')[0] ) {
745  const tabs = $('[role="tab"]');
746  const tabList = $('[role="tablist"]');
747
748  // 各タブに click イベントハンドラーを追加します
749  tabs.each( function() {
750    $(this).on("click", changeTabs);
751  });
752
753  // tabListの中で表示されているタブを指定するようの定数。
754  let tabFocus = 0;
755  tabList.on("keydown", e => {
756    //← →を押したら
757    if (e.keyCode === 37 || e.keyCode === 39) {
758      tabs[tabFocus].setAttribute("tabindex", -1);
759
760      if (e.keyCode === 37) {
761        // ← を押したら
762        tabFocus--;
763        // 最初にいる場合は、最後に移動します
764        if (tabFocus < 0) {
765          tabFocus = tabs.length - 1;
766        }
767      } else if (e.keyCode === 39) {
768        // → を押したら
769        tabFocus++;
770        // 最後にいる場合は、最初に移動します
771        if (tabFocus >= tabs.length) {
772          tabFocus = 0;
773        }
774      }
775      tabs[tabFocus].setAttribute("tabindex", 0);
776      tabs[tabFocus].focus();
777    }
778  });
779}
780
781
782function changeTabs(e) {
783  const target = e.target;
784  const parent = target.parentNode;
785  const grandparent = parent.parentNode;
786  const grandparent2 = grandparent.parentNode;
787
788  // タブから現在すべての選択状態を取り除きます
789  grandparent
790    .querySelectorAll('[aria-selected="true"]')
791    .forEach(t => t.setAttribute("aria-selected", false));
792
793  // このタブを選択されたタブとして設定します
794  target.setAttribute("aria-selected", true);
795
796  // すべてのタブパネルを非表示にします
797  if ( $(grandparent2).find(`[role="tabpanel"]`)[0] ) {
798  grandparent2
799    .querySelectorAll('[role="tabpanel"]')
800    .forEach(p => p.setAttribute("hidden", true));
801
802  // 選択されたパネルを表示します
803      grandparent2.parentNode
804        .querySelector(`#${target.getAttribute("aria-controls")}`)
805        .removeAttribute("hidden");
806  }
807
808    return false;
809}
810
811if ( $('[data-category]')[0] ) {
812  // 0件のカテゴリがないかチェック
813  if ( !$('.home-news-section')[0] ) {  // TOPでは実施しない
814    $('[data-category]').each(function() {
815      var tmp_news_category = $(this).attr('data-category');
816      if ( tmp_news_category != 'all' && $('#news-list-target').find('[data-category*="' + tmp_news_category + '"]').length === 0 ) {
817        $(this).addClass('disabled');
818      }
819    });
820  }
821
822  $('.c-tab-btn-list [data-category]').on('click', function() {
823    if ( $(this).hasClass('disabled') ) {
824      return false;
825    }
826
827    this_news_category = $(this).attr('data-category');
828    this_news_page = 1;
829
830    if ( $(this).hasClass('btn') ) {
831      var this_news_parent_category = $(this).attr('data-category');
832      var this_news_parent_category_name = $(this).text();
833    }
834    else {
835      var this_news_parent_category = $(this).closest('ul').closest('li').find('.cat-btn').attr('data-category');
836      var this_news_parent_category_name = $(this).closest('ul').closest('li').find('.cat-btn').text();
837      $('.news-category-tab .is-active').removeClass('is-active');
838      $('.news-category-tab [aria-selected="true"]').attr('aria-selected', false);
839      $(this).closest('ul').closest('li').addClass('is-active');
840      $(this).closest('ul').closest('li').find('.cat-btn').attr('aria-selected', true);
841    }
842
843    changeNewsTags(this_news_parent_category);
844    changeNewsArticle();
845
846    return false;
847  });
848}
849
850// system カテゴリーはすぐ削除
851if ( $('#news-list-target [data-category="system"]')[0] ) {
852  $('#news-list-target [data-category="system"]').remove();
853}
854
855
856var this_news_page = 1;
857var this_news_page_all = 1;
858var this_news_target_article = 1;
859var this_news_category = 'all';
860let NEWS_PAGE_NUM = 10;
861if ( $('#main').hasClass('home') ) {
862  NEWS_PAGE_NUM = 5;
863}
864var $pagingArea = $('.c-paging-area');
865changeNewsArticle();
866function changeNewsArticle() {
867  // 並び替え
868  var $list = $('#news-list-target'),
869    $items = $list.find('li').get();
870
871  $items.sort(function(a, b) {
872    var dateA = $(a).attr('data-date');
873    var dateB = $(b).attr('data-date');
874
875    // 同じ日付ならsortnumで比較
876    if (dateA === dateB) {
877      var sortA = parseInt($(a).attr('data-sortnum')) || 0;
878      var sortB = parseInt($(b).attr('data-sortnum')) || 0;
879      return sortA - sortB;
880    }
881
882    // 日付で比較(昇順)
883    return dateA < dateB ? 1 : -1;
884  });
885
886  // 並び替えた要素をDOMに再追加
887  $list.empty().append($items);
888
889  $('#news-list-target').find('[data-category]').hide();
890  if ( this_news_category == 'all' ) {
891    this_news_target_article = $('#news-list-target').find('[data-category]').length;
892    $('#news-list-target').find('[data-category]').each( function(index) {
893      if ( index < (NEWS_PAGE_NUM * this_news_page) && index >= (NEWS_PAGE_NUM * (this_news_page - 1)) ) {
894        $(this).show();
895      }
896    });
897  }
898  else {
899    this_news_target_article = $('#news-list-target').find('[data-category*="' + this_news_category + '"]').length;
900    $('#news-list-target').find('[data-category*="' + this_news_category + '"]').each( function(index) {
901      if ( index < (NEWS_PAGE_NUM * this_news_page) && index >= (NEWS_PAGE_NUM * (this_news_page - 1)) ) {
902        $(this).show();
903      }
904    });
905  }
906
907  // ページング
908  this_news_page_all = Math.ceil(this_news_target_article / NEWS_PAGE_NUM);
909  if ( this_news_page_all > 1 ) {
910    $pagingArea.html(makePagingHtml(this_news_page, this_news_page_all));
911    $('.c-paging-area').show();
912  }
913  else {
914    $('.c-paging-area').hide();
915  }
916
917}
918function makePagingHtml (now, all) {
919  var paging_html = '';
920  if ( now > 1 ) {
921    paging_html += '<a class="prev page-numbers" title="前のページへ" href="" data-page="' + (now - 1) + '" hidden></a>';
922    paging_html += '<a class="page-numbers" href="" data-page="1">1</a>';
923  }
924  else {
925    paging_html += '<a class="prev page-numbers" title="前のページへ" href="" data-page="1" disabled hidden></a>';
926  }
927  if ( now > 2 && all > 4 ) {
928    paging_html += '<span class="dot first-dot">...</span>';
929  }
930  if ( all == 3 && now == all ) {
931    paging_html += '<a class="page-numbers" href="" data-page="2">2</a>';
932  }
933  if ( all > 4 && now == all ) {
934    paging_html += '<a class="page-numbers sp-hide" href="" data-page="' + (all - 2) + '">' + (all - 2) + '</a>';
935    paging_html += '<a class="page-numbers" href="" data-page="' + (all - 1) + '">' + (all - 1) + '</a>';
936  }
937  if ( all > 4 && now == (all - 1) ) {
938    paging_html += '<a class="page-numbers sp-hide" href="" data-page="' + (all - 2) + '">' + (all - 2) + '</a>';
939  }
940  paging_html += '<a class="page-numbers current" href="" data-page="' + now + '" disabled>' + now + '</a>';
941  if ( now == 1 && all == 3 ) {
942    paging_html += '<a class="page-numbers" href="" data-page="2">2</a>';
943  }
944  if ( now == 1 && all > 3 ) {
945    paging_html += '<a class="page-numbers" href="" data-page="2">2</a>';
946    paging_html += '<a class="page-numbers sp-hide" href="" data-page="3">3</a>';
947  }
948  if ( now == 2 && all > 3 ) {
949    paging_html += '<a class="page-numbers sp-hide" href="" data-page="3">3</a>';
950  }
951  if ( all > 4 && now < (all - 1) ) {
952    paging_html += '<span class="dot last-dot">...</span>';
953  }
954  if ( now < all ) {
955    paging_html += '<a class="page-numbers" href="" data-page="' + all + '">' + all + '</a>';
956    paging_html += '<a class="next page-numbers" title="次のページへ" href="" data-page="' + (parseInt(now) + 1) + '" hidden></a>';
957  }
958  else {
959    paging_html += '<a class="next page-numbers" title="次のページへ" href="" data-page="' + all + '" disabled hidden></a>';
960  }
961
962  return paging_html;
963}
964function changeNewsTags(this_news_parent_category) {
965  $('#news-list-target [data-category*="' + this_news_parent_category + '"]').each( function() {
966    if ( $(this).find('.tag').length > 1 ) {  // 複数タグがある場合はメインを入替
967      $(this).find('.parents').removeClass('parents');
968      $(this).find('[data-category-basename="' + this_news_parent_category + '"]').addClass('parents');
969      var tmp_html = $(this).find('[data-category-basename="' + this_news_parent_category + '"]').clone();
970      $(this).find('[data-category-basename="' + this_news_parent_category + '"]').remove();
971      $(this).find('.c-tags').prepend(tmp_html);
972    }
973  });
974}
975
976// ページング処理
977$pagingArea.on('click', 'a', function() {
978  if ( $(this).prop('disabled') ) {
979    return false;
980  }
981  this_news_page = $(this).attr('data-page');
982  changeNewsArticle();
983  // スクロール
984  var headerHeight = $('.c-header').outerHeight();
985  var position = $('#main').offset().top - headerHeight;
986  $('body,html').stop().animate({scrollTop: position}, scrollSpeed, 'swing');
987
988  return false;
989});
990
991if( $('.products-list')[0] ) {
992  changeProducts();
993  function changeProducts() {
994    // 並び替え
995    var $list = $('.products-list'),
996      $items = $list.find('li').get();
997
998    $items.sort(function(a, b) {
999      var sortA = parseInt($(a).attr('data-sortnum')) || 100;
1000      var sortB = parseInt($(b).attr('data-sortnum')) || 100;
1001      return sortA - sortB;
1002    });
1003
1004    // 並び替えた要素をDOMに再追加
1005    $list.empty().append($items);
1006  }
1007}
1008
1009/* --------------------------------
1010アコーディオン
1011----------------------------------- */
1012$('.js-aco-btn').on('click', function() {
1013  if ( deviceFlag == 0 ) { // → PC
1014    var speed = 300;
1015  } else { // → SP
1016    var speed = 400;
1017  }
1018
1019  if ($(this).parents('.c-footer')) {
1020    $(this).next('.js-aco-cont').slideToggle(speed);
1021
1022    if($(this).hasClass('is-active')) {
1023      $(this).attr('aria-expanded', false);
1024      $(this).removeClass('is-active');
1025
1026      $(this).next('.js-aco-cont').attr('aria-hidden', true);
1027    } else {
1028      $(this).attr('aria-expanded', true);
1029      $(this).addClass('is-active');
1030
1031      $(this).next('.js-aco-cont').attr('aria-hidden', false);
1032
1033    }
1034  } else {
1035    $(this).next('.js-aco-cont').slideToggle(speed);
1036
1037    if($(this).hasClass('is-active')) {
1038      $(this).attr('aria-expanded', false);
1039      $(this).removeClass('is-active');
1040    } else {
1041      $(this).attr('aria-expanded', true);
1042      $(this).addClass('is-active');
1043    }
1044  }
1045
1046});
1047
1048$('.c-header .js-aco-btn').on('click', function() {
1049
1050  if($(this).parents('.c-header')) {
1051    $(this).parents('.sp-aco-area').find('.btn').toggleClass('is-active');
1052
1053    if($(this).parents('.sp-aco-area').find('.btn').hasClass('is-active')) {
1054      // 開いてたら
1055      $(this).next('.js-aco-cont').attr('tabindex', '0');
1056      $(this).next('.js-aco-cont').attr('aria-hidden', false);
1057      $(this).next('.js-aco-cont').find('.sub-nav-list a').attr('tabindex', '0');
1058    } else {
1059      // 閉じてたら
1060      $(this).next('.js-aco-cont').attr('tabindex', '-1');
1061      $(this).next('.js-aco-cont').attr('aria-hidden', true);
1062      $(this).next('.js-aco-cont').find('.sub-nav-list a').attr('tabindex', '-1');
1063    }
1064  }
1065});
1066
1067/* --------------------------------
1068NEWSページ js-year-select-btn
1069----------------------------------- */
1070$('.js-year-select-btn').on('click', function() {
1071  $(this).parents('.js-year-select').toggleClass('is-active');
1072});
1073$(document).click(function(e) {
1074  // エリア外をクリックしたら閉じる
1075  if(!$(e.target).closest('.js-year-select').length) {
1076    $('.js-year-select').removeClass('is-active');
1077  }
1078});
1079
1080
1081/* --------------------------------
1082NEWSページ news-category-tab
1083----------------------------------- */
1084if ( $('.news-category-tab')[0] ) {
1085  $('.news-category-tab li:not(.ico-external) .btn').on('click', function() {
1086    if ( $(this).hasClass('disabled') ) {
1087      return false;
1088    }
1089    $('.news-category-tab li:not(.ico-external)').removeClass('is-active');
1090    $(this).parent().toggleClass('is-active');
1091  });
1092  $('.news-category-tab li:not(.ico-external) a:not(.btn)').on('click', function() {
1093    $(this).parents('li.is-active').removeClass('is-active');
1094  });
1095  $(document).click(function(e) {
1096    // mainにirがついていないとき、エリア外をクリックしたら閉じる
1097    if (!$(main).hasClass('ir')) {
1098      if(!$(e.target).closest('.news-category-tab').length) {
1099        $('.news-category-tab li').removeClass('is-active');
1100      }
1101    }
1102  });
1103
1104  // サブカテゴリーがある場合はタブにクラスを付ける
1105  $('.news-category-tab').children('li').each(function() {
1106    if ($(this).find('.aco-list').find('li').length > 0) {
1107      $(this).children('.btn').addClass('cat-btn');
1108    }
1109  });
1110}
1111
1112
1113//c-table03 spの時yearとmonthの幅を同じにする
1114if ($(window).width() <= break_point) {
1115  $('.c-table03 .each').each(function () {
1116    var yearWidth = $(this).find(".year").outerWidth();
1117    $(this).find(".month").css("width", yearWidth);
1118  });
1119}
1120
1121// ウィンドウサイズ変更時
1122var currentWidth = window.innerWidth;
1123
1124$(window).resize(function () {
1125  if (currentWidth == window.innerWidth) {
1126		return;
1127	} else {
1128    if ($(window).width() <= break_point) {
1129      $('.c-table03 .each').each(function () {
1130        var yearWidth = $(this).find(".year").outerWidth();
1131        $(this).find(".month").css("width", yearWidth);
1132      });
1133    } else {
1134        // ブレイクポイントを超えた場合
1135        $(".month").css("width", ""); // 幅をリセット
1136    }
1137  }
1138});
1139
1140
1141//決算短信ページ 年代を選ぶ
1142$(".ir-summary-year-select .year-btn").on("click", function () {
1143  var selectedYear = $(this).text().replace("年", ""); // クリックした年を取得
1144
1145    if ( deviceFlag == 0 ) { // → PC
1146      var speed = 300;
1147    } else { // → SP
1148      var speed = 400;
1149    }
1150
1151
1152  $(".tabpanel .tab-head").each(function () {
1153    var tabText = $(this).text().trim();
1154
1155    if (tabText.includes(selectedYear)) {
1156      // 他の開いている要素を閉じる
1157      $(".tabpanel .js-aco-cont").slideUp(speed);
1158      $(".tabpanel .tab-head").removeClass("is-active");
1159
1160      // クリックされたものを開く
1161      $(this).addClass("is-active");
1162
1163      var content = $(this).next(".js-aco-cont");
1164      content.slideDown(speed, function () {
1165        // スクロール処理(開いたパネルの位置へ)
1166        $('html, body').animate({
1167          scrollTop: $(this).offset().top - 200 // 上部に少し余裕を持たせる
1168        }, 500);
1169      });
1170    }
1171  });
1172
1173  $('.js-year-select').removeClass('is-active');
1174});
1175
1176if ( $('.js-scrollable')[0] ) {
1177  new ScrollHint('.js-scrollable', {
1178    suggestiveShadow: true, //スクロール可能な要素右端に影を付ける
1179    i18n: {
1180      scrollable: '' //表示するテキスト
1181    }
1182  });
1183}
1184
1185
1186// NEWアイコン
1187if ( $('.js-disp-new-icon')[0] && $('[data-new-target-date]')[0]) {
1188  var current = new Date();
1189  var range_ms = current.getTime() - (14 * 24 * 60 * 60 * 1000); // 2週間
1190  $('.js-disp-new-icon').each ( function() {
1191    if ( $(this).hasClass('new_mark_false') ) {
1192      $(this).remove();
1193    }
1194    else {
1195      var modified = new Date($(this).closest('li').find('[data-new-target-date]').attr('data-new-target-date'));
1196      var modified_ms = modified.getTime();
1197      if (range_ms < modified_ms){
1198        $(this).show();
1199      }
1200      else {
1201        $(this).remove();
1202      }
1203    }
1204  });
1205}
1206
1207
1208// ターゲットテーブル内の,tdの中のデータを3桁区切りにする
1209function number_in_table_to_3digit($target) {
1210  $target.find('td').each(function() {
1211    var $this = $(this);
1212    var text = $this.text().replace(/,/g, '');
1213    if (text.indexOf('▲') >= 0) {
1214      text = text.replace('▲', '');
1215      if (text.indexOf('.') >= 0) {
1216        var tmp_text = text.split('.');
1217        var num = parseInt(tmp_text[0], 10);
1218        $this.text('▲' + num.toLocaleString() + '.' + tmp_text[1]);
1219      }
1220      else {
1221        if (text.match(/^[0-9]+$/)) {
1222          var num = parseInt(text, 10);
1223          $this.text('▲' + num.toLocaleString());
1224        }
1225      }
1226    }
1227    else if (text.indexOf('.') >= 0) {
1228      var tmp_text = text.split('.');
1229      var num = parseInt(tmp_text[0], 10);
1230      $this.text(num.toLocaleString() + '.' + tmp_text[1]);
1231    }
1232    else if (text.match(/^[0-9]+$/)) {
1233      var num = parseInt(text, 10);
1234      $this.text(num.toLocaleString());
1235    }
1236  });
1237}
1238
1239// 財務ハイライト CSVファイル読み込み
1240if ( $('#business-highlight-table-div')[0] ) {
1241  var csv_flg = false;
1242  var table_caption = '<caption><details><summary tabindex="-1">財務ハイライトが確認できる表です。</summary></details></caption>';
1243  if ( $('[name="data_use_which"]').val() == 'csv' ) {
1244    $.ajax({
1245      url: $('[name="csv_url"]').val()
1246    }).done(async function(data, textStatus, jqXHR){
1247      await new Promise(resolve => setTimeout(resolve, 100)); // 処理を100ms遅らせる
1248      csv_flg = true;
1249      var csv = $.csv.toArrays(data);
1250      var csv_html = '';
1251      csv_html += '<table class="c-table05">';
1252      csv_html += table_caption;
1253      csv_html += '<tr class="th-center">';
1254      for ( var i = 0; i < csv[0].length; i++ ) {
1255        csv_html += '<th scope="col">' + csv[0][i] + '</th>';
1256      }
1257      csv_html += '</tr>';
1258      for ( var i = 1; i < csv.length; i++ ) {
1259        csv_html += '<tr class="td-right">';
1260        for ( var j = 0; j < csv[i].length; j++ ) {
1261          if ( j == 0 ) {
1262            csv_html += '<th scope="row">' + csv[i][j] + '</th>';
1263          }
1264          else {
1265            csv_html += '<td>' + csv[i][j] + '</td>';
1266          }
1267        }
1268        csv_html += '</tr>';
1269      }
1270      csv_html += '</table>';
1271      $('#business-highlight-table-div').html(csv_html);
1272      number_in_table_to_3digit($('#business-highlight-table-div'));
1273    }).fail(function(jqXHR, textStatus, errorThrown){
1274      console.log(errorThrown);
1275    });
1276  }
1277  else {
1278    // 現在のものにクラス付与して整形
1279    if ( $('#business-highlight-table-div').find('table')[0] ) {
1280      $('#business-highlight-table-div').find('table').addClass('c-table05');
1281      $('#business-highlight-table-div').find('table').prepend(table_caption);
1282      // 1行目をヘッダーにする
1283      $('#business-highlight-table-div').find('table').find('tr').each(function(index) {
1284        if ( index == 0 ) {
1285          $(this).html($(this).html().replace(/<td/g, '<th scope="col"').replace(/<\/td>/g, '</th>'));
1286          $(this).addClass('th-center');
1287        }
1288        else {
1289          // 1列目をヘッダーにする
1290          $(this).addClass('td-right');
1291          $(this).find('td').each(function(index2) {
1292            if ( index2 == 0 ) {
1293              $(this).html($(this).html().replace(/<td/g, '<th scope="row"').replace(/<\/td>/g, '</th>'));
1294            }
1295          });
1296        }
1297      });
1298
1299      number_in_table_to_3digit($('#business-highlight-table-div'));
1300    }
1301  }
1302}
1303
1304
1305// 月次情報 CSVファイル読み込み
1306if ( $('#monthly-report-table-div')[0] ) {
1307  var csv_flg = false;
1308  var table_caption = '<caption><details><summary tabindex="-1">月次情報が確認できる表です。</summary></details></caption>';
1309  if ( $('[name="data_use_which"]').val() == 'csv' ) {
1310    $.ajax({
1311      url: $('[name="csv_url"]').val()
1312    }).done(function(data, textStatus, jqXHR){
1313      csv_flg = true;
1314      var csv = $.csv.toArrays(data);
1315      var csv_html = '';
1316      csv_html += '<table class="c-table05">';
1317      csv_html += table_caption;
1318      csv_html += '<tr class="th-center">';
1319      for ( var i = 0; i < csv[0].length; i++ ) {
1320        csv_html += '<th scope="col">' + csv[0][i] + '</th>';
1321      }
1322      csv_html += '</tr>';
1323      for ( var i = 1; i < csv.length; i++ ) {
1324        csv_html += '<tr class="td-right">';
1325        for ( var j = 0; j < csv[i].length; j++ ) {
1326          if ( j == 0 ) {
1327            csv_html += '<th scope="row">' + csv[i][j] + '</th>';
1328          }
1329          else {
1330            csv_html += '<td>' + csv[i][j] + '</td>';
1331          }
1332        }
1333        csv_html += '</tr>';
1334      }
1335      csv_html += '</table>';
1336      $('#monthly-report-table-div').html(csv_html);
1337      console.log(csv);
1338    }).fail(function(jqXHR, textStatus, errorThrown){
1339      console.log(errorThrown);
1340    });
1341  }
1342  else {
1343    // 現在のものにクラス付与して整形
1344    if ( $('#monthly-report-table-div').find('table')[0] ) {
1345      $('#monthly-report-table-div').find('table').addClass('c-table05');
1346      $('#monthly-report-table-div').find('table').prepend(table_caption);
1347      // 1行目をヘッダーにする
1348      $('#monthly-report-table-div').find('table').find('tr').each(function(index) {
1349        if ( index == 0 ) {
1350          $(this).html($(this).html().replace(/<td/g, '<th scope="col"').replace(/<\/td>/g, '</th>'));
1351          $(this).addClass('th-center');
1352        }
1353        else {
1354          // 1列目をヘッダーにする
1355          $(this).addClass('td-right');
1356          $(this).find('td').each(function(index2) {
1357            if ( index2 == 0 ) {
1358              $(this).html($(this).html().replace(/<td/g, '<th scope="row"').replace(/<\/td>/g, '</th>'));
1359            }
1360          });
1361        }
1362      });
1363    }
1364  }
1365}
1366
1367// IRカレンダーページのテーブル調整
1368if ( $('.ir-calendar-section')[0] ) {
1369  $('.ir-tbl-area').each(function() {
1370    var table_caption = '<caption><details><summary tabindex="-1">' + $(this).closest('.desc-texts-wrap').find('.ttl-red').text() + 'の情報が確認できる表です。</summary></details></caption>';
1371    var $tbl = $(this).find('table');
1372    $tbl.addClass('c-table05');
1373    $tbl.prepend(table_caption);
1374    // 1行目をヘッダーにする
1375    $tbl.find('tr').each(function(index) {
1376      if ( index == 0 ) {
1377        $(this).html($(this).html().replace(/<td/g, '<th scope="col"').replace(/<th>/g, '<th scope="col">').replace(/<\/td>/g, '</th>'));
1378        $(this).addClass('th-center');
1379      }
1380    });
1381
1382  });
1383}
1384
1385// お知らせ・FAQのカテゴリにリンクから遷移した場合
1386if ( location.pathname.indexOf('/news/') != -1 || location.pathname.indexOf('/faq/') != -1 ) {
1387  var last_url_path = location.pathname.split('/');
1388  if ( last_url_path[3] == 'ir' ) {
1389    $('.news-category-tab [data-category="management_ir"]').trigger('click');
1390  }
1391  else if ( last_url_path[3] == '' ) {
1392    if ( $('#tab_' + last_url_path[2])[0] ) {
1393      $('#tab_' + last_url_path[2]).trigger('click');
1394    }
1395  }
1396}
1397
1398// お知らせ年別アーカイブでのタブ切り替え
1399if ( $('[name="year-archive-page"]')[0] ) {
1400  var this_page_year = $('[name="year-archive-page"]').val();
1401  $('.year-current').text(this_page_year + 'å¹´');
1402
1403  $('.js-year-select-btn').addClass('is-selected');
1404}
1405
1406/* --------------------------------
1407アクセシビリティ調整
1408----------------------------------- */
1409
1410// js-support(閲覧補助)
1411$(function(){
1412  if($('.js-support')[0]){
1413    const $trigger = $('.js-support'),
1414      $popup = $('.support-items'),
1415      $close_trigger = $popup.find('.close-btn'),
1416      $color_trigger = $popup.find('.color-list .acc-btn'),
1417      $size_trigger = $popup.find('.size-list .acc-btn'),
1418      $wrapper = $('#wrapper'),
1419      $popup_content = $popup.find('.c-support-popup'),
1420      add_action = function(){
1421        $trigger.attr('aria-expanded', true);
1422        $popup.find('.acc-btn').attr('tabindex', '0');
1423        $close_trigger.attr('tabindex', '0');
1424        $popup_content.attr('aria-hidden', false);
1425      },
1426      remove_action = function(){
1427        $trigger.attr('aria-expanded', false);
1428        $popup.find('.acc-btn').attr('tabindex', -1);
1429        $close_trigger.attr('tabindex', -1);
1430        $popup_content.attr('aria-hidden', true);
1431      };
1432
1433    $popup_content.attr('aria-hidden', true);
1434
1435    // ポップアップ表示制御
1436    $trigger.on('click', function(){
1437      $(this).toggleClass('is-active');
1438      if($(this).hasClass('is-active')){
1439        add_action();
1440      }else{
1441        remove_action();
1442      }
1443    });
1444    $close_trigger.on('click', function(){
1445      $trigger.removeClass('is-active');
1446      remove_action();
1447    });
1448    $(document).on('click', function(e){
1449      const $this = $(e.target);
1450
1451      if($trigger.hasClass('is-active') && !$this.is($trigger) && !$this.is($popup) && !$this.parents('.support-items')[0]){
1452        $trigger.removeClass('is-active');
1453        remove_action();
1454      }
1455    });
1456
1457    let navFocusOutTimer = null;
1458
1459    //フォーカスアウト
1460    $popup_content.on('focusout', function () {
1461      navFocusOutTimer = setTimeout(() => {
1462        if (!$popup_content.find(':focus').length) {
1463          $trigger.removeClass('is-active');
1464          remove_action();
1465        }
1466      }, 10);
1467    });
1468    // 念のため、戻ってきた場合はタイマーキャンセル
1469    $popup_content.on('focusin', function () {
1470      if (navFocusOutTimer) clearTimeout(navFocusOutTimer);
1471    });
1472
1473    // 背景色
1474    $color_trigger.on('click', function(){
1475      $wrapper.attr('class', 'web-support-wrapper');
1476      $wrapper.attr('data-color', $(this).data('color'));
1477      $wrapper.addClass($(this).data('color'));
1478      window.sessionStorage.setItem(['data-color'], [$(this).data('color')]); // 選択された色をsessionに保存
1479    });
1480
1481    // 文字サイズ
1482    $size_trigger.on('click', function(){
1483      $wrapper.attr('data-font_size', $(this).data('size'));
1484      window.sessionStorage.setItem(['data-size'], [$(this).data('size')]); // 選択されたサイズをsessionに保存
1485    });
1486
1487    // sessionにデータが保存されている場合
1488    if(window.sessionStorage.getItem(['data-color']) || window.sessionStorage.getItem(['data-size'])){
1489      const session_data_color = window.sessionStorage.getItem(['data-color']),
1490        session_data_size = window.sessionStorage.getItem(['data-size']);
1491
1492      $popup.find('.color-list .acc-btn[data-color='+ session_data_color +']').trigger('click');
1493      $popup.find('.size-list .acc-btn[data-size='+ session_data_size +']').trigger('click');
1494    }
1495
1496  }
1497});
1498
1499// focusの調整 mega-menu
1500$(function(){
1501  var $megaMenuTarget = $('.mega-menu-wrap .btn, .mega-menu a');
1502  $megaMenuTarget.on("focus", function(e) {
1503      $(this).parents('.mega-menu-wrap').find('.mega-menu').addClass('is-focus');
1504    });
1505  $megaMenuTarget.on("blur", function(e) {
1506    $(this).parents('.mega-menu-wrap').find('.mega-menu').removeClass('is-focus');
1507  });
1508});
1509
1510// PDFファイルサイズの取得
1511function get_file_size(d) {
1512  var h = "-";
1513  var g = d.closest('a').attr('href');
1514  var f = $.ajax({
1515    type: "HEAD",
1516    url: g,
1517    dataType: "text"
1518  }).done(function () {
1519    var i = f.getResponseHeader("Content-Length");
1520    console.log(i);
1521    if ( i ) {
1522      d.html(return_file_size(i));
1523    }
1524    else {
1525      d.remove();
1526    }
1527  }).fail(function () {
1528    d.remove();
1529  });
1530}
1531
1532function return_file_size(d) {
1533  if (d < 1024) {
1534    return d + "B"
1535  } else {
1536    d = calc_file_size(d)
1537  }
1538  if (d < 1024) {
1539    return d + "KB"
1540  } else {
1541    d = calc_file_size(d)
1542  }
1543  if (d < 1024) {
1544    return d + "MB"
1545  } else {
1546    return calc_file_size(d) + "GB"
1547  }
1548}
1549
1550function calc_file_size(d) {
1551  return (Math.ceil((d * 10) / 1024)) / 10
1552}
1553
1554if ( $(".js-pdf-size")[0] ) {
1555
1556  var pdf_url_array = [];
1557  $('.js-pdf-size').each(function() {
1558    var this_href = $(this).closest('a').attr('href');
1559    pdf_url_array.push(this_href);
1560  });
1561  // URLをまとめて通信
1562    $.ajax({
1563      url: 'https://www.cando-web.co.jp/my_cgi/get_filesize_pdf.php',
1564      type: 'POST',
1565      dataType: 'json',
1566      data: { 'target_pdfs': pdf_url_array },
1567    }).done(function(data, textStatus, jqXHR){
1568      console.log(data);
1569      $.each(data, function(index, value) {
1570        if ( value.status !== 'NG' ) {
1571          $('a[href="' + value.target_pdf + '"] .js-pdf-size').html(value.status);
1572        }
1573        else {
1574          $('a[href="' + value.target_pdf + '"] .js-pdf-size').remove();
1575        }
1576      });
1577
1578    }).fail(function(jqXHR, textStatus, errorThrown){
1579    });
1580
1581  // $('.js-pdf-size').each(function() {
1582  //   get_file_size($(this));
1583  // });
1584}
1585
1586/* --------------------------------
1587言語ボタン 多言語ページのときのis-active
1588----------------------------------- */
1589if($('html[lang=en]')[0]) {
1590  // 英語
1591  $('.lang-list li').removeClass('is-current');
1592  $('.lang-list li[data-lang=EN]').addClass('is-current');
1593
1594  $('.c-sp-language-link .label-txt').text('EN');
1595
1596  $('.js-canly-url').attr('href','https://en.shopinfo.cando-web.co.jp/');
1597  $('.js-canly-url-footer').attr('href','https://en.shopinfo.cando-web.co.jp/');
1598  $('.js-canly-url-map').attr('href','https://en.shopinfo.cando-web.co.jp/map/');
1599
1600} else if ($('html[lang=zh-hans]')[0]) {
1601  // 简体中文
1602  $('.lang-list li').removeClass('is-current');
1603  $('.lang-list li[data-lang=ZH]').addClass('is-current');
1604
1605  $('.c-sp-language-link .label-txt').text('ZH');
1606
1607  $('.js-canly-url').attr('href','https://zh-cn.shopinfo.cando-web.co.jp/');
1608  $('.js-canly-url-footer').attr('href','https://zh-cn.shopinfo.cando-web.co.jp/');
1609  $('.js-canly-url-map').attr('href','https://zh-cn.shopinfo.cando-web.co.jp/map/');
1610
1611} else if ($('html[lang=zh-hant]')[0]) {
1612  // 繁體中文
1613  $('.lang-list li').removeClass('is-current');
1614  $('.lang-list li[data-lang="TW"]').addClass('is-current');
1615
1616  $('.c-sp-language-link .label-txt').text('TW');
1617
1618  $('.js-canly-url').attr('href','https://zh-tw.shopinfo.cando-web.co.jp/');
1619  $('.js-canly-url-footer').attr('href','https://zh-tw.shopinfo.cando-web.co.jp/');
1620  $('.js-canly-url-map').attr('href','https://zh-tw.shopinfo.cando-web.co.jp/map/');
1621
1622} else if ($('html[lang=ko]')[0]) {
1623  // 한국어
1624  $('.lang-list li').removeClass('is-current');
1625  $('.lang-list li[data-lang=KO]').addClass('is-current');
1626
1627  $('.c-sp-language-link .label-txt').text('KO');
1628
1629  $('.js-canly-url').attr('href','https://ko.shopinfo.cando-web.co.jp/');
1630  $('.js-canly-url-footer').attr('href','https://ko.shopinfo.cando-web.co.jp/');
1631  $('.js-canly-url-map').attr('href','https://ko.shopinfo.cando-web.co.jp/map/');
1632
1633} else {
1634  $('.lang-list li').removeClass('is-current');
1635  $('.lang-list li:first-child').addClass('is-current');
1636
1637  $('.c-sp-language-link .label-txt').text('JP');
1638
1639  $('.js-canly-url').attr('href','https://shopinfo.cando-web.co.jp/');
1640  $('.js-canly-url-footer').attr('href','https://shopinfo.cando-web.co.jp/');
1641  $('.js-canly-url-map').attr('href','https://shopinfo.cando-web.co.jp/map/');
1642}
1643
1644
1645/* --------------------------------
1646EmbedSocial iframeに修正
1647----------------------------------- */
1648$(window).on('load', function(){
1649  if($('.home-sns-section iframe')[0]) {
1650    $('.home-sns-section iframe').attr('tabindex','-1');
1651    $('.home-sns-section iframe').attr('aria-hidden','true');
1652  }
1653});
1654
1655
1656// 電子公告で最新のPDFの表示場所を変えるなどの対応
1657if ( $('.pdf-or-text-area')[0] ) {
1658  var text_area_disp_flg = false;
1659  if ( $('.disp-pdf')[0] ) {
1660    var target_html = '';
1661    $('.disp-pdf').each(function() {
1662      var $target_pdf = $(this);
1663      var current = new Date();
1664      var current_ms = current.getTime();
1665      var range_ms = current.getTime() - (30 * 24 * 60 * 60 * 1000); // 30日間
1666      var modified = new Date($target_pdf.attr('data-create-date'));
1667      var modified_ms = modified.getTime();
1668      var limit_date = $(this).attr('data-limit-date').replace('年','/').replace('月','/').replace('日','');  // 2026年2月26日 の形式
1669      var limit_date_obj = new Date(limit_date);
1670      var limit_date_ms = limit_date_obj.getTime();
1671      
1672      if ( range_ms < modified_ms && current_ms < limit_date_ms ) {
1673        // 30日以内に更新されている場合
1674        target_html += $target_pdf.html();
1675        $('.pdf-or-text-area .latest-pdf').html(target_html);
1676        $target_pdf.remove();
1677        $('.pdf-or-text-area .pdf-area').show();
1678        $('.pdf-or-text-area .latest-pdf').show();
1679        $('.pdf-or-text-area .text-area').hide();
1680        text_area_disp_flg = true;
1681      }
1682      else {
1683        if ( !text_area_disp_flg ) {
1684          // 30日以上更新されていない場合
1685          $('.pdf-or-text-area .text-area').show();
1686        }
1687      }
1688    });
1689  }
1690  else {
1691    $('.pdf-or-text-area .text-area').show();
1692  }
1693}
1694
1695
1696})(jQuery);

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.