PageSourceSearch

https://www.tentoumusi.net/wp-content/themes/tentoumusi-nagasaki.com_theme/assets/js/main.js?

js tentoumusi.net collected 2026-10-07 23:38:39 UTC 16,083 bytes, 535 lines download raw bytes

1$(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;
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
43  // scrollbar
44  var scrollbarWidth = window.innerWidth - document.body.clientWidth;
45
46  // sp gnav
47  $('.menu_icon a').on('click', function(e) {
48    e.preventDefault();
49    $(this).toggleClass('close').parent().prev()
50    $('body').removeClass('down').addClass('up');
51    $(this).closest('header').toggleClass('menu_open');
52  });
53
54  // gnav
55  var navi_event = 'click';
56  if ($('.global_nav').css('list-style-position') === 'inside') {
57    navi_event =
58      (!$('body.mobile').length && !$('body.tablet').length) ?
59      'mouseenter mouseleave' : 'touchend';
60    $('.has_under').on('click', function(e) {
61      var tagName = e.target.tagName.toLowerCase();
62      if (!tagName === 'a' || $(e.target.parentNode).hasClass('has_under')) {
63        e.preventDefault();
64      }
65    });
66  }
67  $('.has_under').on(navi_event, function(e) {
68    var tagName = e.target.tagName.toLowerCase();
69    if (tagName === 'a' && !$(e.target.parentNode).hasClass('has_under')) {
70      return;
71    }
72    e.preventDefault();
73    var $self = $('>a', $(this));
74    //var $self = $(this);
75    if (!$self.hasClass('menu_under_open') && $('.menu_under_open').length) {
76      $('.menu_under_open')
77        .removeClass('menu_under_open')
78        .next().stop().slideToggle(200);
79    }
80    $self.toggleClass('menu_under_open');
81    $self.next().stop().slideToggle(200);
82  });
83  $('.gnav_search>a').on('click', function(e) {
84    e.preventDefault();
85    //$(this).toggleClass('menu_under_open');
86    $(this).next().slideToggle(200);
87  });
88
89  // pagetop
90  $('.pagetop a').on('click', function(e) {
91    e.preventDefault();
92    $('html, body').animate({
93      scrollTop: 0
94    });
95  });
96
97  // iOS svg tap fix
98  if ($('body.mobile').length || $('body.tablet').length) {
99    $('header .title a').on('touchend', function(e) {
100      e.preventDefault();
101      location.href = this.href;
102    });
103  }
104
105  // swipebox
106  if ($.isFunction($().swipebox)) {
107    var swipebox = $('.swipebox').swipebox();
108    $(document).on('click touchend', '#swipebox-overlay', function(e) {
109      e.preventDefault();
110      if ($(e.target).hasClass('slide')) $.swipebox.close();
111    })
112  }
113
114  // slider
115  if ($.isFunction($().sliderPro)) {
116    var sliderDefaults = {
117      center: {
118        width: 1000,
119        height: 450,
120        slideDistance: 0,
121        visibleSize: '100%',
122        arrows: true,
123        fadeArrows: false,
124        autoScaleLayers: false,
125        breakpoints: {}
126      },
127      wide: {
128        width: '100%',
129        autoHeight: true,
130        slideDistance: 0,
131        arrows: true,
132        fadeArrows: false,
133        fade: true,
134        autoScaleLayers: false,
135        touchSwipe: false,
136        breakpoints: {}
137      },
138      contents: {
139        width: 450,
140        height: 300,
141        aspectRatio: 1.5,
142        slideDistance: 10,
143        visibleSize: '100%',
144        arrows: true,
145        fadeArrows: false,
146        buttons: false,
147        fadeCaption: false,
148        breakpoints: {}
149      }
150    };
151    $('.slider-pro').each(function() {
152      var opt = $(this).data();
153      var number_of_slide = $(this).find('.sp-slide').length;
154      $(this).addClass(opt.type || 'center');
155      if (!this.hasAttribute('data-type')) {
156        return true;
157      }
158      var options = $.extend(true, (sliderDefaults[opt.type] || sliderDefaults.center), {});
159      if (opt.width) {
160        options.width = opt.width
161      }
162      if (opt.height) {
163        options.height = opt.height
164      }
165      if (typeof opt.distance !== 'undefined') {
166        options.slideDistance = opt.distance
167      }
168      if (opt.type == 'contents') {
169        if (opt.width || opt.height) {
170          options.aspectRatio = Math.round(options.width / options.height * 100) / 100;
171        }
172        if (number_of_slide % 2 === 0) {
173          options.visibleSize = options.width * (number_of_slide - 1) + options.slideDistance * (number_of_slide - 2);
174        }
175      }
176      if (typeof opt.autoplay !== 'undefined') {
177        options.autoplay = opt.autoplay
178      }
179      if (typeof opt.arrows !== 'undefined') {
180        switch (opt.arrows) {
181          case false:
182            options.arrows = false;
183            $(this).addClass('disable-arrows');
184            break;
185          case 'pc-only':
186            var bp = 768 - scrollbarWidth - 1;
187            options.breakpoints[bp] = options.breakpoints[bp] || {};
188            options.breakpoints[bp].arrows = false;
189            $(this).addClass('sp-disable-arrows');
190            break;
191        }
192      }
193      if (typeof opt.buttons !== 'undefined') {
194        switch (opt.buttons) {
195          case false:
196            options.buttons = false;
197            break;
198          case 'pc-only':
199            var bp = 768 - scrollbarWidth - 1;
200            options.breakpoints[bp] = options.breakpoints[bp] || {};
201            options.breakpoints[bp].buttons = false;
202            break;
203        }
204      }
205      $(this).sliderPro(options);
206    });
207  }
208
209  $('.slide_scroll').click(function(e) {
210    e.preventDefault();
211    var pos = $(this).closest('section').next().offset().top;
212    $('html, body').animate({
213      scrollTop: pos
214    });
215  });
216
217  // Q&A
218   $('.qa:not(.qa-open) .question').click(function() {
219     $(this).toggleClass('open').next('.answer').slideToggle();
220   });
221
222  // responsive scroll table
223  $('table.responsive-scroll').wrap(
224    '<div><div class="responsive-scroll-container"><div class="responsive-scroll-inner"></div></div><p class="sp-only text-center text-small">※横スクロールで全体を表示します。</p></div>'
225  );
226
227  // responsive list table
228  $('table.responsive-list').each(function() {
229    var header = [];
230    $(this).find('thead th').each(function() {
231      header.push($(this).text());
232    });
233    $(this).find('tbody td').each(function() {
234      $(this).attr('data-title', header[$(this).index()]);
235    });
236  });
237
238  // combine table
239  $('table.combine').closest('.col').css('margin-bottom', 0);
240
241  // Fix SP Menu
242  function fixSpMenu() {
243    var win_h = $(window).height();
244    var hdr_h = $('header').height();
245    if ($('.menu_icon').is(':visible') && $('header').css('z-index') != 'auto') { // SP && Fixed
246      $('header .global_nav>ul').css('max-height', win_h - hdr_h);
247    } else {
248      $('header .global_nav>ul').css('max-height', 'none');
249    }
250  }
251
252  function fixPageTop(window) {
253    var currentPos = $(window).scrollTop();
254    var $pagetop = $('.pagetop');
255    if (currentPos > 200) {
256      $pagetop.fadeIn(200, function() {
257        $(this).removeClass('hidden');
258      });
259    } else {
260      $pagetop.fadeOut(200, function() {
261        $(this).addClass('hidden');
262      });
263    }
264  }
265
266  function fixMainSize() {
267    if ($('.main_visual').length) {
268      var mainPadding = +$('.main_visual').css('padding-top').replace('px', '');
269      var mainHeight = $('.main_visual').height();
270      return (mainPadding > mainHeight) ? mainPadding : mainHeight;
271    } else {
272      return false;
273    }
274  }
275
276  // Load Event
277  $(window).load(function() {
278    headerOffset = fixMainSize();
279    footerOffset = $('footer').offset().top;
280    headerHeight = $('header').height();
281    $('body').removeClass('down').addClass('up').css('paddingTop', function() {
282      return $('header').css('position') == 'fixed' ? $('header').height() : 0;
283    });
284    if (typeof WOW !== 'undefined') {
285      new WOW().init();
286    }
287    fixSpMenu();
288    $('.tile').each(function() {
289      $(this).children().tile();
290    });
291  })
292
293  // Scroll Event
294  var scrolltimer = false;
295  var prevPos = 0;
296  $(window).on('scroll touchmove', function() {
297    $('body').addClass('scroll');
298    var currentPos = $(this).scrollTop();
299
300    headerOffset = fixMainSize();
301    footerOffset = $('footer').offset().top;
302
303    if (currentPos > headerOffset) {
304      $('header').removeClass('low').addClass('high');
305    } else {
306      $('header').removeClass('high').addClass('low');
307    }
308
309    if ((currentPos + $(this).height()) > footerOffset) {
310      $('footer').removeClass('low').addClass('high');
311    } else {
312      $('footer').removeClass('high').addClass('low');
313    }
314
315    fixPageTop(this);
316
317    if (currentPos > prevPos && currentPos > 0) { // down
318      $('body').removeClass('up').addClass('down') //.css('paddingTop', 0);
319      if (currentPos > headerHeight) {
320        $('header').addClass('hidden');
321      }
322    } else { // up
323      $('body').removeClass('down').addClass('up').css('paddingTop', function() {
324        return $('header').css('position') == 'fixed' ? headerHeight : 0;
325      });
326      $('header').removeClass('hidden');
327    }
328    if (!currentPos) {
329      $('body').addClass('scrollTop');
330    } else {
331      $('body').removeClass('scrollTop');
332    }
333    prevPos = currentPos;
334
335    if (scrolltimer !== false) {
336      clearTimeout(scrolltimer);
337    }
338    scrolltimer = setTimeout(function() {
339      $('body').removeClass('scroll');
340      $('body').removeClass('down').addClass('up').css('paddingTop', function() {
341        return $('header').css('position') == 'fixed' ? headerHeight : 0;
342      });
343      $('header').removeClass('hidden');
344    }, 500);
345  });
346
347  // Resize Event
348  var resizetimer = false;
349  $(window).resize(function() {
350    if (resizetimer !== false) {
351      clearTimeout(resizetimer);
352    }
353    resizetimer = setTimeout(function() {
354      fixSpMenu();
355      $('.tile').each(function() {
356        $(this).children().tile();
357      });
358      headerHeight = $('header').height();
359      headerOffset = $('header').offset().top;
360      footerOffset = $('footer').offset().top;
361      $('.tile').each(function() {
362        $(this).children().tile();
363      });
364    }, 200);
365  });
366
367  // main_slider
368  if ($.isFunction($().slick)) {
369    (function($) {
370      if ($('.main_visual_slick li').length <= 1) return;
371      if ($('.main_visual').css('transform') !== 'none') {
372        var html = $('.main_visual_slick').html();
373        var $ul = $('<ul class="main_visual_slick_thumb">');
374        $('.main_visual').append($ul.html(html));
375      }
376      var fade = false;
377      var arrows = false;
378      var dots = false;
379      var speed = 500;
380      var appendArrows = $('.main_visual_slick');
381      if ($('.main_visual').css('table-layout') === 'fixed') {
382        fade = true;
383        speed = 1000;
384      }
385      if ($('.main_visual').css('list-style-position') === 'inside') {
386        arrows = true;
387        $('.main_visual').append('<div class="main_visual_arrow"></div>');
388        appendArrows = $('.main_visual_arrow');
389      }
390      if ($('.main_visual').css('list-style-type') === 'circle') {
391        dots = true;
392      }
393      var slick = $('.main_visual_slick').slick({
394        slidesToShow: 1,
395        autoplay: true,
396        fade: fade,
397        arrows: arrows,
398        dots: dots,
399        appendArrows: appendArrows,
400        autoplaySpeed: 5000,
401        speed: speed,
402      }).on('beforeChange', function(e, slick, currentSlide, nextSlide) {
403        if ($('.main_visual_slick_thumb').length) {
404          $('.main_visual_slick_thumb_current').removeClass('main_visual_slick_thumb_current');
405          $('.main_visual_slick_thumb>li').eq(nextSlide).addClass('main_visual_slick_thumb_current');
406        }
407        if ($('.main_visual_copy').css('transform') !== 'none') {
408          var $copy = $('.main_visual_copy li');
409          $copy.eq(currentSlide).removeClass('active');
410          $copy.eq(nextSlide).addClass('active');
411        }
412      });
413      if ($('.main_visual_copy').css('transform') !== 'none') {
414        $('.main_visual_copy li').eq(0).addClass('active').show();
415      }
416      $('.main_visual_slick_thumb>li').on('click', function() {
417        var index = $(this).index();
418        slick.slick('slickGoTo', index);
419      });
420    })($);
421  }
422
423  if (typeof skrollr !== 'undefined' && !$('body').hasClass('tablet') && !$('body').hasClass('mobile')) {
424    skrollr.init();
425  }
426
427  if (typeof objectFitImages !== 'undefined') {
428    objectFitImages('.ofi img');
429  }
430
431  // pc-only等のタグ前後に出てくる改行コードを除去
432  $('br.pc-only, br.sp-only, br.tablet-only, br.pc-hide, br.sp-hide, br.tablet-hide, sup, sub').each(function(){
433    var $parent = $(this).parent();
434    if( !$parent.length ) return true;
435    var html = $parent.html();
436    html = html
437      .replace(/\n/g, '')
438      .replace(/\s*?(<br class="(sp|pc|tablet)-(only|hide)([^>+?])>)\s*/g, '$1')
439      .replace(/(,|\.)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
440      .replace(/(\d)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
441      .replace(/\s*?<(sup|sub)/g, '<$1');
442    $parent.html( html );
443  });
444  // FromCake
445  $('.sweetswidget').each(function(){
446    var self = this;
447    var dataset = $(self).data();
448    var shopcode = dataset.widgetcode;
449    if( shopcode===undefined ) return true;
450    var count = (dataset.widgetcount!==undefined)? dataset.widgetcount: 50;
451    var class_name = (dataset.widgetcarousel&&dataset.widgetcarousel!==undefined)? 'reservation_widget_carousel_wrap': '';
452    var url = 'https://sweetsguide.jp/shop/'+shopcode+'/widget';
453    var ajaxOption = {
454      method: 'get',
455      url: url,
456      data: {
457        class_name: class_name,
458        count: count,
459      },
460      dataType: 'html',
461    };
462    $.ajax(ajaxOption).done(function(html){
463      getWidget(self, html)
464    });
465  });
466
467  function getWidget(self, html){
468    $(self).after(html);
469    var current = $(self).next();
470    $(self).remove();
471    var $container = $(current);
472
473    customTile('h3', $container);
474    // Resize Event
475    var resizetimer = false;
476    $(window).resize(function() {
477      if (resizetimer !== false) {
478        clearTimeout(resizetimer);
479      }
480      resizetimer = setTimeout(function() {
481        customTile('h3', $container);
482      }, 200);
483    });
484    function customTile(selector, $container){
485      var $selector = $(selector, $container);
486      var h, max;
487      var last = $selector.length - 1;
488      $selector.each(function(i){
489        $(this).removeAttr('style');
490      }).each(function(i){
491        h = $(this).outerHeight();
492        if(i===0||h > max) max = h;
493        if(i == last) {
494          $selector.each(function(i){
495            $(this).css('height', max);
496          });
497        }
498      });
499    }
500    if( !$container
501      .hasClass('reservation_widget_carousel_wrap') ) return true;
502    var length = $('>li', $container).length;
503    if( length <= 4 ) {
504      $container.removeClass('reservation_widget_carousel_wrap');
505      return;
506    };
507    $container.removeClass('row_inline');
508    $('>li', $container).each(function(){
509      $(this).removeClass('span_3 col').addClass('reservation_widget_carousel');
510    });
511    $container.after('<div class="reservation_widget_arrow"></div>');
512    appendArrows = $container.next();
513    var slickOption = {
514      slidesToShow: 4,
515      autoplay: true,
516      arrows: true,
517      dots: true,
518      appendArrows: appendArrows,
519      responsive: [{
520        breakpoint: 900,
521        settings: {
522          slidesToShow: 3
523        }
524      },{
525        breakpoint: 768,
526        settings: {
527          slidesToShow: 2
528        }
529      }]
530    };
531    $container.slick(slickOption);
532    customTile('h3', $container);
533  }
534
535});

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.