PageSourceSearch

https://www.mof.go.jp/common/js/common.js

js mof.go.jp collected 2026-09-24 08:28:09 UTC 7,673 bytes, 244 lines download raw bytes

1(function ($) {
2  const mediaQuery = window.matchMedia('(max-width: 767px)');
3
4  $(function () {
5    /**
6    * Hamburger Menu
7    */
8    let scrollPos;
9    $('.js-ham-button').on('click', function () {
10      scrollPos = $(window).scrollTop();
11      $(this).toggleClass('is-open');
12      $('.header-nav').toggleClass('is-open');
13      $('body').toggleClass('is-fixed-header').css({ top: -scrollPos });
14    });
15
16    function hamMenuClose() {
17      $('.js-ham-button').removeClass('is-open');
18      $('.header-nav').removeClass('is-open');
19      $('body').removeClass('is-fixed-header').css({ top: 0 });
20      $(window).scrollTop(scrollPos);
21    }
22
23    $('.js-nav-close-button').on('click', hamMenuClose);
24
25    function resizeFunc() {
26      if (!mediaQuery.matches === true) {
27        hamMenuClose();
28      }
29    }
30    mediaQuery.addListener(resizeFunc);
31    resizeFunc(mediaQuery);
32
33
34    /*
35    * ドロップダウンメニュー
36    */
37    const $dropdownButtun = $('.js-dropdown-button');
38    const duration = 200;
39
40    function dropdownMenufadeOut() {
41      $dropdownButtun.next('.js-dropdown-menu')
42        .stop()
43        .fadeOut(duration)
44        .parent('.header-nav-global-item').removeClass('is-open');
45      $dropdownButtun.removeClass('is-active');
46    }
47
48    function toggleMenu() {
49      const $self = $(this);
50      if (mediaQuery.matches === true) {
51        $self.next().stop().slideToggle();
52        $self.toggleClass('is-active');
53      } else {
54        // 今開いているのがあれば閉じてから
55        if (!$self.parent('.header-nav-global-item').hasClass('is-open')) {
56          dropdownMenufadeOut();
57          // 開く
58          $self.siblings('.js-dropdown-menu')
59            .stop().fadeIn(duration)
60            .parent('.header-nav-global-item').toggleClass('is-open');
61          $self.toggleClass('is-active');
62        } else {
63          // 閉じる
64          dropdownMenufadeOut();
65        }
66      }
67    }
68
69    $dropdownButtun.on('click', toggleMenu);
70
71    mediaQuery.addListener(toggleMenu);
72    toggleMenu(mediaQuery);
73
74    // ページ内リンクをクリックしたらメニューを閉じる
75    $('.js-dropdown-menu a, .js-dropdown-close-button').on('click', function () {
76      dropdownMenufadeOut();
77    });
78
79    // メニュー領域外をクリックしたらメニューを閉じる
80    $(document).on('click', function (e) {
81      if (!$(e.target).closest('.header-nav-global-item').length) {
82        dropdownMenufadeOut();
83      }
84    });
85
86
87    /*
88    * スムーススクロール
89    */
90    $('a.js-smooth[href^="#"]').on('click', function (e) {
91      e.preventDefault();
92      const href = $(this).attr('href');
93      const target = $(href == '#' || href == '' ? 'html' : href);
94      const position = href == '#' || href == '' ? target.offset().top : target.offset().top;
95      $('html,body').animate({ scrollTop: position }, 500, 'linear', function (e) {
96        location.href = href;
97      });
98      return false;
99    });
100
101    
102    /*
103    * ページトップへ戻るボタン
104    */
105    if ($('.js-pagetop').length) {
106      $('.js-pagetop a').on('click', function (e) {
107        e.preventDefault();
108        const href = $(this).attr('href');
109        $('body, html').animate({
110          scrollTop: 0
111        }, 500, 'linear', function (e) {
112          location.href = href;
113        });
114        return false;
115      });
116      
117      $('.js-pagetop').hide();
118
119      $(window).on('scroll resize', function () {
120        // 表示/非表示
121        if ($(this).scrollTop() > $('#header').innerHeight()) {
122          $('.js-pagetop').fadeIn();
123        } else {
124          $('.js-pagetop').fadeOut();
125        }
126        // ボタン位置固定/非固定
127        if ($(this).scrollTop() + $(this).height() < $('#footer').offset().top + 50) {
128          $('.js-pagetop').addClass('is-fixed');
129        } else {
130          $('.js-pagetop').removeClass('is-fixed');
131        }
132      });
133    }
134
135    
136    /*
137    * ポップアップページ:ウィンドウを閉じるボタン
138    */
139    function CloseWindow() {
140      let userAgent = window.navigator.userAgent.toUpperCase();
141      if (userAgent.indexOf('MSIE') === -1 && userAgent.indexOf('TRIDENT') === -1) {
142        window.open('/public_relations/gallery/', '_self').close();
143      }
144      else {
145        window.close();
146      }
147    }
148    $('.js-close-window-button').on('click', CloseWindow);
149
150
151    /**
152     * 情報一覧:ナビゲーション
153     * スマホのみアコーディオン
154     */
155    const accordionOnlySp = function () {
156      if ($('.pagination-tab').length) {
157        $('.pagination-tab').find('.js-toggle-button').each(function () {
158          if (mediaQuery.matches === true) {
159            if (!$(this).parent('.pagination-tab').hasClass('is-open')) {
160              $(this).siblings('.pagination-tab-body').hide();
161            }
162            $(this).on('click', function () {
163              if ($('+.pagination-tab-body', this).not(':animated').length > 0) {
164                $('+.pagination-tab-body', this).slideToggle();
165                $(this).parent('.pagination-tab').toggleClass('is-open');
166              }
167              return false;
168            });
169          } else {
170            $(this).next('.pagination-tab-body').show();
171            $(this).parent('.pagination-tab').removeClass('is-open');
172          }
173        });
174      };
175    };
176
177    mediaQuery.addListener(accordionOnlySp);
178    accordionOnlySp(mediaQuery);
179
180
181    /**
182     * SP 横スクロール アイコン非表示
183     */
184    const tableScrolling = function () {
185      if (mediaQuery.matches === true) {
186        $('.table-scroll-icon').on('scroll', function () {
187          if ($(this).scrollLeft() > 0) {
188            $(this).addClass('is-scroll');
189          }
190        });
191      } else {
192        $('.table-scroll-icon').removeClass('is-scroll');
193      }
194    };
195
196    mediaQuery.addListener(tableScrolling);
197    tableScrolling(mediaQuery);
198
199
200    /**
201     * キーボード操作を可能にするため
202     * 横スクロールするtableにはtabindex="0"を追加
203     */
204    if ($('.table-scroll').length) {
205      $('.table-scroll').children('table').each(function () {
206        if (!$(this).attr('tabindex')) {
207          $(this).attr('tabindex', '0');
208        }
209      })
210    };
211  });
212})(window.jQuery);
213
214
215/**
216* 既存コード
217*/
218
219/****************************************
220swapimage.js
221****************************************/
222
223function MM_swapImgRestore() { //v3.0
224var i,x,a=document.MM_sr;
224 for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
225}
226
227function MM_preloadImages() { //v3.0
228var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
229var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
230if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
231}
232
233function MM_findObj(n, d) { //v4.01
234var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
235d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
236if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
237for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
238if(!x && d.getElementById) x=d.getElementById(n); return x;
239}
240
241function MM_swapImage() { //v3.0
242var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
243if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
244}

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.