PageSourceSearch

https://www.city.iki.nagasaki.jp/theme/base/js/common.js

js city.iki.nagasaki.jp collected 2026-10-02 05:18:28 UTC 14,940 bytes, 465 lines download raw bytes

1/**
2 * 全デザインサイト共通JS
3 * @author nagai
4 * @version 1.0
5 */
6$(function(){
7
8  /**
9 * テキストタブ
10 * ※classHideは設定してください、tabsとpagesは一つだけ存在するmodを指定してください(id指定が最適)
11 * $.fn.textTab({defaultSelect:0,cookie:'topTab',tabs:$("#topTab .titleList li"),pages:$("#topTab .box")});
12 *
13 * @param object 設定
14 */
15  $.fn.textTab = function(config) {
16    var targetJ = this;
17
18    config = $.extend({
19      tabs: null,
20      pages: null,
21      defaultSelect: 0,
22      cookie: 'tab',
23      classHover: 'hover',
24      classHide: 'hide'
25    }, config);
26
27    if (config.tabs == null || config.pages == null) {
28      return;
29    }
30
31    var ClassTab = function() {}
32    ClassTab.prototype = {
33      rollOver: function(select) {
34        config.tabs.unbind("mouseenter").unbind("mouseleave"); //img.unbind('hover');ではできない
35        config.tabs.removeClass(config.classHover);
36        config.tabs.each(function(idx) {
37          var tabJ = $(this);
38
39          if (select == idx) {
40            tabJ.addClass(config.classHover);
41          } else {
42            tabJ.hover(function() {
43              tabJ.addClass(config.classHover);
44            }, function() {
45              tabJ.removeClass(config.classHover);
46            });
47          }
48        });
49      },
50      showpage: function(select) {
51
52        config.pages.each(function(idx) {
53          if (idx == select) {
54            $(this).removeClass(config.classHide);
55          } else {
56            $(this).addClass(config.classHide);
57          }
58        });
59      },
60      init: function() {
61        var cls = this;
62
63        config.pages.each(function(idx) {
64          if (idx == config.defaultSelect) {
65            $(this).removeClass(config.classHide);
66          } else {
67            $(this).addClass(config.classHide);
68          }
69        });
70
71        config.tabs.click(function() {
72          var idx = config.tabs.index(this);
73          cls.rollOver(idx);
74          cls.showpage(idx);
75          // アクセシブル対応
76          ariaTab(config.tabs, config.pages, idx);
77          //選択されたタブの番号をクッキーに保存
78          $.cookie(config.cookie, idx, {path: '/', expires: 30 });
79          return false;
80        });
81
82        config.tabs.keydown(function(e) {
83          var type = 'keydown';
84          var $prev = $(this).prev('[role="tab"]');
85          var $next = $(this).next('[role="tab"]');
86          var $target;
87          switch (e.keyCode) {
88            case 37: //左矢印(←)
89              $target = $prev;
90              break;
91            case 39: //右矢印(→)
92              $target = $next;
93              break;
94            default:
95              $target = false;
96              break;
97          }
98          if ($target.length) {
99            var idx = config.tabs.index($target);
100            cls.rollOver(idx);
101            cls.showpage(idx);
102            // アクセシブル対応
103            ariaTab(config.tabs, config.pages, idx, type);
104            //選択されたタブの番号をクッキーに保存
105            $.cookie(config.cookie, idx, {path: '/', expires: 30 });
106            return false;
107          }
108        });
109
110        cls.rollOver(config.defaultSelect);
111        // アクセシブル対応
112        ariaTab(config.tabs, config.pages, config.defaultSelect);
113      }
114    };
115
116    // 前回選択タブ復元
117    if ($.cookie(config.cookie)) {
118      config.defaultSelect = $.cookie(config.cookie);
119    }
120    // タブ作成
121    var tab = new ClassTab();
122    tab.init();
123
124  };
125
126  // 翻訳プルダウン
127  $('.js-btn-lang-select').on('click', function() {
128    var lang = $(this).parent().find('select[name=translate]').val();
129    window.location.href = lang;
130  });
131
132	//スムーズスクロール
133	$("a[href*='#'].scroll").smoothScroll();
134
135	//ファイルリンクは別窓表示
136	//$("a[href*='.*']").fileBlank('*') セレクタで拡張子指定 fileBlankの引数にクラス指定;
137	$("a[href*='.pdf']").fileBlank('pdf');
138	$("a[href*='.doc']").fileBlank('word');
139	$("a[href*='.xls']").fileBlank('excel');
140
141	// ファイルリンクのクリックイベント計測
142	$('.file-link-item a').on('click',function(){
143		var targetUrl = $(this).attr('href');
144		var targetLabel = $(this).text();
145		// ga未定義の場合は実行しない
146		if(typeof ga == 'function'){
147			ga('send', 'event', targetUrl, 'download', targetLabel);
148		}
149		// gtag未定義の場合は実行しない(GA4)
150		if(typeof gtag == 'function'){
151			gtag('event', 'sv_file_link_click', {
152				'event_category': 'file_download_category',
153				'event_label': targetLabel + ':' + targetUrl,
154				'value': 1
155			});
156		}
157	});
158
159	//ロールオーバー画像
160	$("img[src*='_off.']").rollOver({off:'_off.',on:'_on.'});
161
162	//tableのalign属性削除
163	$.fn.tableDeleteAlign();
164
165	//class名で別窓表示
166	//$('.JSblank').jsBlank();
167
168	//class名で別窓表示(外部リンクテキストなし)
169	//$('.JSblank2').jsBlank2();
170
171	//透明度ロールオーバー画像
172	//$("img.JSroll").rollOver2();
173
174
175
176    var location_href = location.href;
177    var now_site_domein;
178
179    if(location_href.indexOf('http://') != -1 || location_href.indexOf('https://') != -1){
180      var replace_site_domain = site_domain + '/';
181      var now_site_domein = replace_site_domain.replace( /http:/g , "" ).replace( /https:/g , "" );
182    }else{
183      now_site_domein = '';
184    }
185    
186	//スマートフォンへのリンク
187	//$.fn.smartphoneLink({smphDir:'m', img:'<img src="/material/template/img_pc_top/smartphone.gif" width="960" height="114" alt="スマートフォン専用サイトへ" />'});
188
189	// 元のページに戻るリファラーを自動でつける
190	// $("a[href*=inquiryId]").each(function() {
191	// 	var a = $(this);
192	// 	var url = a.attr("href");
193	// 	var locaUrl = location.pathname;
194	// 	a.attr("href", url.replace(/(Init\.do\?inquiryId=[0-9]+)/, '$1&ref=www.city.iki.nagasaki.jp' + locaUrl) );
195	// });
196
197
198	// ヘッダーナビのドロップメニュ
199	// if (typeof $.fn.megaDropMenu != 'undefined') {
200	// 	$('#headerNav').megaDropMenu({
201	// 		fadeTime:300
202	// 	});
203	// }
204	// ヘッダーナビのドロップメニュ
205	if (typeof $.fn.dropMenu != 'undefined') {
206		$("#header-nav-in").dropMenu();
207	}
208
209  //文字サイズ変更
210  if ($('.scsize').length) {
211    $.fn.fontSizeSwitch();
212  }
213
214  //背景色変更
215  if ($('.sccolor').length) {
216    $.fn.bgColorSwitch();
217  }
218
219  // ヘッダーナビのドロップメニュ
220  if (typeof $.fn.dropMenu != 'undefined') {
221    $("#header-nav").dropMenu();
222  }
223
224
225	// 文字サイズ変更監視
226	$.fn.fontSizeChange({func:function(){
227		//$("#header-nav .list2").eqGroupHeight(3);
228		$("#wrapper").show();
229	}});
230
231
232	//モーダル(検索)
233	$('.menu-btn-search').lightbox({
234		modalBg:$('.modal-search-bg'),
235		modal:$('.modal-search'),
236		close:$('.modal-menu-close'),
237		scrollID:'sWrapper',
238		lightSpot:$('.menu-btn-search')
239	});
240
241
242	//モーダル(メニュー)
243  $('.menu-btn-menu').lightbox({
244    modalBg:$('.modal-menu-bg'),
245    modal:$('.modal-menu, .modal-menu-close'),
246    close:$('.modal-menu-close'),
247    scrollID:'sWrapper',
248    lightSpot:$('.menu-btn-menu, .modal-menu-close')
249  });
250
251	// $('.modal-menu .box').accordion({
252	// 	classHead:'.title',
253	// 	classBody:'.list',
254	// 	classToggle:'on'
255	// });
256
257  // スマホメニュー内のアコーディオン
258  $('.sp-nav .box button').on('click', function() {
259    $(this).parent('.title').parent('li').find('.bloc').slideToggle();
260    var btn_name = $(this).find('span').text();
261    if($(this).attr('class') === 'mynus') {
262      $(this).attr('class', 'plus');
263      $(this).find('span').text(btn_name.replace('閉じる', '開く'));
264      $(this).attr('aria-selected', false);
265      $(this).attr('aria-expanded', false);
266      $(this).parent('.title').parent('li').find('.bloc').attr('aria-hidden', true);
267    } else {
268      $(this).attr('class', 'mynus');
269      $(this).find('span').text(btn_name.replace('開く', '閉じる'));
270      $(this).attr('aria-selected', true);
271      $(this).attr('aria-expanded', true);
272      $(this).parent('.title').parent('li').find('.bloc').attr('aria-hidden', false);
273    }
274  });
275
276  // アコーディオン(よくある質問用)
277  $('.faq-block').accordion({
278    classHead:'.title',
279    classBody:'.childs',
280    classToggle:'on'
281  });
282
283
284	//アコーディオン(分野別で探す)
285	$('.joho-tab #tab-6 .in2').accordion({
286		classHead:'.title',
287		classBody:'.links',
288		classToggle:'on'
289	});
290
291	//スマホプレビューに対応
292	$('.no-escape').each(function(){
293		$(this).html($(this).text());
294	});
295
296  // -----------------------------------------------------
297  // wysiwygの中にtableがあれば、wrapperクラスを付与する
298  // (100%を超えたときにwrapper内でスクロールさせるため)
299  // -----------------------------------------------------
300  if ($('.wysiwyg table').length){
301    $('.wysiwyg table').wrap('<div class="table-wrapper"></div>');
302  }
303
304
305  /**
306   IE8,9でXMLHttpRequestの代わりにXDomainRequestを使う
307  このセクションは消さないでください。
308  */
309  if ( window.XDomainRequest ) {
310      jQuery.ajaxTransport(function( s ) {
311          if ( s.crossDomain && s.async ) {
312              if ( s.timeout ) {
313                  s.xdrTimeout = s.timeout;
314                  delete s.timeout;
315              }
316              var xdr;
317              return {
318                  send: function( _, complete ) {
319                      function callback( status, statusText, responses, responseHeaders ) {
320                          xdr.onload = xdr.onerror = xdr.ontimeout = xdr.onprogress = jQuery.noop;
321                          xdr = undefined;
322                          complete( status, statusText, responses, responseHeaders );
323                      }
324                      xdr = new XDomainRequest();
325                      xdr.open( s.type, s.url );
326                      xdr.onload = function() {
327                          callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
328                      };
329                      xdr.onerror = function() {
330                          callback( 404, "Not Found" );
331                      };
332                      xdr.onprogress = function() {};
333                      if ( s.xdrTimeout ) {
334                          xdr.ontimeout = function() {
335                              callback( 0, "timeout" );
336                          };
337                          xdr.timeout = s.xdrTimeout;
338                      }
339                      xdr.send( ( s.hasContent && s.data ) || null );
340                  },
341                  abort: function() {
342                      if ( xdr ) {
343                          xdr.onerror = jQuery.noop();
344                          xdr.abort();
345                      }
346                  }
347              };
348          }
349      });
350  }
351
352  //PC・スマホ切り替え(レスポンシブ)
353  if( typeof MutualSwitching !== 'undefined') {
354    MutualSwitching.config.setPathSettings({
355      "/": {
356      "pc_width": 1400,
357      "sp_width": 750,
358      "layout_type": 0
359      }
360    });
361    MutualSwitching.run.ready();
362  }
363
364  //Page Id search
365  $(function(){
366    $('.page-number-search').each(function(){
367      var $this = $(this);
368
369      $(window).load(function() {
370        $this.find('.number-search-submit').click(function() {
371          getPageURL();
372        });
373        $this.find('.number-search-input').keypress(function(ev) {
374          if ((ev.which && ev.which === 13) || (ev.keyCode && ev.keyCode === 13)) {//Enterキー無効
375            getPageURL();
376          } else {
377            return true;
378          }
379        });
380      });
381
382      function getPageURL() {
383        var errorFlag = false;
384        var inputText = $this.find('.number-search-input').val(); // 検索するID取得
385        var errorMessage = '';
386        //エラーチェック
387        //数値チェック
388        if(inputText.match(/[^0-9]+/)) {
389          errorFlag = true;
390          errorMessage = 'ID番号は半角数字で入力してください。';
391        } else if(inputText == '') {
392          errorFlag = true;
393          errorMessage = 'ID番号を入力してください。';
394        }
395
396        if(errorFlag) {
397          //エラーメッセージ表示
398          $('.error-message').remove();
399          $this.find('.number-search-container').append('<p class="error-message">' + errorMessage + '</p>');
400        } else {
401          /*検索ID取得*/
402          $.ajax({
403            type: 'get',
404            url: '//' + cms_api_domain + '/v1/page/get_page_contents.json',
405            data: {
406              app_version: cms_app_version,
407              app_id: cms_app_id,
408              token: cms_api_token,
409              page_no: inputText
410            },
411            dataType : 'json',
412            success: function(data) {
413              if(data.success && data.data)
414                location.href = data.data.page_path;//画面遷移
415              else {
416                //エラーメッセージ表示
417                $('.error-message').remove();
418                $this.find('.number-search-container').append('<p class="error-message">該当のページはございません</p>');
419              }
420            },
421            error: function(data) {
422              //エラーメッセージ表示
423              $('.error-message').remove();
424              $this.find('.number-search-container').append('<p class="error-message">ページを取得できませんでした。</p>');
425            }
426          });
427        }
428      }
429
430    });
431  });
432
433  // ページトップボタン
434  $(function() {
435    var topBtn = $('#pagetop');
436    topBtn.hide();
437
438    //スクロールが450に達したらボタン表示
439    $(window).scroll(function () {
440        if ($(this).scrollTop() > 450) {
441          topBtn.fadeIn();
442        } else {
443          topBtn.fadeOut();
444        }
445    });
446    //フッター手前でボタンを止める
447    $(window).scroll(function () {
448      var height = $(document).height(); //ドキュメントの高さ
449      var position = $(window).height() + $(window).scrollTop(); //ページトップから現在地までの高さ
450      var footer = $("footer").height(); //フッターの高さ
451      if ( height - position  < footer ) {
452        topBtn.css({
453          position : "absolute",
454        });
455      } else {
456        topBtn.css({
457          position : "fixed",
458          top: "auto"
459        });
460      }
461    });
462  });
463
464
465});

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.