PageSourceSearch

https://www.city.hachinohe.aomori.jp/theme/base/js/common.js

js city.hachinohe.aomori.jp collected 2026-10-02 05:04:55 UTC 9,760 bytes, 300 lines download raw bytes

1/**
2 * 全デザインサイト共通JS
3 * @author nagai
4 * @version 1.0
5 */
6$(function(){
7  
8  $(window).on('load', function() {
9    $('.footer-address-body').attr('x-ms-format-detection', 'none');
10  });
11
12  // 「スマートフォン版を表示」ボタンを下スクロール時に隠す
13  var oldScrollPos = 0;
14  $(window).scroll(function() {
15    var currentScrollPos = $(this).scrollTop();
16    if (currentScrollPos <= oldScrollPos) {
17      $('#smartphone').removeClass('scrollHide');
18    } else {
19      $('#smartphone').addClass('scrollHide');
20    }
21    oldScrollPos = currentScrollPos;
22  });
23
24  //スムーズスクロール
25  $("a[href*='#'].scroll").smoothScroll();
26
27  //ファイルリンクは別窓表示
28  //$("a[href*='.*']").fileBlank('*') セレクタで拡張子指定 fileBlankの引数にクラス指定;
29  $("a[href*='.pdf']").fileBlank('pdf');
30  $("a[href*='.doc']").fileBlank('word');
31  $("a[href*='.xls']").fileBlank('excel');
32
33  // ファイルリンクのクリックイベント計測
34  $('.file-link-item a').on('click',function(){
35    var targetUrl = $(this).attr('href');
36    var targetLabel = $(this).text();
37    // ga未定義の場合は実行しない
38    if(typeof ga == 'function'){
39      ga('send', 'event', targetUrl, 'download', targetLabel);
40    }
41    // gtag未定義の場合は実行しない(GA4)
42    if(typeof gtag == 'function'){
43      gtag('event', 'sv_file_link_click', {
44        'event_category': 'file_download_category',
45        'event_label': targetLabel + ':' + targetUrl,
46        'value': 1
47      });
48    }
49  });
50
51  //ロールオーバー画像
52  $("img[src*='_off.']").rollOver({off:'_off.',on:'_on.'});
53  
54  //object-fit適用対象の画像
55  objectFitImages('.ofi-wrapper img');
56
57
58  // //XPのIE7と他のOSにメイリオのフォント指定
59  // $.fn.fontMeiryo();
60
61  //tableのalign属性削除
62  $.fn.tableDeleteAlign();
63
64  // // 別ドメインは別窓表示
65  // $('a[href*=http]').linkBlank({url:['/www.xxxx.xxxx.xxxx.jp' ,'/xxxx.xxxx.xxxx.jp' ,'^http://www00.dev.smartcms.smart-lgov.jp']});
66
67  // 元のページに戻るリファラーを自動でつける
68  $("a[href*=inquiryId]").each(function() {
69    var a = $(this);
70    var url = a.attr("href");
71    var locaUrl = location.pathname;
72    a.attr("href", url.replace(/(Init\.do\?inquiryId=[0-9]+)/, '$1&ref=www.xxxx.xxxx.xxxx.jp' + locaUrl) );
73  });
74
75
76  var location_href = location.href;
77  var now_site_domain;
78
79  if(!!site_domain && (location_href.indexOf('http://') != -1 || location_href.indexOf('https://') != -1)){
80    var replace_site_domain = site_domain + '/';
81    var now_site_domain = replace_site_domain.replace( /http:/g , "" ).replace( /https:/g , "" );
82  }else{
83    now_site_domain = '';
84  }
85
86  //文字サイズ変更(標準 or 大きくする)HTML側は以下のように設定
87  if ($('.scsize').length) {
88    $.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});
89  }
90
91  //背景色変更(白、黒、青)用プラグイン
92  $.fn.styleCatcher = function(config) {
93    config = $.extend({
94      btnCls: "scsize",
95      cssID: "scsize",
96      cssPath:'/theme/base/css/',
97      def: 0
98    },config);
99
100    var cssTag = $('<link rel="stylesheet" />');
101    cssTag.attr('id', config.cssID);
102    $("body").append(cssTag);
103
104    function offRollAndOn(_id) {
105      $('.' + config.btnCls).each(function(idx){
106        var j2 = $(this);
107        var id2 = j2.attr("data-background");
108        var img2 = j2.find("img");
109        img2.unbind();
110        if(_id == id2) {
111          img2.attr("src", img2.attr("src").replace("_off.", "_on."));
112        }
113        else {
114          img2.attr("src", img2.attr("src").replace("_on.", "_off."));
115          img2.hover(function () {
116            $(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
117          },function () {
118            $(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
119          });
120        }
121      });
122    }
123    $('.' + config.btnCls).attr("href", "#");
124    $('.' + config.btnCls).click(function(){
125      var j = $(this);
126      var img = j.find("img");
127      var id = j.attr("data-background"); //
128      offRollAndOn(id);
129      $('#' + config.cssID).attr("href", config.cssPath + id + '.css');
130      $.cookie(config.cssID, id, {path:'/'});
131      return false;
132    });
133    var fileName;
134    if($.cookie(config.cssID)) {
135      fileName = $.cookie(config.cssID);
136    }
137    else {
138      fileName = $($('.' + config.btnCls).get(config.def)).attr("data-background");
139    }
140    offRollAndOn(fileName);
141    $('#' + config.cssID).attr("href", config.cssPath + fileName + '.css');
142  };
143
144  //背景色変更(白、黒、青)HTML側は以下のように設定
145  if ($('.sccolor').length) {
146    $.fn.styleCatcher({btnCls: "sccolor",cssID: "sccolor", cssPath: now_site_domain + 'theme/base/css/',def: 2});
147  }
148
149
150
151
152  // ヘッダーナビのドロップメニュ
153  if (typeof $.fn.dropMenu != 'undefined') {
154    $("#header-nav").dropMenu();
155  }
156
157  // 文字サイズ変更監視
158  $.fn.fontSizeChange({func:function(){
159    $(window).trigger('fontSizeChange');
160    $("#wrapper").show();
161  }});
162
163
164  //モーダル(メニュー)
165  $('.menu-btn-menu').lightbox({
166    modalBg:$('.modal-menu-bg'),
167    modal:$('.modal-menu,.menu-btn-close'),
168    close:$('.modal-menu-close,.menu-btn-close'),
169    scrollID:'sWrapper',
170    lightSpot:$('.menu-btn-menu')
171  });
172
173  $('.modal-menu .toggle').svAccordion({
174    classHead:'.title',
175    classBody:'.list',
176    classToggle:'on'
177  });
178
179  // アコーディオン(よくある質問用)
180  $('.faq-block').svAccordion({
181    classHead:'.title',
182    classBody:'.childs',
183    classToggle:'on'
184  });
185
186  //アコーディオン(分野別で探す)
187  $('.joho-tab #tab-6 .in2').svAccordion({
188    classHead:'.title',
189    classBody:'.links',
190    classToggle:'on'
191  });
192
193  //スマホプレビューに対応
194  $('.no-escape').each(function(){
195    $(this).html($(this).text());
196  });
197
198  // 本文へ表示
199  var toBody = $('.honbun a');
200  var toBodyOuter = $('.honbun');
201    toBody.focus(function(){
202    toBodyOuter.css('top', '0');
203  });
204  toBody.blur(function(){
205    toBodyOuter.css('top', '-999px');
206  });
207  
208  setTranslateForm();
209  transformMedia = window.matchMedia("(max-width: 768px)");
210  
211  transformMedia.addListener(setTranslateForm);
212  
213  function setTranslateForm() {
214    if(window.matchMedia("(max-width: 768px)").matches) {
215      $('#honyaku').appendTo('#translate-sp');
216      $('#read-speaker').appendTo('#read-speaker-sp');
217    } else {
218      $('#honyaku').appendTo('#translate-pc');
219      $('#read-speaker').appendTo('#read-speaker-pc');
220    }
221  }
222  
223  var printMedia = window.matchMedia('print');
224  printMedia.addListener(function(){
225    if (print.matches) {
226      transformMedia.removeListener(setTranslateForm);
227    } else {
228      transformMedia.addListener(setTranslateForm);
229    }
230  });
231
232  // -----------------------------------------------------
233  // wysiwygの中にtableがあれば、wrapperクラスを付与する
234  // (100%を超えたときにwrapper内でスクロールさせるため)
235  // -----------------------------------------------------
236  if ($('.wysiwyg table').length){
237    $('.wysiwyg table').wrap('<div class="table-wrapper"></div>');
238  }
239
240
241/**
242 IE8,9でXMLHttpRequestの代わりにXDomainRequestを使う
243 このセクションは消さないでください。
244 */
245if ( window.XDomainRequest ) {
246    jQuery.ajaxTransport(function( s ) {
247        if ( s.crossDomain && s.async ) {
248            if ( s.timeout ) {
249                s.xdrTimeout = s.timeout;
250                delete s.timeout;
251            }
252            var xdr;
253            return {
254                send: function( _, complete ) {
255                    function callback( status, statusText, responses, responseHeaders ) {
256                        xdr.onload = xdr.onerror = xdr.ontimeout = xdr.onprogress = jQuery.noop;
257                        xdr = undefined;
258                        complete( status, statusText, responses, responseHeaders );
259                    }
260                    xdr = new XDomainRequest();
261                    xdr.open( s.type, s.url );
262                    xdr.onload = function() {
263                        callback( 200, "OK", { text: xdr.responseText }, "Content-Type: " + xdr.contentType );
264                    };
265                    xdr.onerror = function() {
266                        callback( 404, "Not Found" );
267                    };
268                    xdr.onprogress = function() {};
269                    if ( s.xdrTimeout ) {
270                        xdr.ontimeout = function() {
271                            callback( 0, "timeout" );
272                        };
273                        xdr.timeout = s.xdrTimeout;
274                    }
275                    xdr.send( ( s.hasContent && s.data ) || null );
276                },
277                abort: function() {
278                    if ( xdr ) {
279                        xdr.onerror = jQuery.noop();
280                        xdr.abort();
281                    }
282                }
283            };
284        }
285    });
286}
287
288  //PC・スマホ切り替え(レスポンシブ)
289  if( typeof MutualSwitching !== 'undefined') {
290    MutualSwitching.config.setPathSettings({
291      "/": {
292      "pc_width": 1280,
293      "sp_width": 750,
294      "layout_type": 0
295      }
296    });
297    MutualSwitching.run.ready();
298  }
299
300});

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.