PageSourceSearch

https://www.hakataza.co.jp/common/js/common.js?1759913413

js hakataza.co.jp collected 2026-10-02 03:28:21 UTC 19,542 bytes, 674 lines download raw bytes

1const
2	$window = $(window);
3
4let
5    ua = window.navigator.userAgent,
6    platform = window.navigator.platform,
7	locationHash = window.location.hash,
8	browser = '',
9    os = '',
10    isPc = false;
11	common = {};
12	common.event = {};
13	const breakPoints = {
14		p: 767,
15	};
16	common.breakPoints = breakPoints;
17
18if (window.navigator.userAgentData) {
19    isPc = window.navigator.userAgentData.mobile ? false : true;
20} else {
21    ua = window.navigator.userAgent,
22    platform = window.navigator.platform,
23    browser = '',
24    os = '';
25    
26    if(ua.indexOf('Edge') != -1) {
27      //console.log('Microsoft Edge');
28    } else if(ua.indexOf('Trident') != -1 || ua.indexOf('MSIE') != -1) {
29      //console.log('Microsoft Internet Explorer');
30        browser = 'ie';
31    } else if(ua.indexOf('OPR') != -1 || ua.indexOf('Opera') != -1) {
32      //console.log('Opera');
33    } else if(ua.indexOf('Chrome') != -1) {
34      //console.log('Google Chrome');
35        //$('body').addClass('chrome');
36    } else if(ua.indexOf('Firefox') != -1) {
37      //console.log('FireFox');
38    } else if(ua.indexOf('Safari') != -1) {
39      //console.log('Safari');
40    } else {
41      //console.log('Unknown');
42    }
43
44    if(platform.indexOf('Win') !== -1) {
45      //console.log('Microsoft Windows');
46        os = 'win';
47    } else if(platform.indexOf('android') !== -1) {
48      //console.log('Android');
49    } else if(platform.indexOf('iPhone') !== -1 || platform.indexOf('iPad') !== -1) {
50      //console.log('phone');
51    } else if(platform.indexOf('Mac') !== -1) {
52      //console.log('mac');
53        os = 'mac';
54    } else {
55      //console.log('Unknown');
56    }
57    
58    if (ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0) {
59        // スマートフォン用コード
60    } else if (ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0) {
61        // タブレット用コード
62    } else {
63        // PC用コード
64        isPc = 'true';
65    }
66}
67
68function resizeEvent() {
69	return isPc ? 'resize' : 'orientationchange';
70}
71
72
73/************************************************
74
75	smooth scroll
76
77*************************************************/
78$window.on('load', function(){
79    /*ページ内#リンク*/
80    $('.js-scroll').click(function(){
81        const
82			$this = $(this),
83            headerHight = $('.b-header').outerHeight(),
84            href= $(this).attr('href'),
85            target = $(href == '#' || href == '' ? 'body' : href);
86        
87        $('html, body').animate({
88            scrollTop: target.offset().top - headerHight
89        }, 400, 'swing', function() {
90			target.attr('tabindex', '-1');
91			document.querySelector(href)?.focus({preventScroll: true});
92		});
93        return false;
94    });
95    
96     /*ページ外#リンク*/      
97    var url = $(location).attr('href');
98    if( url.indexOf('?id=') >= 1 && url.indexOf('preview=') == -1 ) {
99        const
100            headerHight = $('.b-header').outerHeight(),
101            url_sp = url.split('?id='),
102            hash = '#' + url_sp[url_sp.length - 1],
103            target = $(hash);
104        
105        $('html, body').animate({
106            scrollTop: target.offset().top - headerHight
107        }, 0, 'swing', function() {
108			target.attr('tabindex', '-1');
109			document.querySelector(hash)?.focus({preventScroll: true});
110		});
111        return false;
112    } else if (location.hash) {
113				const headerHight = $('.b-header').outerHeight();
114        const hash = location.hash;
115        const target = $(hash);
116
117        if (target.length) {
118            $('html, body').animate({
119                scrollTop: target.offset().top - headerHight
120            }, 0, 'swing', function() {
121                target.attr('tabindex', '-1');
122                document.querySelector(hash)?.focus({ preventScroll: true });
123            });
124        }
125    }
126});
127
128
129/************************************************
130	
131	to top
132	
133*************************************************/
134$(()=> {
135    const
136        topBtn = $('.js-to_top_btn'),
137        wHeight = window.innerHeight;
138
139    $window.scroll(()=> {
140        if ($(this).scrollTop() > wHeight / 2) {
141            topBtn.addClass('is-show');
142        } else {
143            topBtn.removeClass('is-show');
144        }
145    });
146
147    topBtn.click(()=> {
148        $('body,html').animate({
149            scrollTop: 0
150        }, 400);
151        return false;
152    });
153});
154
155/************************************************
156
157	menu open
158
159*************************************************/
160$(()=> {
161	const
162		modalOption  = {
163		disableScroll: true,
164		disableFocus: true,
165		awaitOpenAnimation: true,
166		awaitCloseAnimation: true,
167		};
168
169	MicroModal.init(modalOption);
170});
171
172/************************************************
173
174	緊急のお知らせ表示時の位置調整
175
176*************************************************/
177/*
178$(()=> {
179	if($('.b-header__alert').length < 0) return false;
180
181	let timer;
182
183	setMrgin();
184	
185	$window.on(resizeEvent(), () => {
186		if(timer) clearTimeout;
187		timer = setTimeout(() => {
188			setMrgin();
189		}, 50);
190	});
191
192	function setMrgin() {
193		
194		const alertHeight = $('.b-header__alert').outerHeight();
195		$('#main').css('padding-top', `${alertHeight}px`);
196	}
197});
198*/
199
200/* ------------------------------------------------------------
201	Window Resized
202* ------------------------------------------------------------ */
203// ----------------------------------------
204// ブラウザサイズにより切り替え
205// ----------------------------------------
206function checkViewWidth() {
207	if (!common.viewWidth) common.viewWidth = {};
208	var vw;
209	if (window.matchMedia("(max-width: " + breakPoints.p + "px)").matches) {
210		vw = "sp";
211	}
212	if (window.matchMedia("(min-width: " + (breakPoints.p + 1) + "px)").matches) {
213		vw = "pc";
214	}
215	common.viewWidth = vw;
216	var $html = $("html");
217	if (common.viewWidth == "pc") {
218		//PCだったら
219		$html.removeClass("sp").addClass("pc");
220	} else {
221		//スマホだったら
222		$html.removeClass("pc").addClass("sp");
223	}
224}
225$(window).on("resize", checkViewWidth);
226
227
228/* ------------------------------------------------------------
229	ローディング
230* ------------------------------------------------------------ */
231var isLoading = false;
232$(function() {
233	setTimeout(function(){
234		$('html').addClass('is-tratition-start');
235	}, 500)
236	// 強制終了
237	setTimeout(function(){
238		$('html').addClass('is-loaded');
239	}, 10000)
240});
241$(window).on('load', function() {
242	if (isLoading==false) {
243		loadingInit();
244	}
245});
246function loadingInit() {
247	function loading() {
248		$('html').addClass('is-loaded');
249	}
250	loading();
251}
252
253/* ------------------------------------------------------------
254	画像など含めてページ読込み完了後に実行
255* ------------------------------------------------------------ */
256/* 実行
257-------------------------------------------------- */
258$(window).on({
259	load:function(){
260		common.searchBar.init();
261		common.gtmtest.init();
262	},
263	scroll:function(){
264	},
265	resize:function(){
266	}
267});
268
269function loaded() {
270	common.effect.init();
271}
272/* ------------------------------------------------------------
273	DOM構築後実行
274* ------------------------------------------------------------ */
275/* 実行
276-------------------------------------------------- */
277$(function () {
278	checkViewWidth();
279	common.accordion.init();
280	common.more.init();
281	common.tab.init();
282	common.tel.init();
283	common.imgGuard.init();
284	common.microModal.init();
285});
286
287common = {
288	// ----------------------------------------
289	// gsapタイムライン
290	// ----------------------------------------
291	gsap_tl: {
292		init: function init(e){
293			var positionStart = e.getAttribute("data-position-start");
294			var positionEnd = e.getAttribute("data-position-end");
295			var tl = gsap.timeline({
296				scrollTrigger:{
297					trigger: e,
298					start: positionStart,
299					end: positionEnd,
300					once: true,
301					//markers: true,
302					toggleClass: {
303						targets: e,
304						className: "is-active"
305					}
306				}
307			})
308			return tl;
309		}
310	},
311	// ----------------------------------------
312	// gsapエフェクト
313	// ----------------------------------------
314	effect: {
315		init: function init() {
316			const trigger = gsap.utils.toArray('.js-fade-ins.js-trigger');
317			trigger.forEach(function (e) {
318				const elems = e.querySelectorAll('.js-fade-in');
319				var positionStart = e.getAttribute("data-position-start");
320				var positionEnd = e.getAttribute("data-position-end");
321				gsap.set(elems, {
322					y: 30,
323					opacity: 0,
324				},.3);
325				ScrollTrigger.create({
326					trigger: e,
327					start: positionStart,
328					end: positionEnd,
329					once: true,
330					toggleClass: {
331						targets: e,
332						className: "is-active"
333					},
334					onEnter: () => gsap.to(elems, {
335						y: 0,
336						opacity: 1,
337						stagger: 0.2,
338						duration: 1,
339					}),
340				});
341			})
342		}
343	},
344	// ----------------------------------------
345	// アコーディオン
346	// ----------------------------------------
347	accordion : {
348		init: function init() {
349			const _this = this;
350			$('.js-accordion__trigger').not('.js-accordion-one .js-accordion__trigger').on('click', function () {
351				var $isClosed = $(this).closest('.js-accordion').toggleClass('is-active').hasClass('is-active');
352				if ($isClosed) {
353					_this.__Flag_open = true;
354					gsap.to($(this).next('.js-accordion__content'),{
355						height: 'auto',
356						duration: 0.5,
357						ease: "power2.inOut"
358					});
359					$(this).attr("aria-expanded", true);
360					$(this).next('.js-accordion__content').attr("aria-hidden", false);
361				} else {
362					_this.__Flag_open = false;
363					gsap.to($(this).next('.js-accordion__content'),{
364						height: 0,
365						duration: 0.5,
366						ease: "power2.inOut"
367					});
368					$(this).attr("aria-expanded", false);
369					$(this).next('.js-accordion__content').attr("aria-hidden", true);
370				}
371			});
372			var url = location.href;
373			url = url.split("#")[0];
374			if ( (url.indexOf('?id=accordion') != -1)){
375				const
376					headerHight = $('.b-header').outerHeight(),
377					url_sp = url.split('?id='),
378					hash = '#' + url_sp[url_sp.length - 1],
379					target = $(hash);
380				
381				$('html, body').animate({
382					scrollTop: target.offset().top - headerHight
383				}, 1000, 'swing', function() {
384					target.attr('tabindex', '-1');
385					document.querySelector(hash)?.focus({preventScroll: true});
386				});
387				var $isClosed = $(target).toggleClass('is-active').hasClass('is-active');
388				if ($isClosed) {
389					_this.__Flag_open = true;
390					gsap.to($(target).find('.js-accordion__content'),{
391						height: 'auto',
392						duration: 0.5,
393						ease: "power2.inOut"
394					});
395					$(target).attr("aria-expanded", true);
396					$(target).find('.js-accordion__content').attr("aria-hidden", false);
397				} else {
398					_this.__Flag_open = false;
399					gsap.to($(target).next('.js-accordion__content'),{
400						height: 0,
401						duration: 0.5,
402						ease: "power2.inOut"
403					});
404					$(target).find("aria-expanded", false);
405					$(target).find('.js-accordion__content').attr("aria-hidden", true);
406				}
407			}
408			$('.b-accordion').each(function() {
409				var $this = $(this);
410				var $trigger = $this.find('.b-accordion__trigger');
411				$trigger.append( '<span class="b-accordion__trigger-bars"><span class="b-accordion__trigger-bar"></span><span class="b-accordion__trigger-bar"></span></span>' );
412			});
413			$('.b-accordion2').each(function() {
414				var $this = $(this);
415				var $trigger = $this.find('.b-accordion2__trigger');
416				$trigger.append( '<span class="b-accordion__trigger-bars"><span class="b-accordion__trigger-bar"></span><span class="b-accordion__trigger-bar"></span></span>' );
417			});
418		},
419		open: function open() {
420			const _this = this;
421			_this.__Flag_open = true;
422			$('.js-accordion.is-active').children('.js-accordion__trigger').attr("aria-expanded", true);
423			$('.js-accordion.is-active').children('.js-accordion__content').attr("aria-hidden", false);
424			gsap.to($('.js-accordion.is-active').children('.js-accordion__content'),{
425				height: 'auto',
426				duration: 0.5,
427				ease: "power2.inOut"
428			});
429		},
430		close: function close() {
431			const _this = this;
432			_this.__Flag_open = false;
433			$('.js-accordion').removeClass('is-active')
434			$('.js-accordion').children('.js-accordion__trigger').attr("aria-expanded", false);
435			$('.js-accordion').children('.js-accordion__content').attr("aria-hidden", true);
436			gsap.to($('.js-accordion').children('.js-accordion__content'),{
437				height: 0,
438				duration: 0,
439				ease: "power2.inOut"
440			});
441		}
442	},
443	// ----------------------------------------
444	// タブ
445	// ----------------------------------------
446	tab : {
447		init: function init() {
448			$(document).on('click', '.js-tab__trigger', function() {
449				var $this = $(this),
450					$tab = $this.parents('.js-tabs'),
451					$tab_trigger = $tab.find('.js-tab__trigger'),
452					$tab_content = $tab.find('.js-tab__content');
453				$tab_trigger.attr("aria-selected", false);
454				$this.attr("aria-selected", true);
455				var $thisIndex =  $tab_trigger.index(this);
456				$tab_content.attr("aria-selected", false);
457				$tab_content.eq($thisIndex).attr("aria-selected", true);
458				//更新
459				//ScrollTrigger.refresh();
460			});
461
462			//閉じる
463			$(document).on('click', '.js-tab__trigger-close', function() {
464				var $this = $(this),
465					$tab = $this.parents('.js-tabs'),
466					$tab_trigger = $tab.find('.js-tab__trigger'),
467					$tab_triggerclose = $tab.find('.js-tab__trigger-close'),
468					$tab_content = $tab.find('.js-tab__content');
469				$tab_content.attr("aria-selected", true);
470				$tab_content.eq($thisIndex).attr("aria-selected", false);
471				var $thisIndex =  $tab_triggerclose.index(this);
472				$tab_content.attr("aria-selected", false);
473				$tab_content.eq($thisIndex).attr("aria-selected", false);
474				$tab_trigger.attr("aria-selected", false);
475				$this.attr("aria-selected", true);
476				//更新
477				//ScrollTrigger.refresh();
478			});
479
480			//タブ切り替えの中でタブ切り替え
481			$(document).on('click', '.js-tab__sub-trigger', function() {
482				var $this = $(this),
483					$tab = $this.parents('.js-tab__content'),
484					$tab_trigger = $tab.find('.js-tab__sub-trigger'),
485					$tab_content = $tab.find('.js-tab__sub-content');
486				$tab_trigger.attr("aria-selected", false);
487				$this.attr("aria-selected", true);
488				var $thisIndex =  $tab_trigger.index(this);
489				$tab_content.attr("aria-selected", false);
490				$tab_content.eq($thisIndex).attr("aria-selected", true);
491				//更新
492				ScrollTrigger.refresh();
493			});
494		}
495	},
496	// ----------------------------------------
497	// 電話番号
498	// ----------------------------------------
499	tel : {
500		init: function init() {
501			if(common.viewWidth == 'sp'){
502				$('.js-tel-link').each(function() {
503					var str = $(this).html();
504					if ($(this).children().is('img')) {
505					$(this).html($('<a>').attr('href', 'tel:' + $(this).children().attr('alt').replace(/-/g, '')).append(str + '</a>'));
506						} else {
507					$(this).html($('<a class="b-link">').attr('href', 'tel:' + $(this).text().replace(/-/g, '')).append('<span class="o-link-out">' + str + '</span></a>'));
508					}
509				});
510			}
511		}
512	},
513	// ----------------------------------------
514	// 画像保存禁止
515	// ----------------------------------------
516	imgGuard : {
517		init: function init() {
518			$(function() {
519				$(".b-guard").on('contextmenu', function(e) {
520					return false;
521				});
522			});
523		}
524	},
525	// ----------------------------------------
526	// サイト内検索バー デザイン
527	// ----------------------------------------
528	searchBar : {
529		init: function init() {
530			$(".gsc-input").attr('placeholder', '検索キーワードを入力');
531		}
532	},
533	// ----------------------------------------
534	// グリッド
535	// ----------------------------------------
536	grid: {
537		init: function init() {
538			$(".o-grid").each(function () {
539				var $this = $(this);
540				if($(this).children('[class*="o-grid-item-"]:not(.o-grid-item-sp-12)').length) {
541					$this.addClass('o-grid-sp');
542				}
543			});
544		}
545	},
546	// ----------------------------------------
547	// GTMテスト
548	// ----------------------------------------
549	gtmtest: {
550		init: function init() {
551			const searchButton = $(".gsc-search-button-v2");
552			const formInput = $("#gsc-i-id1");
553			searchButton.click(function () {
554				var inputVal = formInput.val();
555				if (!inputVal) {
556					return false;
557				} else {
558					dataLayer.push({
559						'event': 'hakatazaSearch',
560						'hakatazaSearchKeyword': inputVal
561					});
562				}
563			});
564
565			formInput.keydown(function(e){
566				var inputVal = formInput.val();
567				if (e.key === "Enter") {
568					if (!inputVal) {
569						return false;
570					} else {
571						dataLayer.push({
572							'event': 'hakatazaSearch',
573							'hakatazaSearchKeyword': inputVal
574						});
575					}
576				}
577			});
578		}
579	},
580	// ----------------------------------------
581	// マイクロモーダル
582	// ----------------------------------------
583	microModal: {
584		init: function init() {
585			const $prevButton = $('.js-modal-prev');
586			const $nextButton = $('.js-modal-next');
587			$prevButton.click(function () {
588				let $modalId = $(this).parents('.js-modal').attr('id');
589				let $nextModalId = $(this).parents('.js-modal').prev('.js-modal').attr('id');
590				if($nextModalId) {
591					MicroModal.close($modalId);
592					MicroModal.show($nextModalId, {
593						disableScroll: true,
594						disableFocus: true,
595						awaitOpenAnimation: true,
596						awaitCloseAnimation: true,
597					});
598				}
599			});
600			$nextButton.click(function () {
601				let $modalId = $(this).parents('.js-modal').attr('id');
602				let $nextModalId = $(this).parents('.js-modal').next('.js-modal').attr('id');
603				if($nextModalId) {
604					MicroModal.close($modalId);
605					MicroModal.show($nextModalId, {
606						disableScroll: true,
607						disableFocus: true,
608						awaitOpenAnimation: true,
609						awaitCloseAnimation: true,
610					});
611				}
612			});
613		}
614	},
615	// ----------------------------------------
616	// もっと見るボタン
617	// ----------------------------------------
618	more: {
619		init: function init() {
620			const _this = this;
621			$('.js-more__trigger').on('click', function () {
622				var $isClosed = $(this).closest('.js-more').toggleClass('is-active').hasClass('is-active');
623				if ($isClosed) {
624					_this.__Flag_open = true;
625					gsap.to($(this).prev('.js-more__content'),{
626						height: 'auto',
627						duration: 0.5,
628						ease: "power2.inOut"
629					});
630					$(this).attr("aria-expanded", true);
631					$(this).text('閉じる');
632				} else {
633					console.log('close');
634					_this.__Flag_open = false;
635					gsap.to($(this).prev('.js-more__content'),{
636						height: 0,
637						duration: 0.5,
638						ease: "power2.inOut"
639					});
640					$(this).attr("aria-expanded", false);
641					$(this).text('もっと見る');
642				}
643			});
644			$('.b-more').each(function() {
645				var $this = $(this);
646				var $trigger = $this.find('.b-more__trigger');
647				$trigger.append( '<span class="b-more__trigger-bars"><span class="b-more__trigger-bar"></span><span class="b-more__trigger-bar"></span></span>' );
648			});
649		},
650		open: function open() {
651			const _this = this;
652			_this.__Flag_open = true;
653			$('.js-more.is-active').children('.js-more__trigger').attr("aria-expanded", true);
654			$('.js-more.is-active').children('.js-more__content').attr("aria-hidden", false);
655			gsap.to($('.js-more.is-active').children('.js-more__content'),{
656				height: 'auto',
657				duration: 0.5,
658				ease: "power2.inOut"
659			});
660		},
661		close: function close() {
662			const _this = this;
663			_this.__Flag_open = false;
664			$('.js-more').removeClass('is-active')
665			$('.js-more').children('.js-more__trigger').attr("aria-expanded", false);
666			$('.js-more').children('.js-more__content').attr("aria-hidden", true);
667			gsap.to($('.js-more').children('.js-more__content'),{
668				height: 0,
669				duration: 0,
670				ease: "power2.inOut"
671			});
672		}
673	}
674}

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.