PageSourceSearch

https://topworld.jp/wp-content/themes/theme_topworld.jp/assets/js/main.js?ver=1687415965

js topworld.jp collected 2026-09-30 22:27:34 UTC 9,692 bytes, 329 lines download raw bytes

1jQuery(function($) {
2
3  (function($) {
4    var cName;
5    switch (true) {
6      case (window._ua.Tablet):
7        cName = 'tablet';
8        break;
9      case (window._ua.Mobile):
10        cName = 'mobile';
11        break;
12      default:
13        cName = '';
14    }
15    $('body').addClass(cName);
16    var isTouchDevice = (function(d) {
17      var iframe = d.createElement('iframe');
18      d.body.appendChild(iframe);
19      var result = ('ontouchstart' in iframe.contentWindow);
20      d.body.removeChild(iframe);
21      return result;
22    })(document);
23    if (!isTouchDevice) {
24      $('body').addClass('touch-disabled');
25    }
26  })($)
27
28  var headerHeight = 0;
29  var headerOffset = 0;
30  var footerOffset = 0;
31  $('header').addClass('low');
32  $('footer').addClass('low');
33  $('.pagetop').hide().addClass('hidden');
34
35  var ua = navigator.userAgent.toLowerCase();
36  if (ua.indexOf('android') !== -1) {
37    $('.menu_icon a').addClass('fix');
38  }
39  if (ua.indexOf('iphone') !== -1 || ua.indexOf('ipad') !== -1) {
40    $('.parallax').addClass('ios');
41  }
42  if (ua.indexOf('safari') !== -1 && ua.indexOf('iPad') !== -1) {
43    $('.parallax').addClass('ios');
44  }
45  if (ua.indexOf('iPad') !== -1) {
46    $('.parallax').addClass('ios');
47  }
48  var ipad =
49    ua.indexOf('ipad') > -1 ||
50    (ua.indexOf('macintosh') > -1 && 'ontouchend' in document);
51  if (ipad == true) {
52    $('.parallax').addClass('ios');
53  }
54
55  // sp gnav
56  $('.menu_icon a').on('click', function(e) {
57    e.preventDefault();
58    $(this).toggleClass('close').parent().prev()
59    $('body').removeClass('down').addClass('up');
60    $(this).closest('header').toggleClass('menu_open');
61  });
62
63  // gnav
64  var navi_event = 'click';
65  if ($('.global_nav').css('list-style-position') === 'inside') {
66    navi_event =
67      (!$('body.mobile').length && !$('body.tablet').length) ?
68      'mouseenter mouseleave' : 'touchend';
69    $('.has_under').on('click', function(e) {
70      var tagName = e.target.tagName.toLowerCase();
71      if (!tagName === 'a' || $(e.target.parentNode).hasClass('has_under')) {
72        e.preventDefault();
73      }
74    });
75  }
76  $('.has_under').on(navi_event, function(e) {
77    var tagName = e.target.tagName.toLowerCase();
78    if (tagName === 'a' && !$(e.target.parentNode).hasClass('has_under')) {
79      return;
80    }
81    e.preventDefault();
82    var $self = $('>a', $(this));
83    //var $self = $(this);
84    if (!$self.hasClass('menu_under_open') && $('.menu_under_open').length) {
85      $('.menu_under_open')
86        .removeClass('menu_under_open')
87        .next().stop().slideToggle(200);
88    }
89    $self.toggleClass('menu_under_open');
90    $self.next().stop().slideToggle(200);
91  });
92  $('.gnav_search>a').on('click', function(e) {
93    e.preventDefault();
94    //$(this).toggleClass('menu_under_open');
95    $(this).next().slideToggle(200);
96  });
97
98  // pagetop
99  $('.pagetop a').on('click', function(e) {
100    e.preventDefault();
101    $('html, body').animate({
102      scrollTop: 0
103    });
104  });
105
106  // iOS svg tap fix
107  if ($('body.mobile').length || $('body.tablet').length) {
108    $('header .title a').on('touchend', function(e) {
109      e.preventDefault();
110      location.href = this.href;
111    });
112  }
113
114  // swipebox
115  if ($.isFunction($().swipebox)) {
116    var swipebox = $('.swipebox').swipebox();
117    // $(document).on('click touchend', '#swipebox-overlay', function(e) {
118    //   e.preventDefault();
119    //   if ($(e.target).hasClass('slide')) $.swipebox.close();
120    // })
121  }
122
123  $('.slide_scroll').click(function(e) {
124    e.preventDefault();
125    var pos = $(this).closest('section').next().offset().top;
126    $('html, body').animate({
127      scrollTop: pos
128    });
129  });
130
131  // Fix SP Menu
132  function fixSpMenu() {
133    var win_h = $(window).height();
134    var hdr_h = $('header').height();
135    if ($('.menu_icon').is(':visible') && $('header').css('z-index') != 'auto') { // SP && Fixed
136      $('header .global_nav>ul').css('max-height', win_h - hdr_h);
137    } else {
138      $('header .global_nav>ul').css('max-height', 'none');
139    }
140  }
141
142  function fixPageTop(window) {
143    var currentPos = $(window).scrollTop();
144    var $pagetop = $('.pagetop');
145    if (currentPos > 200) {
146      $pagetop.fadeIn(200, function() {
147        $(this).removeClass('hidden');
148      });
149    } else {
150      $pagetop.fadeOut(200, function() {
151        $(this).addClass('hidden');
152      });
153    }
154  }
155
156  function fixMainSize() {
157    if ($('.main_visual').length) {
158      var mainPadding = +$('.main_visual').css('padding-top').replace('px', '');
159      var mainHeight = $('.main_visual').height();
160      return (mainPadding > mainHeight) ? mainPadding : mainHeight;
161    } else {
162      return false;
163    }
164  }
165
166  // Scroll Event
167  var scrolltimer = false;
168  var prevPos = 0;
169  $(window).on('scroll touchmove', function() {
170    $('body').addClass('scroll');
171    var currentPos = $(this).scrollTop();
172
173    headerOffset = fixMainSize();
174    footerOffset = $('footer').offset().top;
175
176    if (currentPos > headerOffset) {
177      $('header').removeClass('low').addClass('high');
178    } else {
179      $('header').removeClass('high').addClass('low');
180    }
181
182    if ((currentPos + $(this).height()) > footerOffset) {
183      $('footer').removeClass('low').addClass('high');
184    } else {
185      $('footer').removeClass('high').addClass('low');
186    }
187
188    fixPageTop(this);
189
190    if (currentPos > prevPos && currentPos > 0) { // down
191      $('body').removeClass('up').addClass('down') //.css('paddingTop', 0);
192      if (currentPos > headerHeight) {
193        $('header').addClass('hidden');
194      }
195    } else { // up
196      $('body').removeClass('down').addClass('up').css('paddingTop', function() {
197        return $('header').css('position') == 'fixed' ? headerHeight : 0;
198      });
199      $('header').removeClass('hidden');
200    }
201    if (!currentPos) {
202      $('body').addClass('scrollTop');
203    } else {
204      $('body').removeClass('scrollTop');
205    }
206    prevPos = currentPos;
207
208    if (scrolltimer !== false) {
209      clearTimeout(scrolltimer);
210    }
211    scrolltimer = setTimeout(function() {
212      $('body').removeClass('scroll');
213      $('body').removeClass('down').addClass('up').css('paddingTop', function() {
214        return $('header').css('position') == 'fixed' ? headerHeight : 0;
215      });
216      $('header').removeClass('hidden');
217    }, 500);
218  });
219
220  // Resize Event
221  var resizetimer = false;
222  $(window).resize(function() {
223    if (resizetimer !== false) {
224      clearTimeout(resizetimer);
225    }
226    resizetimer = setTimeout(function() {
227      fixSpMenu();
228      $('.tile').each(function() {
229        $(this).children().tile();
230      });
231      headerHeight = $('header').height();
232      headerOffset = $('header').offset().top;
233      footerOffset = $('footer').offset().top;
234      $('.tile').each(function() {
235        $(this).children().tile();
236      });
237    }, 200);
238  });
239
240  // main_slider
241  if ($.isFunction($().slick)) {
242    (function($) {
243      if ($('.main_visual_slick li').length <= 1) return;
244      if ($('.main_visual').css('transform') !== 'none') {
245        var html = $('.main_visual_slick').html();
246        var $ul = $('<ul class="main_visual_slick_thumb">');
247        $('.main_visual').append($ul.html(html));
248      }
249      var fade = false;
250      var arrows = false;
251      var dots = false;
252      var speed = 500;
253      var appendArrows = $('.main_visual_slick');
254      if ($('.main_visual').css('table-layout') === 'fixed') {
255        fade = true;
256        speed = 1000;
257      }
258      if ($('.main_visual').css('list-style-position') === 'inside') {
259        arrows = true;
260        $('.main_visual').append('<div class="main_visual_arrow"></div>');
261        appendArrows = $('.main_visual_arrow');
262      }
263      if ($('.main_visual').css('list-style-type') === 'circle') {
264        dots = true;
265      }
266      var slick = $('.main_visual_slick').slick({
267        slidesToShow: 1,
268        autoplay: true,
269        fade: fade,
270        arrows: arrows,
271        dots: dots,
272        appendArrows: appendArrows,
273        autoplaySpeed: 5000,
274        speed: speed,
275      }).on('beforeChange', function(e, slick, currentSlide, nextSlide) {
276        if ($('.main_visual_copy').css('transform') !== 'none') {
277          var $copy = $('.main_visual_copy li');
278          $copy.eq(currentSlide).removeClass('active');
279          $copy.eq(nextSlide).addClass('active');
280        }
281      });
282      if ($('.main_visual_copy').css('transform') !== 'none') {
283        $('.main_visual_copy li').eq(0).addClass('active').show();
284      }
285    })($);
286  }
287
288  // pc-only等のタグ前後に出てくる改行コードを除去
289  $('br.pc-only, br.sp-only, br.tablet-only, br.pc-hide, br.sp-hide, br.tablet-hide, sup, sub').each(function(){
290    var $parent = $(this).parent();
291    if( !$parent.length ) return true;
292    var html = $parent.html();
293    html = html
294      .replace(/\n/g, '')
295      .replace(/\s*?(<br class="(sp|pc|tablet)-(only|hide)([^>+?])>)\s*/g, '$1')
296      .replace(/(,|\.)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
297      .replace(/(\d)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
298      .replace(/\s*?<(sup|sub)/g, '<$1');
299    $parent.html( html );
300  });
301
302  // 遅延読み込み時のtile強制発火
303  if(typeof MutationObserver !== 'undefined') { // IE10-
304    var observer = new MutationObserver(function(){
305      $(window).trigger('resize')
306    });
307
308    var config = {
309      attributes: true,
310      childList: true,
311      characterData: true
312    };
313
314    $('.tile .lazy-hidden').each(function(){
315      observer.observe(this, config);
316    });
317  }
318
319});
320
321// Load Event
322jQuery(window).on('load', function() {
323  if (typeof WOW !== 'undefined') {
324    new WOW().init();
325  }
326  jQuery('.tile').each(function() {
327    jQuery(this).children().tile();
328  });
329});

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.