PageSourceSearch

https://enmusubi-izumo.com/blog/wp-content/themes/hiranoya_theme/cmn/js/common.js

js enmusubi-izumo.com collected 2026-10-08 04:48:53 UTC 13,242 bytes, 454 lines download raw bytes

1/*/*=========================================
2	++ common.js ++ Ver.1.5.20
3	Last update 2018.11.20
4==========================================*/
5/*
6
7* 2018 11/20  *ブラウザ判定処理を一新
8* 2018 10/25  *jQuery 3系 に対応
9
10*/
11
12
13
14/**
15 * Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
16 * Dual licensed under MIT and GPL.
17 * @author Ariel Flesler
18 * @version 1.4.3.1
19 */
20 // EXSAMPLE  ===   $.scrollTo('#Global', 1500);
21
22(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
23
24
25
26//============================================
27//	Detecting Browser & Device Ver.1.4.2
28//============================================
29
30//++++++++++++ モバイル/タブレット/ブラウザ判定処理 ++++++++++++
31
32//ブラウザ/デバイス 種別
33var isMobile=false,isTablet=false,isRetina=false,isMobileTablet=false,isAndroid=false;;
34
35	//モバイル タブレット 判定
36	//https://w3g.jp/blog/js_browser_sniffing2015
37	var _ua = (function(u){
38		return {
39			Tablet:(u.indexOf("windows") != -1 && u.indexOf("touch") != -1 && u.indexOf("tablet pc") == -1)
40				|| u.indexOf("ipad") != -1
41				|| (u.indexOf("android") != -1 && u.indexOf("mobile") == -1)
42				|| (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1)
43				|| u.indexOf("kindle") != -1
44				|| u.indexOf("silk") != -1
45				|| u.indexOf("playbook") != -1,
46			Mobile:(u.indexOf("windows") != -1 && u.indexOf("phone") != -1)
47				|| u.indexOf("iphone") != -1
48				|| u.indexOf("ipod") != -1
49				|| (u.indexOf("android") != -1 && u.indexOf("mobile") != -1)
50				|| (u.indexOf("firefox") != -1 && u.indexOf("mobile") != -1)
51				| u.indexOf("blackberry") != -1
52		}
53	})(window.navigator.userAgent.toLowerCase());
54
55	//モバイル
56	if(_ua.Mobile){
57		isMobile=true;
58		isMobileTablet=true;
59	}
60	//タブレット
61	if(_ua.Tablet){
62		isTablet=true;
63		isMobileTablet=true;
64	}
65
66	//Retina Display 判定
67	if(window.retina || window.devicePixelRatio > 1){
68		isRetina=true;
69	}
70
71	//Android 判定
72	if (/android[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
73		isAndroid=true;
74	}
75
76
77
78
79//============================================
80//	デバイス ブラウザ別の処理
81//============================================
82
83//++++++++++++ モバイル/タブレット クラス追加 ++++++++++++
84(function($) {
85	$(function() {
86		if (isMobile) {
87				//HTMLにclass isMobileを追加
88				$('html').addClass('isMobile');
89				$('html').addClass('isMobileTablet');
90		}else if(isTablet){
91				//HTMLにclass isTabletを追加
92				$('html').addClass('isTablet');
93				$('html').addClass('isMobileTablet');
94		}
95		//Retina Display isRetina クラス追加
96		if (isRetina) {
97			$('html').addClass('isRetina');
98		}
99	});
100})(jQuery);
101
102
103
104
105//============================================
106//	Veiwport 切り替え Tablet
107//============================================
108
109(function($) {
110	$(function() {
111
112	if (isTablet) {
113		var metalist = document.getElementsByTagName('meta');
114		for(var i = 0; i < metalist.length; i++) {
115			var name = metalist[i].getAttribute('name');
116			if(name && name.toLowerCase() === 'viewport') {
117			metalist[i].setAttribute('content', 'target-densitydpi=device-dpi, width=1040, maximum-scale=1.0, user-scalable=yes');
118			break;
119			}
120		}
121	}
122
123	});
124})(jQuery);
125
126
127//++++++ Copyright ++++++ OLD
128// Copyright &copy; <script>thisYear()</script>
129function thisYear(){
130var day=new Date();
131var year=day.getFullYear();
132return document.write(year);
133}
134
135//++++++ Copyright ++++++
136// Copyright <span id="copyYear">&copy;</span>
137(function($) {
138	$(function() {
139		var date=new Date();
140		var copyYear=date.getFullYear();
141			copyYear = "&copy; "+copyYear
142		$('#copyYear').html(copyYear);
143	});
144})(jQuery);
145
146//++++++ Page Anc Scroll ++++++
147(function($) {
148	$(function() {
149		$(document).on("click","a[href*=#],area[href*=#]", function(){
150		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
151		&& location.hostname == this.hostname) {
152			var $target = $(this.hash);
153			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
154			if ($target.length) {
155				var targetOffset = $target.offset().top - 20;
156				$('html,body').animate({scrollTop: targetOffset}, 800);
157				return false;
158			}
159		}
160		});
161	});
162})(jQuery);
163
164//++++++++++++ Bookmark ++++++++++++
165//EXSAMPLE	bookmark('http://~~~','My Site')
166function bookmark(address,sitename) {
167	if (window.sidebar) {
168	window.sidebar.addPanel(sitename, address,"");
169	} else if( document.all ) {
170	window.external.AddFavorite(address, sitename);
171	} else if( window.opera && window.print ) {
172
173	return true;
174	}else {
175	alert("Ctrl + D を押してください")
176	}
177}
178//++++++++++++ Bookmark Each ++++++++++++
179(function($) {
180	$(function() {
181		var address =  location.href;
182		var title = document.title;
183		//サイト名を設定(空欄の場合はtitleタグを取得)
184		var sitename = "";
185		var fevName="";
186
187		if(sitename == ""){
188			fevName=title;
189		}else{
190			fevName=sitename;
191		}
192		//.fevをクリックで発火
193		$('.fev').click(function(){
194		if (window.sidebar) {
195			window.sidebar.addPanel(fevName, address,"");
196			} else if( document.all ) {
197			window.external.AddFavorite(address, fevName);
198			} else if( window.opera && window.print ) {
199
200			return true;
201			}else {
202			alert("Ctrl + D を押してください")
203			}
204		});
205	});
206})(jQuery);
207
208//IE6 Massage
209//if(isIE6){}
210function ie6Mess(){
211alert('申し訳ありません。\nお使いのブラウザではこの機能がご利用いただけません。');
212}
213
214
215//++++++++++++ サブナビゲーション 現在地表示 ++++++++++++
216(function($) {
217	$(function() {
218
219		//サブナビのタグを指定
220		var navTag = ".side_link li"
221
222		//表示URLからファイル名を抽出
223		var pathURL = location.href;
224		var pathHash = location.hash;
225		pathURL =pathURL.replace(pathHash,'');
226		pathURL =pathURL.replace(/^http:\/\/(.*?)\//,'/');
227		var path = location.href;
228		path=path.replace(pathHash,'');
229		path=path.replace(/\\/g,'/').replace(/(.*)\//,'' );
230
231		$(navTag).each(function(){
232			//ナビの指定リンクを取得
233			var myURL = $(this).find('a').attr('href');
234			myURL =myURL.replace(/^http:\/\/(.*?)\//,'/');
235			var myHref = $(this).find('a').attr('href');
236				myHref = myHref.replace(/\\/g,'/').replace(/(.*)\//,'' );
237
238				//表示URLと指定リンクが同じ場合 class activeを追加
239				if(myHref!=''){
240				if(myHref==path){
241					$(this).addClass('active')
242				}
243				}
244				else if(myURL==pathURL){
245					$(this).addClass('active')
246				}
247		});
248	});
249})(jQuery);
250
251
252//++++++++++++ マウスオーバー 画像エフェクト ++++++++++++
253(function($) {
254	$(function() {
255
256		var targSelector = ".ro a img";
257		//IE8以下を判定
258		var isIE_lt9;
259		//opacityをサポートしていないのはきっとIE8以下
260		if(!jQuery.support.opacity){
261			isIE_lt9 = true;
262		}
263			//++++++++画像エフェクト(リンク画像のみ)+++++
264			//FF CSSバグFIX 背景色追加
265			$(targSelector).css("background-color","#ffffff");
266			//マウスオーバー処理
267			$(document).on("mouseenter",targSelector, function(){
268			var imgExtention = $(this).attr('src');
269				//IE8以下はpngを無視
270				if(imgExtention.match(/\.png$/i) && isIE_lt9){
271				}else{
272					$(this).animate( {
273					opacity: '0.8'
274					},{duration: 200, easing: 'swing'
275					});
276				}
277			});
278			//マウスアウト処理
279			$(document).on("mouseleave",targSelector, function(){
280				$(this).animate( {
281					opacity: '1'
282					},{duration: 200, easing: 'swing'
283				});
284			});
285	});
286})(jQuery);
287
288
289
290
291
292//++++++リストアイテム CSS 制御+++++++
293(function($) {
294	$(function() {
295		//最後のボーダーを消す
296		$(".side_link,.entry-content,#newstopics").each(function(){
297			$(this).find("li:last-child,dl:last-child,.list_support:last-child,.list_newstopics:last-child").css({
298				"border-bottom-style": "none",
299				"border-bottom-width": "0"
300			});
301		});
302		//最後のマージンを消す
303		$(".side_link").each(function(){
304			$(this).find("li:last-child,dl:last-child").css({
305				"margin-bottom": "0"
306			});
307		});
308	});
309})(jQuery);
310
311
312//++++++ Retina Display イメージ差し替え+++++++
313(function($) {
314	$(function() {
315		//.Retina の場合 イメージのパスを書き換え
316		//@2x.jpg or @2x.png
317		$(".Retina").each(function(){
318			if(isRetina){
319				var mySrc = $(this).find("img").attr('src');
320					mySrc = mySrc.replace(/(\.jpg|\.png)/gi,'@2x$1');
321					$(this).attr('src',mySrc);
322
323			}
324		});
325	});
326})(jQuery);
327
328
329//++++++ナビ固定+++++++
330(function($) {
331	$(function() {
332	var nav    = $('#head_box'),
333	offset = nav.offset();
334
335$(window).scroll(function () {
336  if($(window).scrollTop() > offset.top) {
337    nav.addClass('fixed');
338  } else {
339    nav.removeClass('fixed');
340  }
341});
342	});
343})(jQuery);
344
345
346
347(function($) {
348$(function() {
349var $grid = $('.grid'),
350	emptyCells = [],
351	i;
352
353// 子パネル (ul.cell) の数だけ空の子パネル (ul.cell.is-empty) を追加する。
354for (i = 0; i < $grid.find('.cell').length; i++) {
355	emptyCells.push($('<div>', { class: 'cell is-empty' }));
356}
357
358$grid.append(emptyCells);
359});
360})(jQuery);
361
362
363
364
365
366$(function(){
367  fade('.dropmenu');
368});
369
370function fade(elm){
371  var $fade = $(elm),
372	  $body = $('body');
373  // .toggleWrapを非表示にしておく
374  $fade.addClass('hide');
375
376  // #toggleがクリックされた時に、.hideの付け外しで .toggleWrapの表示・非表示を切り替え
377  // .addClass('animation');でアニメーションのCSSを適応
378  $('.menu-btn').on('click', function(){
379	$fade.toggleClass('hide').addClass('animation');
380	$('.menu-btn').toggleClass('active');
381
382	// スクロールの制御
383	// .hideを持っている状態はメニューが閉じている状態で、このときは.no-scrollは不要
384	if ($fade.hasClass('hide')) {
385	  $body.removeClass('no-scroll').off('.noScroll');
386	} else {
387	  // メニューが開いている時に、bodyに.no-scrollを追加してスクロールさせない
388	  $body.addClass('no-scroll').on('touchmove.noScroll', function(e){
389		e.preventDefault();
390	  });
391	}
392  });
393}
394
395
396
397//category
398$(function(){
399
400  $(".CategoryTitle").on("click", function() {
401	$(this).toggleClass("active");
402
403	$(this).next().slideToggle();
404  });
405})
406
407
408
409
410
411$(function() {
412  var Accordion = function(el, multiple) {
413	this.el = el || {};
414	// more then one submenu open?
415	this.multiple = multiple || false;
416
417	var dropdownlink = this.el.find('.dropdownlink');
418	dropdownlink.on('click',
419					{ el: this.el, multiple: this.multiple },
420					this.dropdown);
421  };
422
423  Accordion.prototype.dropdown = function(e) {
424	var $el = e.data.el,
425		$this = $(this),
426		//this is the ul.submenuItems
427		$next = $this.next();
428
429	$next.slideToggle();
430	$this.parent().toggleClass('open');
431
432	if(!e.data.multiple) {
433	  //show only one menu at the same time
434	  $el.find('.submenuItems').not($next).slideUp().parent().removeClass('open');
435	}
436  }
437
438  var accordion = new Accordion($('.accordion-menu'), false);
439})
440
441
442$(function(){
443var nav    = $('.primaryS'),
444	offset = nav.offset();
445
446$(window).scroll(function () {
447  if($(window).scrollTop() > offset.top - 20) {
448	nav.addClass('fixed');
449  } else {
450	nav.removeClass('fixed');
451  }
452});
453});
454

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.