PageSourceSearch

https://www.torican.jp/common/js/default.js

js torican.jp collected 2026-10-02 05:52:32 UTC 3,682 bytes, 154 lines download raw bytes

1// JavaScript Document
2"use strict";
3
4// スムーズスクロール
5$(function(){
6	$('a[href^="#"]').on('click', function(){
7		var speed = 400;
8		var href = $(this).attr('href');
9		var target = $(href == '#' || href == '' ? 'html' : href);
10		var offset = target.offset().top;
11		$('body,html').animate({
12				scrollTop:offset
13			}, speed, 'swing');
14		return false;
15	});
16});
17
18
19// アンカーリンクバグ対策
20$(window).on('load',function(){
21	var id = location.hash;
22	var speed = 400;
23	if(''!=id){
24		var pos = $(id).offset().top;
25		$('html').animate({ scrollTop:pos},speed);
26	}
27});
28
29
30// svgスプライト表示バグ対策
31(function(document, window){
32	document.addEventListener('DOMContentLoaded',function(){
33		var baseUrl = window.location.href
34			.replace(window.location.hash, '');
35		[].slice.call(document.querySelectorAll('use[*|href]'))
36			.filter(function(element) {
37				return (element.getAttribute('xlink:href').indexOf('#') === 0);
38			})
39			.forEach(function(element) {
40				element.setAttribute('xlink:href', baseUrl + element.getAttribute('xlink:href'));
41			});
42	}, false);
43}(document, window));
44
45
46// PCでのTELリンク無効
47var ua = navigator.userAgent.toLowerCase();
48var isMobile = /iphone/.test(ua)||/android(.+)?mobile/.test(ua);
49if (!isMobile){
50	$('a[href^="tel:"]').on('click', function(e) {
51		e.preventDefault();
52	});
53}
54
55
56// 読み込み検知
57$(window).on('load',function(){
58	$('body').removeClass('do');
59	$('body').addClass('done');
60});
61
62
63// スクロール検知
64$(window).scroll(function(){
65	if( $(window).scrollTop() > 0){
66		$('body').removeClass('scrollTop');
67	} else {
68		$('body').addClass('scrollTop');
69	}
70});
71$(function(){
72	var timeoutId;
73	window.addEventListener('scroll',function(){
74		$('body').addClass('scroll');
75		clearTimeout(timeoutId);
76		timeoutId = setTimeout(function(){
77			$('body').removeClass('scroll');
78		},100);
79	});
80});
81
82
83// グローバルナビ
84$(function(){
85	$('#navButton').click(function(){
86		$('body').toggleClass('nav');
87	});
88	$('body').on('touchstart', onTouchStart);
89	$('body').on('touchmove', onTouchMove);
90	$('body').on('touchend', onTouchEnd);
91	var direction, position;
92	function onTouchStart(event){
93		position = getPosition(event);
94		direction = '';
95	}
96	function onTouchMove(event){
97		if (position - getPosition(event) > 70) {
98			direction = 'left';
99		} else if (position - getPosition(event) < -70){
100			direction = 'right';
101		}
102	}
103	function onTouchEnd(event){
104		if (direction == 'right'){
105			$('body').removeClass('nav');
106		}
107	}
108	function getPosition(event) {
109		return event.originalEvent.touches[0].pageX;
110	}
111});
112
113
114// トップへ戻るリンク
115$(function(){
116	var topBtn = $('#pageTop');
117	topBtn.hide();
118	$(window).scroll(function(){
119		if ($(this).scrollTop() > $(window).height()){
120			topBtn.fadeIn();
121		} else {
122			topBtn.fadeOut();
123		}
124	});
125});
126
127
128// 画像サムネイル化
129$(function(){
130	$('.thumb').each(function(){
131		var srcImg = $(this).attr('src');
132		var classImg = $(this).attr('class');
133		if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('trident') >= 0) {
134			$(this).wrap('<div class="'+classImg+'" style="background-image: url('+srcImg+');">');
135		} else {
136			$(this).wrap('<div class="'+classImg+'">');
137		}
138		$(this).removeAttr('class');
139	});
140});
141
142
143// IE対応
144var userAgent = window.navigator.userAgent.toLowerCase();
145if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('trident') >= 0) {
146	$('body').prepend('\
147		<script src="/common/js/plugin/ofi.min.js"></script>\
148		<script src="/common/js/plugin/svgxuse.min.js"></script>\
149	');
150}
151
152
153
154

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.