PageSourceSearch

https://www.nakijin.jp/theme/base/js/common.js

js nakijin.jp collected 2026-10-02 06:57:36 UTC 13,196 bytes, 385 lines download raw bytes

1/**
2 * 全デザインサイト共通JS
3 * @author nagai
4 * @version 1.0
5 */
6$(function(){
7
8  //スムーズスクロール
9  $("a[href*='#'].scroll").smoothScroll();
10
11  //ファイルリンクは別窓表示
12  //$("a[href*='.*']").fileBlank('*') セレクタで拡張子指定 fileBlankの引数にクラス指定;
13  $("a[href*='.pdf']").fileBlank('pdf');
14  $("a[href*='.doc']").fileBlank('word');
15  $("a[href*='.xls']").fileBlank('excel');
16
17  // ファイルリンクのクリックイベント計測
18  $('.file-link-item a').on('click',function(){
19    var targetUrl = $(this).attr('href');
20    var targetLabel = $(this).text();
21    // ga未定義の場合は実行しない
22    if(typeof ga == 'function'){
23      ga('send', 'event', targetUrl, 'download', targetLabel);
24    }
25    // gtag未定義の場合は実行しない(GA4)
26    if(typeof gtag == 'function'){
27      gtag('event', 'sv_file_link_click', {
28        'event_category': 'file_download_category',
29        'event_label': targetLabel + ':' + targetUrl,
30        'value': 1
31      });
32    }
33  });
34
35  //ロールオーバー画像
36  $("img[src*='_off.']").rollOver({off:'_off.',on:'_on.'});
37
38
39  // //XPのIE7と他のOSにメイリオのフォント指定
40  // $.fn.fontMeiryo();
41
42  //tableのalign属性削除
43  $.fn.tableDeleteAlign();
44
45  // // 別ドメインは別窓表示
46  // $('a[href*=http]').linkBlank({url:['/www.xxxx.xxxx.xxxx.jp' ,'/xxxx.xxxx.xxxx.jp' ,'^http://www00.dev.smartcms.smart-lgov.jp']});
47
48  // 元のページに戻るリファラーを自動でつける
49  $("a[href*=inquiryId]").each(function() {
50    var a = $(this);
51    var url = a.attr("href");
52    var locaUrl = location.pathname;
53    a.attr("href", url.replace(/(Init\.do\?inquiryId=[0-9]+)/, '$1&ref=www.xxxx.xxxx.xxxx.jp' + locaUrl) );
54  });
55
56
57  var location_href = location.href;
58  var now_site_domain;
59
60  if(location_href.indexOf('http://') != -1 || location_href.indexOf('https://') != -1){
61    var replace_site_domain = site_domain + '/';
62    var now_site_domain = replace_site_domain.replace( /http:/g , "" ).replace( /https:/g , "" );
63  }else{
64    now_site_domain = '';
65  }
66
67  //文字サイズ変更(標準 or 大きくする)HTML側は以下のように設定
68  if ($('.scsize').length) {
69    $.fn.styleCatcherUpNormal({btnCls: "scsize",cssID: "scsize",prAry: ['size_default.css', 'size_up.css', 'size_up2.css', 'size_up3.css'],cssPath: now_site_domain + 'theme/base/css/',def: 0});
70  }
71  //文字サイズ(小、中、大)HTML側は以下のように設定
72  //$.fn.styleCatcher({btnCls: "scSize",cssID: "scSize",cssTag: '<link href="/material/template/css/size_small.css" rel="stylesheet" type="text/css" id="scSize" />',def: 0});
73
74  //背景色変更(白、黒、青)HTML側は以下のように設定
75  if ($('.sccolor').length) {
76    $.fn.styleCatcher({btnCls: "sccolor",cssID: "sccolor", cssPath: now_site_domain + 'theme/base/css/',def: 2});
77  }
78
79
80
81
82  // ヘッダーナビのドロップメニュ
83  if (typeof $.fn.dropMenu != 'undefined') {
84    $("#header-nav").dropMenu();
85  }
86
87  // 文字サイズ変更監視
88  $.fn.fontSizeChange({func:function(){
89    //$("#header-nav .list2").eqGroupHeight(3);
90    $("#wrapper").show();
91    
92    $('#header-logo').css('top', $('#header-nav .in .list').height());
93  }});
94
95
96  //モーダル(検索)
97  $('.menu-btn-search').lightbox({
98    modalBg:$('.modal-search-bg'),
99    modal:$('.modal-search'),
100    close:$('.modal-menu-close'),
101    scrollID:'sWrapper',
102    lightSpot:$('.menu-btn-search')
103  });
104
105
106  //モーダル(メニュー)
107  $('.menu-btn-menu').lightbox({
108    modalBg:$('.modal-menu-bg'),
109    modal:$('.modal-menu'),
110    close:$('.modal-menu-close'),
111    scrollID:'sWrapper',
112    lightSpot:$('.menu-btn-menu')
113  });
114
115  $('.modal-menu .box').svAccordion({
116    classHead:'.title',
117    classBody:'.list',
118    classToggle:'on'
119  });
120
121  // アコーディオン(よくある質問用)
122  $('.faq-block').svAccordion({
123    classHead:'.title',
124    classBody:'.childs',
125    classToggle:'on'
126  });
127
128  //アコーディオン(分野別で探す)
129  $('.joho-tab #tab-6 .in2').svAccordion({
130    classHead:'.title',
131    classBody:'.links',
132    classToggle:'on'
133  });
134
135  //スマホプレビューに対応
136  $('.no-escape').each(function(){
137    $(this).html($(this).text());
138  });
139
140  
141  // -----------------------------------------------------
142  // wysiwygの中にtableがあれば、wrapperクラスを付与する
143  // (100%を超えたときにwrapper内でスクロールさせるため)
144  // -----------------------------------------------------
145  if ($('.wysiwyg table').length){
146    $('.wysiwyg table').wrap('<div class="table-wrapper"></div>');
147  }
148
149
150/**
151 IE8,9でXMLHttpRequestの代わりにXDomainRequestを使う
152 このセクションは消さないでください。
153 */
154if ( window.XDomainRequest ) {
155    jQuery.ajaxTransport(function( s ) {
156        if ( s.crossDomain && s.async ) {
157            if ( s.timeout ) {
158                s.xdrTimeout = s.timeout;
159                delete s.timeout;
160            }
161            var xdr;
162            return {
163                send: function( _, complete ) {
164                    function callback( status, statusText, responses, responseHeaders ) {
165                        xdr.onload = xdr.onerror = xdr.ontimeout = xdr.onprogress = jQuery.noop;
166                        xdr = undefined;
167                        complete( status, statusText, responses, responseHeaders );
168                    }
169                    xdr = new XDomainRequest();
170                    xdr.open( s.type, s.url );
171                    xdr.onload = function() {
172                        callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
173                    };
174                    xdr.onerror = function() {
175                        callback( 404, "Not Found" );
176                    };
177                    xdr.onprogress = function() {};
178                    if ( s.xdrTimeout ) {
179                        xdr.ontimeout = function() {
180                            callback( 0, "timeout" );
181                        };
182                        xdr.timeout = s.xdrTimeout;
183                    }
184                    xdr.send( ( s.hasContent && s.data ) || null );
185                },
186                abort: function() {
187                    if ( xdr ) {
188                        xdr.onerror = jQuery.noop();
189                        xdr.abort();
190                    }
191                }
192            };
193        }
194    });
195}
196
197  //PC・スマホ切り替え(レスポンシブ)
198  if( typeof MutualSwitching !== 'undefined') {
199    MutualSwitching.config.setPathSettings({
200      "/": {
201      "pc_width": 1024,
202      "sp_width": 720,
203     "layout_type": 0
204      }
205    });
206    MutualSwitching.run.ready();
207  }
208  
209  var isMobile = {
210    phone : false,
211    phoneCheck : function(){
212      this.phone = $($('.visible-phone')[0]).is(':visible');
213      return this.phone;
214    },
215    check : function(){
216      this.phoneCheck();
217    },
218    init : function(){
219      if ($('.visible-phone').length <= 0) $('body').append($('<div class="visible-phone"></div>'));
220      this.check();
221      $(window).resize(function(){
222        isMobile.check();
223      });
224    }
225  };
226
227  $(window).on('load resize orientationchange',function(){
228    isMobile.init();
229    if(isMobile.phone){
230      $('#header #google_translate_element').prependTo('#sp-header .g-translate-box');
231    } else {
232      $('#sp-header .g-translate-box #google_translate_element').prependTo('#header .g-translate-box');
233    }
234
235  });
236  
237  // ヘッダーナビ hover focus 対応
238  $('#header-nav > .in > .list > li').hover(function() {
239    addActiveNav($(this).find('> a'));
240  }, function() {
241    removeActiveNav();
242  });
243  $('a').focusin(function() {
244    if ($(this).closest('#header-nav').length > 0) {
245      addActiveNav($(this).closest('li:not(.pageEntity)').find('> a'));
246    } else {
247      removeActiveNav();
248    }
249  });
250
251  function addActiveNav($a) {
252    removeActiveNav();
253    $a.addClass('active');
254  }
255  function removeActiveNav() {
256    $('#header-nav > .in > .list > li > a').removeClass('active');
257  }
258
259
260  /**
261 * SmartAlert
262 * @param ...
263 * @return ... Returns {@ code}
264*/
265$.fn.smartAlertListView = function(config){
266
267  // 初期値
268  config = $.extend({
269    rssPath: site_domain + '/cgi-bin/smart_alert.php/1',
270    historyPath: site_domain + '/cgi-bin/smart_alert.php/1/list',
271    historyClass: '.more',
272    ulClass: '.list',
273    textClass: '.text',
274    dateClass: '.date',
275    limit: 3,
276    dateformat: 'YYYY年MM月DD日(WW) hh時mm分ss秒',
277    noDataView: 1,
278  },config);
279
280  // パラメーターのエラー判定
281  var errorMsg = '';
282  for(key in config) {
283    var value = config[key];
284    // 空文字の判定
285    if(value === '') {
286      errorMsg += 'エラー:' + key + 'に空文字が入っています\n';
287    } else {
288      // 数値かどうかの判定
289      if(key === 'limit' || key === 'noDataView') {
290        if($.type(value) !== 'number'){
291          errorMsg += 'エラー:' + key + 'に文字列が入っています\n';
292        }
293      // 文字列かどうかの判定
294      } else {
295        if($.type(value) !== 'string') {
296          errorMsg += 'エラー:' + key + 'に数値が入っています\n';
297        }
298      }
299    }
300  }
301  // エラーあれば実行しない
302  if(errorMsg) {
303    console.error(errorMsg);
304  // エラーなければ実行
305  } else {
306    $.ajax({
307      url:config.rssPath,
308      timeout: 10000,
309      dataType: 'json',
310      context:this,
311      success:function(json){
312        var itemList = json.data; //xml配列を変数に格納
313        var $parentBox = this; //表示エリアを選択
314        var $smartAlertUlBox = $parentBox.find(config.ulClass); //ulタグを選択
315        var $li = $smartAlertUlBox.find('li:first'); //liタグを選択
316        var litags = '';
317        // --------------------------------------------
318        //アラートがあれば
319        if(itemList.length){
320          //一覧ページへのリンク先設定
321          $($parentBox).find(config.historyClass + ' a').attr('href', config.historyPath);
322          //xmlデータをまわす
323          $(itemList).each(function(idx){
324            if(idx >= config.limit){
325              return false;
326            }
327            //アラート内容の作成
328            var smartAlertTitle = this.title;
329            var smartAlertLink = this.link;
330            //アラート日付の作成
331            var date = new Date(this.pubDate);
332            var weekday = ['日', '月', '火', '水', '木', '金', '土'];
333            var dateText = config.dateformat;
334            dateText = dateText.replace(/YYYY/, date.getFullYear());
335            dateText = dateText.replace(/MM/, ('0' + (date.getMonth() + 1)).slice(-2));
336            dateText = dateText.replace(/DD/, ('0' + date.getDate()).slice(-2));
337            dateText = dateText.replace(/WW/, weekday[date.getDay()]);
338            dateText = dateText.replace(/hh/, ('0' + date.getHours()).slice(-2));
339            dateText = dateText.replace(/mm/, ('0' + date.getMinutes()).slice(-2));
340            dateText = dateText.replace(/ss/, ('0' + date.getSeconds()).slice(-2));
341            dateText = dateText.replace(/M/, date.getMonth() + 1);
342            dateText = dateText.replace(/D/, date.getDate());
343            dateText = dateText.replace(/h/, date.getHours());
344            dateText = dateText.replace(/m/, date.getMinutes());
345            dateText = dateText.replace(/s/, date.getSeconds());
346            //リンクの挿入
347            if($li.find('a').length) {
348              $li.find('a').attr('href', smartAlertLink);
349            }
350            //アラート内容の挿入
351            if($li.find(config.textClass).length) {
352              $li.find(config.textClass).text(smartAlertTitle);
353            }
354            //アラート日付の挿入
355            if($li.find(config.dateClass).length) {
356              $li.find(config.dateClass).text(dateText);
357            }
358            litags += $li.prop('outerHTML');
359          });
360          //追加
361          $smartAlertUlBox.html(litags);
362          // エリアの表示
363          $parentBox.css('display', 'block');
364
365        // --------------------------------------------
366        //アラートがなければ
367        // --------------------------------------------
368        } else {
369          if(config.noDataView) {
370            $parentBox.css('display', 'block');
371            $li = config.noDataClass ? $(config.noDataClass) : '<li>データがありません</li>';
372            $smartAlertUlBox.html($li);
373            $parentBox.find(config.historyClass).remove(); //一覧ページへのボタンを削除
374          } else {
375            $parentBox.remove(); //エリアごと削除
376          }
377        }
378      }
379    });
380  }
381  return this;
382};
383
384
385});

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.