PageSourceSearch

https://nanchiken.jp/wp-content/themes/S4-009-Blue/resources/functions/js/functions.js?ver=20221108

js nanchiken.jp collected 2026-09-30 16:46:21 UTC 6,172 bytes, 203 lines download raw bytes

1$(function() {
2  'use strict';
3  var $window = $(window),
4      $document = $(document),
5      $body = $('body'),
6      $menu = $('#menu'),
7      $menuBtn = $('#menu_btn'),
8      $menuOverlay = $('#menu_overlay'),
9      $search = $('#search'),
10      $searchInput = $('#search_input'),
11      $searchBtn = $('#search_btn'),
12      $searchOverlay = $('#search_overlay'),
13      $pagetopBtn = $('#pagetop_btn'),
14      resize_timer = false,
15      current_scrollPos,
16      menu_height,
17      windowWidth,
18      windowWidth_resized,
19      opt = {
20        'setting': {
21          'pc_width': 1080
22        },
23        'enable': {
24          'topicPath': true,
25          'enlarge': false // 画像をタップで拡大
26        },
27        'className': {
28          'state_hide': 'state-hide',
29          'mainMenuBtn_close': 'menu-btn-close',
30          'mainMenu_active': 'main-menu-active',
31          'search_active': 'search-active',
32          'enlarge': 'sui-enlarge'
33        },
34        'animate': {
35          'duration': 200,
36          'easing': 'linear'
37        }
38      };
39  // init
40  init();
41  function init() {
42    $menuBtn.on('click', function() {
43      if ($menu.hasClass(opt.className.state_hide)) {
44        openMenu();
45        $body.addClass(opt.className.mainMenu_active);
46      } else {
47        closeMenu();
48        $body.removeClass(opt.className.mainMenu_active);
49      }
50      return false;
51    });
52    $searchBtn.on('click', function() {
53      $searchOverlay.toggleClass(opt.className.state_hide);
54      $search.toggleClass(opt.className.state_hide);
55      $searchInput.focus();
56      $body.addClass(opt.className.search_active);
57      return false;
58    });
59    $searchOverlay.on('click', function() {
60      $searchOverlay.toggleClass(opt.className.state_hide);
61      $search.toggleClass(opt.className.state_hide);
62      $searchInput.blur();
63      $body.removeClass(opt.className.search_active);
64      return false;
65    });
66    // resize
67    windowWidth = $window.width();
68    resizeFunc();
69    $window.on('orientationchange resize', function() {
70      if ($window.width() < opt.setting.pc_width) {
71        // $menu.addClass(opt.className.state_hide);
72      } else {
73        $body.css('height', 'auto');
74        $menu.removeClass(opt.className.state_hide)
75      }
76      if (resize_timer !== false) {
77        clearTimeout(resize_timer);
78      }
79      resize_timer = setTimeout(function() {
80        windowWidth_resized = $window.width();
81        if (windowWidth != windowWidth_resized) {
82          windowWidth = $window.width();
83          //
84          resizeFunc();
85        }
86      }, 100);
87    });
88    // ページ内リンク
89    $('a[href^="#"]').on('click', function() {
90      var speed = 500,
91          href= $(this).attr('href'),
92          target = $(href == '#' || href == '' ? 'html' : href),
93          position = 0;
94      if (target.length > 0) position = target.offset().top;
95      $('html, body').animate({scrollTop: position}, speed, 'swing');
96      var scrollTargetId = target.attr('id');
97      setTimeout(function(){
98        if (scrollTargetId) location.hash = scrollTargetId;
99        return false;
100      }, 500);
101    });
102    ratio();
103  }
104  function resizeFunc() {
105      if ($window.width() < opt.setting.pc_width) {
106        // sp
107        closeMenu();
108        $searchOverlay.removeClass(opt.className.state_hide);
109        $search.removeClass(opt.className.state_hide);
110        $body.removeClass(opt.className.search_active);
111      } else {
112        // pc
113        $menu.removeClass(opt.className.state_hide).css('opacity', 1);
114        $menuOverlay.addClass(opt.className.state_hide);
115        $searchOverlay.addClass(opt.className.state_hide);
116        $search.addClass(opt.className.state_hide);
117      }
118      $body.removeClass(opt.className.mainMenu_active);
119  }
120  // function initOverlay() {
121  //   $overlay.css({
122  //     width: $document.width(),
123  //     height: $document.height()
124  //   });
125  // }
126  function openMenu() {
127    current_scrollPos = $window.scrollTop();
128    // menu_height = $menu.height();
129    // initOverlay();
130    // $pagetopBtn.transition(
131    //   {
132    //     opacity: 0,
133    //   },
134    //   opt.animate.duration,
135    //   opt.animate.easing,
136    //   function() {
137    //     $pagetopBtn.addClass(opt.className.state_hide);
138    //   }
139    // );
140    $menuOverlay.removeClass(opt.className.state_hide).transition(
141      {
142        opacity: 1
143      },
144      opt.animate.duration,
145      opt.animate.easing,
146      function() {
147        $menu.removeClass(opt.className.state_hide);
148        menu_height = $menu.height();
149        $window.scrollTop(0);
150        $body.css({
151          overflow: 'hidden',
152          height: menu_height
153        });
154        $menu.removeClass(opt.className.state_hide).transition(
155          {
156            opacity: 1
157          },
158          opt.animate.duration,
159          opt.animate.easing
160        );
161        // menu-btn
162        $menuBtn.addClass(opt.className.mainMenuBtn_close);
163      }
164    );
165  }
166  function closeMenu() {
167    $menu.transition(
168      {
169        opacity: 0
170      },
171      opt.animate.duration,
172      opt.animate.easing,
173      function() {
174        $menu.addClass(opt.className.state_hide);
175        $body.css({
176          overflow: 'auto',
177          height: 'auto'
178          // top: bodyContentsPos
179        });
180        $window.scrollTop(current_scrollPos);
181        $menuOverlay.transition(
182          {
183            opacity: 0
184          },
185          opt.animate.duration,
186          opt.animate.easing,
187          function() {
188            $menuOverlay.addClass(opt.className.state_hide);
189          }
190        );
191        // menu-btn
192        $menuBtn.removeClass(opt.className.mainMenuBtn_close);
193      }
194    );
195  }
196  function ratio() {
197    $('iframe[src*="www.google.com/maps/embed"]', '.editing').each(function() {
198      if ((!$(this).parent().hasClass('ratio') && !$(this).parent().hasClass('map')) && !$(this).hasClass('js-no-ratio')) {
199        $(this).wrap('<div class="ratio" />');
200      }
201    });
202  }
203});

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.