PageSourceSearch

https://www.kyotaru.co.jp/corporate/common/js/common.js

js kyotaru.co.jp collected 2026-10-03 19:37:07 UTC 7,003 bytes, 236 lines download raw bytes

1$(document).ready(function(){
2  getWindowSize();
3  headerSet();
4  pageTopSet();
5  accordionSet();
6  anchorScrollSet();
7  changeHoverBtnImg();
8});
9/*--------------------------------------------------
10baseMove ページ共通変数
11----------------------------------------------------*/
12var baseSet = baseSet || {};
13baseSet.winW = $(window).width();
14baseSet.winH = $(window).height();
15baseSet.scrollY  = 0;
16
17$(window).on("resize", function(){
18  baseSet.winW = $(window).width();
19  baseSet.winH = $(window).height();
20});
21$(window).on("scroll", function(){
22  baseSet.scrollY  = $(window).scrollTop();
23});
24/*--------------------------------------------------
25  wrappにpcかspのクラス付与
26----------------------------------------------------*/
27function getWindowSize(){
28	let sFlag;
29	if(baseSet.winW>767){
30		sFlag = false;
31		$('#wrap').addClass('with_pc');
32	}else{
33		sFlag = true;
34		$('#wrap').addClass('with_sp');
35	}
36	$(window).on("resize", function(){
37		if(baseSet.winW < 768){
38			if(sFlag != true){
39				sFlag = true;
40				$('#wrap').addClass('with_sp');
41				$('#wrap').removeClass('with_pc');
42        spReset();
43			}
44		}else{
45			if(sFlag != false){
46				sFlag = false;
47				$('#wrap').addClass('with_pc');
48				$('#wrap').removeClass('with_sp');
49        pcReset();
50			}
51		}
52	});
53}
54function spReset(){
55  headReset();
56}
57function pcReset(){
58  headReset();
59}
60/*--------------------------------------------------
61  header
62----------------------------------------------------*/
63function headReset(){
64  $('#header').removeClass('head_open');
65  $('#header .btn_wrap, .header_list').removeAttr('style');
66  $('#wrap').css({'margin-top':'0', 'position':'static'});
67}
68function headerSet(){
69  //pc
70  const openMenu = function($this){
71    $this.find('.btn_wrap').stop();
72    $this.addClass('on');
73    $('#header').addClass('head_open');
74  }
75  const closeMenu = function(){
76    $('.head_open .btn_wrap').stop();
77    $('.head_open .acc_wrap').removeClass('on');
78    $('#header').removeClass('head_open');
79  }
80  let timmer;
81  $('body').on('mouseenter','.with_pc .header_list .acc_wrap',function(){
82    const $this = $(this);
83    timmer = setTimeout(function(){
84      openMenu($this);
85    },100);
86  }).on('mouseleave','.with_pc .header_list .acc_wrap',function(){
87    clearTimeout(timmer);
88    closeMenu();
89  }).on('click', '.head_open .btn_close', function(){
90    closeMenu();
91    return false;
92  });;
93
94  //sp
95  const fixedBgSet = function(){
96		let scTop = baseSet.scrollY;
97		$('#header .menu_bg').attr('data-top', scTop);
98		$('#wrap').css({'margin-top':-scTop, 'position':'fixed', 'width':'100%'});
99  }
100  const fixedBgRemove = function(){
101		let scTop = $('#header .menu_bg').attr('data-top');
102    $('#wrap').css({'margin-top':'0', 'position':'static', 'width':'auto'});
103    $('html,body').scrollTop(scTop);
104  }
105  $('body').on('click', '.sp_menu', function(){
106    $('#header .acc_wrap .sp_acc_btn').removeClass('acc_on');
107    $(this).next('.header_list').slideToggle(200);
108    if($('#header').hasClass('head_open')){
109      fixedBgRemove();
110    }else{
111      fixedBgSet();
112    }
113    $('#header').toggleClass('head_open');
114    return false;
115  });
116}
117/*--------------------------------------------------
118  pageTopSet
119----------------------------------------------------*/
120function pageTopSet(){
121	let contentH,footH;
122	const $pageTop = $('.page_top_btn');
123	const pageTopH = $('.page_top_btn .btn').height();
124	let fFlag = true;
125	$(window).on("scroll", function(){
126    contentH = $(document).height();
127		footH = $('#footer').height();
128		if(footH > contentH - baseSet.scrollY - baseSet.winH + pageTopH - 40 || baseSet.scrollY < 200){
129			if(fFlag != true){
130				fFlag = true;
131				$pageTop.removeClass('fixed');
132			}
133		}else{
134			if(fFlag != false){
135				fFlag = false;
136				$pageTop.addClass('fixed');
137			}
138		}
139	});
140}
141/*--------------------------------------------------
142  accordionSet
143----------------------------------------------------*/
144function accordionSet(){
145  $('body').on('click', '.with_sp .sp_acc_btn, .acc_btn', function(){
146    const $this = $(this);
147    const $acc_wrap = $(this).closest('.acc_wrap');
148    $this.toggleClass('acc_on');
149    $acc_wrap.find('.acc_in').slideToggle();
150    return false;
151  });
152}
153/*--------------------------------------------------
154  anchorScrollSet
155----------------------------------------------------*/
156function anchorScrollSet(){
157  $('body').on('click', 'a.anchor, .anchor a', function () {
158    const href = $(this).attr('href');
159    const target = $(href == '#' || href == '' ? 'html' : href.replace(/^.*(#.*)$/, '$1'));
160    const headH = $('#header').height();
161    const position = target.offset().top - headH;
162    $('body, html').animate({ scrollTop: position }, 500, 'swing');
163    return false;
164  });
165}
166/*--------------------------------------------------
167  changeHoverBtnImg
168----------------------------------------------------*/
169function changeHoverBtnImg(){
170  $('a.js-hoverImg').each(function (i,v) {
171    var $img = $(this).find('img');
172    var _src = $img.attr('src');
173    var img_off = _src;
174    var img_on = $img.attr('src').replace('_wh.','.');
175    var img_wh_on = $img.attr('src').replace('.','_wh.');
176
177    $(this).hover(
178      function(){
179        if(_src.indexOf('_wh.') >= 0){
180          $img.attr('src',img_on);
181        }else{
182          $img.attr('src',img_wh_on);
183        }
184      },
185      function(){
186        $img.attr('src',img_off);
187      }
188    );
189  });
190}
191
192/* add 260713 */
193/*--------------------------------------------------
194  fileSize_check(ファイルサイズ取得)
195----------------------------------------------------*/
196function fileSize_check() {
197  const fileElements = document.querySelectorAll(".file-size[data-pdf-url]");
198
199  if (fileElements.length === 0) {
200    return;
201  }
202
203  function formatBytes(bytes) {
204    if (bytes < 1024) return bytes + "B";
205    const mb = bytes / (1024 * 1024);
206    const gb = mb / 1024;
207    if (gb >= 1) {
208      return (Math.floor(gb * 100) / 100).toFixed(2) + "GB";
209    }
210    if (mb >= 1) {
211      return (Math.floor(mb * 100) / 100).toFixed(2) + "MB";
212    }
213    return Math.floor(bytes / 1024) + "KB";
214  }
215
216  fileElements.forEach((element) => {
217    const url = element.getAttribute("data-pdf-url");
218
219    fetch(url, { method: "HEAD" })
220      .then((response) => {
221        if (!response.ok) throw new Error("ネットワークエラー");
222
223        const size = response.headers.get("content-length");
224        if (size) {
225          element.textContent = `(${formatBytes(parseInt(size, 10))})`;
226        } else {
227          element.textContent = "";
228        }
229      })
230      .catch((error) => {
231        console.warn("サイズ取得に失敗したため、何も表示しません:", error);
232        element.textContent = "";
233      });
234  });
235}
236document.addEventListener("DOMContentLoaded", fileSize_check);

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.