PageSourceSearch

https://www.city.morioka.iwate.jp/_template_/_site_/_default_/_res/js/smp.js?z

js city.morioka.iwate.jp collected 2026-09-24 19:12:43 UTC 17,904 bytes, 517 lines download raw bytes

1//------------------------------------------------------------------------------
2//	スマホ表示機能
3//	Copyright (C) 2011 FUTUREINN CO., LTD. All Rights Reserved.
4//------------------------------------------------------------------------------
5//-------------------------------------------------
6// ▼各種設定 変更可能エリア ここから
7//-------------------------------------------------
8FI.KEEP_DAYS = 100;								//クッキーの保存日数
9//-------------------------------------------------
10// ▲各種設定 変更可能エリア ここまで
11//-------------------------------------------------
12FI.sm = false;									//スマホ表示フラグ
13FI.COOKIE_OPT ={ expires: FI.KEEP_DAYS, path: '/' };
14
15	//ユーザーエージェントでスマホかどうかの判定 
16	var agent = navigator.userAgent;
17	if(agent.search(/iPhone/) != -1  || agent.search(/iPod/) != -1 || agent.search(/Android/) != -1){
18		FI.sm = true;
19	}
20
21	(function(){
22		var $ = FI.jQuery;
23		
24		/**
25		 * jQuery Cookie plugin
26		 *
27		 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
28		 * Dual licensed under the MIT and GPL licenses:
29		 * http://www.opensource.org/licenses/mit-license.php
30		 * http://www.gnu.org/licenses/gpl.html
31		 * -------------------------------------------------
32		 * 2011 jQuery.noConflict(true)するため、同じ名前空間に取込
33		 *
34		 */
35		$.cookie = function (key, value, options) {
36		    // key and at least value given, set cookie...
37		    if (arguments.length > 1 && String(value) !== "[object Object]") {
38		        options = $.extend({}, options);
39		        if (value === null || value === undefined) {
40		            options.expires = -1;
41		        }
42		        if (typeof options.expires === 'number') {
43		            var days = options.expires, t = options.expires = new Date();
44		            t.setDate(t.getDate() + days);
45		        }
46		        value = String(value);
47		        return (document.cookie = [
48		            encodeURIComponent(key), '=',
49		            options.raw ? value : encodeURIComponent(value),
50		            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
51		            options.path ? '; path=' + options.path : '',
52		            options.domain ? '; domain=' + options.domain : '',
53		            options.secure ? '; secure' : ''
54		        ].join(''));
55		    }
56		    // key and possibly options given, get cookie...
57		    options = value || {};
58		    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
59		    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
60		};
61		//ここからオリジナル-----------------------------------------------------------------------------------
62
63		// クッキーの内容を取得
64		if($.cookie("view_mode") == "smp"){
65			FI.sm = true;
66		}else if($.cookie("view_mode") == "pc"){
67			FI.sm = false;
68		}
69
70		$(function (){
71			//「pconly」クラスのオブジェクトを削除
72			if(FI.sm){
73				//-------------------------------------------------
74
75				//初期処理
76				$('.pconly').each(function(){
77						$(this).remove();
78				});
79				$('#viewmode_smp').attr('aria-current', 'page');
80				$('#wrap').addClass('smpmode');
81
82				//-------------------------------------------------
83				// 【専用】グローバルナビの画像をテキストに変換
84				$('.subnavi1').find('img').each(function(){
85					var param1 = $(this).attr("alt");
86					$(this).replaceWith(param1);
87				});
88				$('.subnavi1').find('img').each(function(){
89					var param1 = $(this).attr("alt");
90					$(this).replaceWith(param1);
91				});
92				//-------------------------------------------------
93				// 表示位置の変更(プロローグ)
94				if($(".portal #kinkyumail").length){
95					// トップのgnaviは折りたたまない
96					$kinkyumail = $('#kinkyumail');
97					$("#topsearch").before($kinkyumail);
98				}
99				
100				//-------------------------------------------------
101				// ◆下部メニュー
102				//目的から探す
103				if($("#hpurpose").length){
104					$hpurpose = $('#hpurpose');
105					$($hpurpose).appendTo("#jssmpbtmnavi04");
106					
107					if($('#wrap.portal').length == 0){
108						$("#hpurpose .tismenu span").text("検索");
109					}
110				}
111				
112				//-------------------------------------------------
113				// ポータルサイトのとき
114				if($('#wrap.portal').length){
115					potalPosition = function(){
116						//浮いている要素を.bannerwrapの高さ分下げる
117						var bnrHeight = $('.bannerwrap').height() / $(window).width() * 100;
118						
119						var $elements = $('#portaltlogo #portalh1, #portaltlogo .text01, #portaltlogo .text02, .pronavi ul, #slider1');
120						$elements.each(function(){
121							var $this = $(this);
122							var top = $this.css('top');
123							top = parseInt(top);
124							var topvw = top / $(window).width() * 100;
125							
126							var newTop = topvw + bnrHeight;
127							$this.css('top', newTop + 'vw');
128						});
129						
130						//#headleftのpadding-topを.bannerwrapの高さ分増やす
131						var hleft = $('#header #headleft').css('padding-top');
132						hleft = parseInt(hleft);
133						var hleftvw = hleft / $(window).width() * 100;
134						var newHleft = hleftvw + bnrHeight;
135						$("#header #headleft").css("padding-top", newHleft + 'vw');
136					}
137						
138//					$(window).on('resize', function(){
139//						potalPosition();
140//					});
141					potalPosition();
142				}
143
144
145				//-------------------------------------------------
146				// グローバルナビ ドロップダウンメニュー
147				$(function(){
148					if(($('#util').length && !$('#wrapbg.kankou').length && !$('#wrapbg.saigaitop').length) || $('#hpurposemenu').length){
149						
150						//--- ▼関数 ----------------------------
151						//開閉時にクラスを追加・削除する
152						bodyopen = function(){
153							var h = window.innerHeight;
154								
155							if($("body").hasClass("open")){
156								$("body").removeClass("open");
157								$("body").removeAttr("style");
158							}else{
159								$("body").addClass("open");
160								$("body").height(h);
161							}
162						}
163
164						//折りたたみを開いたときに高さを固定する
165						gnavismpheight = function(){
166							var h = window.innerHeight;
167							var jbnh = $("#jssmpbtmnavi").outerHeight();
168							$("#gnavismp , #hpurposemenu").css("height",h - jbnh);
169							$("#gnavismp , #hpurposemenu").css("bottom",jbnh);
170							
171							if($('#wrap.portal').length){
172								var pbwh = $(".bannerwrap").outerHeight();
173								$("#proheaderbg #hpurposemenu").css("height",h - pbwh);
174							}
175						}
176						//--- ▲関数 ----------------------------
177
178						//ボトムナビの高さを[ウインドウサイズ]―[メニューボタン下部]までの距離にする
179						// ロードとリサイズ時の処理
180						$(window).on('resize',function() {
181							gnavismpheight();
182						});
183
184						//フッタにボトムナビの高さ分を挿入
185						if($('#jssmpbtmnavi').length){
186							var jbnh = $("#jssmpbtmnavi").outerHeight();
187							$("footer").css("padding-bottom",jbnh);
188						}
189
190						//折りたたみ用の外枠、ボタン追加
191						$('#util').wrap('<div id="smpmenu">').wrap('<div id="gnavismp" aria-hidden="true" class="clearfix">');
192						$('<button class="hnmenu hnplus" aria-controls="gnavismp" aria-expanded="false"><span>メニュー</span></button>').insertBefore('#gnavismp');
193						$('<button class="hnclose pconly">閉じる</button>').appendTo('#gnavismp');
194
195						//グローバルナビを折りたたみの中に移動
196						if($('#topgnavibg , #gnavibg').length){
197							$gnavi = $('#topgnavibg , #gnavibg');
198							$("#util").before($gnavi);
199						}
200						if($('#jssmpbtmnavi01').length){
201							$gnavi = $('#smpmenu');
202							$('#jssmpbtmnavi01').append($gnavi);
203						}
204						if($('.subnavi1').length){
205							$subnavi1 = $('.subnavi1');
206							$('#topgnavibg , #gnavibg').after($subnavi1);
207							$subnavi1.children('ul').append($('#util2 .jigyousha'));
208						}
209						//詳細ページ 検索ボックスを移動
210						if($('#sitesearch form').length){
211							var $sitesearch = $('#sitesearch form');
212							$sitesearch.prependTo('#navisearchmenu');
213							$('#navisearchmenu form #key').attr('title','サイト内検索');
214							$('#navisearchmenu form label').remove();
215							$('#sitesearch').remove();
216						}
217						//トップ 検索ボックスを複製
218						if($('#search1 form').length){
219							var $topsitesearch = $('#search1 form').clone();
220							$topsitesearch.prependTo('#navisearchmenu');
221						}
222
223						//折りたたみ処理
224						$('#gnavismp').each(function() {
225							hnFlg = false;
226							var $this = $(this);
227							var $ul = $('#gnavismp');
228							var $button = $('#smpmenu .hnmenu');
229							
230							if($(this).children('*').hasClass("hnplus") ){
231								$ul.hide();
232								hnFlg = false;
233							}
234							//表示
235							$button.click(function() {
236								
237								bodyopen();
238								
239								$('#smpmenu').toggleClass("choice");
240								$('#smpmenu .hnmenu').toggleClass("hnplus").toggleClass("hnminus");
241								hnFlg = !hnFlg;
242								if(hnFlg){
243									$("#smpmenu").css('width','100%');
244									$("#smpmenu .hnmenu").attr('aria-expanded', 'true');
245									$("#gnavismp").attr('aria-hidden', 'false');
246								}
247								$ul.slideToggle('normal', function() {
248									if(!hnFlg){
249										$("#smpmenu").css('width','auto');
250										$("#smpmenu .hnmenu").attr('aria-expanded', 'false');
251										$("#gnavismp").attr('aria-hidden', 'true');
252									}
253								});
254								return false;
255							});
256							
257							//閉じるボタン押下
258							$('.hnclose').click(function() {
259								menuClose();
260								return false;
261							});
262							
263							//閉じる処理
264							menuClose = function(){
265								bodyopen();
266								
267								$('#smpmenu').toggleClass("choice");
268								$('#smpmenu .hnmenu').toggleClass("hnplus").toggleClass("hnminus");
269								hnFlg = !hnFlg;
270								$ul.slideToggle('normal', function() {
271										$("#smpmenu").css('width','auto');
272										$("#smpmenu .hnmenu").attr('aria-expanded', 'false');
273										$("#gnavismp").attr('aria-hidden', 'true');
274								});
275							}
276						});
277						
278						gnavismpheight();
279
280					}
281				});
282
283
284
285
286				//-------------------------------------------------
287				// イベントカレンダー
288				if($("#eventcalendar").length){
289					
290					//イベント検索ボタンを移動
291					if($("#eventlink").length){
292						// スマホの場合は、#eventcalendarの下に#eventlinkを表示
293						$eventlink = $('#eventlink');
294						$("#eventcalendar").before($eventlink);
295					}
296					
297					if($('#eventcard').length){
298						$('body').addClass('smpev');
299					}
300				}
301
302				//-------------------------------------------------
303				// カルーセルA スマホの場合、高さ調整
304				if($("#scroll_a").length && FI.sm == true){
305					var mimgFlg = false;
306					var orgWidth = 0;	//オリジナルの幅
307					var orgHeight = $("#scroll_a .photoleft").height();	//オリジナルの高さ
308					var windowWidth = 0;	//スマホウィンドウの幅
309					var imgHeight = 0;	//新しく設定する高さ
310					var btnHeight = 22;	//ボタンエリアの高さ
311					
312					if($("#petit").length){
313						orgWidth = 950;		//汎用トップ
314					}else{
315						orgWidth = 950;		//トップ
316					}
317					
318					var mimgheight = function(){
319						if(!mimgFlg){
320
321							if($("#petit").length){
322									windowWidth = $(window).width();
323							}else{
324									windowWidth = $(window).width() - 40;
325							}
326
327							//画像の高さを設定
328							if(windowWidth < orgWidth){
329								imgHeight = orgHeight * windowWidth / orgWidth;
330							}else{
331								imgHeight = orgHeight;
332							}
333							$('#scroll_a .photoleft').css("height",imgHeight);
334
335							//ボタンの位置を設定
336							if($("#scroll_a .btn").length){
337								$("#scroll_a .btn , #scroll_a .paging").css("position","absolute");
338								$("#scroll_a .btn , #scroll_a .paging").css("top",imgHeight);
339								$("#scroll_a .paging").css("left",$("#scroll_a .btn").outerWidth(true));
340							}
341							
342							if($("#scroll_a .paging").length){
343								btnHeight = $("#scroll_a .paging").outerHeight(true);
344							}else{
345								btnHeight = 0;
346							}
347							$('#scroll_a').css("height",imgHeight+btnHeight);
348
349							mimgFlg = true;
350						}
351
352					};
353					
354					mimgheight();
355					
356					$(window).on('orientationchange resize',function(){
357						mimgFlg = false;
358						mimgheight();
359					});
360				}
361
362				//-------------------------------------------------
363				// カルーセルB スマホの場合、高さ調整
364				if($("#scroll_b").length && !$("#topcontent").length){
365
366					var mimgFlg = false;
367					var orgWidth = 0;	//オリジナルの幅
368					var orgHeight = $("#scroll_b .photoleft").height();	//オリジナルの高さ
369					var windowWidth = 0;	//スマホウィンドウの幅
370					var imgHeight = 0;	//新しく設定する高さ
371					var txtHeight = 0;
372					var btnHeight = 22;	//ボタンエリアの高さ
373
374					if($("#petit").length){
375						orgWidth = 570;		//汎用トップ
376					}else{
377						orgWidth = 275;		//トップ
378					}
379
380					mimgheight = function(){
381						if(!mimgFlg){
382
383							var windowWidth = $(window).width();
384
385							//画像の高さを設定
386							if(windowWidth < orgWidth){
387								imgHeight = orgHeight * windowWidth / orgWidth;
388							}else{
389								imgHeight = orgHeight;
390							}
391							$('#scroll_b .photoleft').css("height",imgHeight);
392
393							$("#scroll_b .imgtxt").each(function(){
394								if(txtHeight < $('#scroll_b .imgtxt').outerHeight(true)){
395									txtHeight = $('#scroll_b .imgtxt').outerHeight(true);
396								}
397							});
398
399							//テキストの位置を設定
400							$("#scroll_b .imgtxt").css("position","absolute");
401							$('#scroll_b .imgtxt').css("top",imgHeight);
402							$('#scroll_b .imgtxt').css("left","0");
403
404							//ボタンの位置を設定
405							if ($("#scroll_b .main").length == 1){
406								$("#scroll_b .btn , #scroll_b .paging").hide();
407								btnHeight = 0;
408							}else{
409								$("#scroll_b .btn , #scroll_b .paging").css("position","absolute");
410								$("#scroll_b .btn , #scroll_b .paging").css("top",imgHeight+txtHeight);
411								$("#scroll_b .paging").css("left",$("#scroll_b .btn").outerWidth(true));
412								$('#scroll_b .main').css("height",imgHeight+txtHeight);
413							}
414							
415							if($("#scroll_b .paging").length){
416								btnHeight = $("#scroll_b .paging").outerHeight(true);
417							}else{
418								btnHeight = 0;
419							}
420							$('#scroll_b .window').css("height",imgHeight+btnHeight+txtHeight);
421
422							mimgFlg = true;
423						}
424					};
425					
426					mimgheight();
427					
428					$(window).on('orientationchange resize',function(){
429						mimgFlg = false;
430						mimgheight();
431					});
432				}
433
434				//-------------------------------------------------
435				// 【汎用トップ】スクロールメニューC
436				if($("#scroll_c").length){
437
438
439					var mimgFlg = false;
440					var orgWidth = 0;	//オリジナルの幅
441					var orgHeight = $("#scroll_c .main").height();	//オリジナルの高さ
442					var windowWidth = 0;	//スマホウィンドウの幅
443					var imgHeight = 0;	//新しく設定する高さ
444
445					var btnHeight = $("#scroll_c .btn").outerHeight(true);	//ボタンエリアの高さ
446
447					if($("#petit").length){
448						orgWidth = 650;		//汎用トップ
449					}else{
450						orgWidth = 650;		//トップ
451					}
452
453					// ボタンテキスト変更
454					$('#scroll_c #topicsroll').find('img').each(function(){
455						var param2 = $(this).attr("alt");
456						$(this).replaceWith(param2);
457					});
458
459					mimgheight = function(){
460						if(!mimgFlg){
461						
462							var windowWidth = $(window).width();
463						
464							//画像の高さを設定
465							if(windowWidth < orgWidth){
466								imgHeight = orgHeight * windowWidth / orgWidth;
467							}else{
468								imgHeight = orgHeight;
469							}
470							$('#scroll_c .main').css("height",imgHeight);
471
472							//ボタンの位置を設定
473							if($("#scroll_c .btn").length){
474								$("#scroll_c .btn , #scroll_c #topicsroll").css("position","absolute");
475								$("#scroll_c .btn , #scroll_c #topicsroll").css("top",imgHeight);
476								$("#scroll_c #topicsroll").css("left",$("#scroll_c .btn").outerWidth(true));
477							}
478							
479							$('#scroll_c .window').css("height",imgHeight+btnHeight);
480
481						mimgFlg = true;
482						}
483					}; 
484					
485					mimgheight();
486					
487					$(window).on('orientationchange resize',function(){
488						mimgFlg = false;
489						mimgheight();
490					});
491				}
492				//-------------------------------------------------
493			}else{
494				//PCのとき
495				$('#viewmode_pc').attr('aria-current', 'page');
496				$('.smponly').each(function(){
497						$(this).remove();
498				});
499			}
500
501			//「PC」クリックイベント
502			$('#viewmode_pc').click(function(){
503				$.cookie("view_mode","pc",FI.COOKIE_OPT);
504				location.reload();
505			});
506			//「スマホ」クリックイベント
507			$('#viewmode_smp').click(function(){
508				$.cookie("view_mode","smp",FI.COOKIE_OPT);
509				location.reload();
510			});
511		});
512	})();
513	if(FI.sm){
514		document.write('<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=2.0,user-scalable=yes">');
515		document.write('<link href="' + FI.smpcss + '" rel="stylesheet" type="text/css">');
516		document.write('<link href="' + FI.smpcss2 + '" rel="stylesheet" type="text/css">');
517	}

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.