PageSourceSearch

https://ashizawa-shika.com/wp-content/themes/ashizawa_theme/assets/js/main.js?t=1791274498

js ashizawa-shika.com collected 2026-10-06 08:15:06 UTC 21,332 bytes, 776 lines download raw bytes

1function main() {
2  (function ($) {
3    var cName;
4    switch (true) {
5      case window._ua.Tablet:
6        cName = 'tablet';
7        break;
8      case window._ua.Mobile:
9        cName = 'mobile';
10        break;
11      default:
12        cName = '';
13    }
14    $('body').addClass(cName);
15    var isTouchDevice = (function (d) {
16      var iframe = d.createElement('iframe');
17      d.body.appendChild(iframe);
18      var result = 'ontouchstart' in iframe.contentWindow;
19      d.body.removeChild(iframe);
20      return result;
21    })(document);
22    if (!isTouchDevice) {
23      $('body').addClass('touch-disabled');
24    }
25  })($);
26
27  var headerHeight = 0;
28  var headerOffset = 0;
29  var footerOffset = 0;
30  $('#header').addClass('low');
31  $('#footer').addClass('low');
32  $('.pagetop')
33    .hide()
34    .addClass('hidden');
35
36  var ua = navigator.userAgent.toLowerCase();
37  if (ua.indexOf('android') !== -1) {
38    $('.menu_icon a').addClass('fix');
39  }
40  if (ua.indexOf('iphone') !== -1 || ua.indexOf('ipad') !== -1) {
41    $('.parallax').addClass('ios');
42  }
43  if (ua.indexOf('safari') !== -1 && ua.indexOf('iPad') !== -1) {
44    $('.parallax').addClass('ios');
45  }
46  if (ua.indexOf('iPad') !== -1) {
47    $('.parallax').addClass('ios');
48  }
49  var ipad =
50    ua.indexOf('ipad') > -1 ||
51    (ua.indexOf('macintosh') > -1 && 'ontouchend' in document);
52  if (ipad == true) {
53    $('.parallax').addClass('ios');
54  }
55
56  // scrollbar
57  var scrollbarWidth = window.innerWidth - document.body.clientWidth;
58
59  // sp gnav
60  $('.menu_icon a').on('click', function (e) {
61    e.preventDefault();
62  
63    const $menuBtn = $(this);
64    const $header = $menuBtn.closest('#header');
65    const $gnav = $header.find('.global_nav > ul');
66  
67    const isOpen = $header.hasClass('menu_open');
68  
69    if (isOpen) {
70      $gnav.css('transform', 'rotateX(90deg)');
71      $menuBtn.removeClass('close');
72      setTimeout(() => {
73        $header.removeClass('menu_open');
74        $gnav.css('transform', '');
75      }, 300);
76  
77    } else {
78      $header.addClass('menu_open');
79      $menuBtn.addClass('close');
80    }
81  
82    $('body').removeClass('down').addClass('up');
83  });
84
85  // gnav
86  var navi_event = 'click';
87  if ($('.global_nav').css('list-style-position') === 'inside') {
88    navi_event =
89      !$('body.mobile').length && !$('body.tablet').length
90        ? 'mouseenter mouseleave'
91        : 'touchend';
92    $('.has_under').on('click', function (e) {
93      var tagName = e.target.tagName.toLowerCase();
94      if (!tagName === 'a' || $(e.target.parentNode).hasClass('has_under')) {
95        e.preventDefault();
96      }
97    });
98  }
99  $('.has_under').on(navi_event, function (e) {
100    var tagName = e.target.tagName.toLowerCase();
101    if ($('.global_nav').css('list-style-position') !== 'inside' && (tagName === 'a' && !$(e.target.parentNode).hasClass('has_under'))) {
102      return;
103    }
104    e.preventDefault();
105    var $self = $('>a', $(this));
106    //var $self = $(this);
107    if (!$self.hasClass('menu_under_open') && $('.menu_under_open').length) {
108      $('.menu_under_open')
109        .removeClass('menu_under_open')
110        .next()
111        .stop()
112        .slideToggle(200);
113    }
114    $self.toggleClass('menu_under_open');
115    $self
116      .next()
117      .stop()
118      .slideToggle(200);
119  });
120  $('.gnav_search>a').on('click', function (e) {
121    e.preventDefault();
122    //$(this).toggleClass('menu_under_open');
123    $(this)
124      .next()
125      .slideToggle(200);
126  });
127
128  // pagetop
129  $('.pagetop a').on('click', function (e) {
130    e.preventDefault();
131    $('html, body').animate({
132      scrollTop: 0
133    });
134  });
135
136  // iOS svg tap fix
137  if ($('body.mobile').length || $('body.tablet').length) {
138    $('#header .title a').on('touchend', function (e) {
139      e.preventDefault();
140      location.href = this.href;
141    });
142  }
143
144  // swipebox
145  if ($.isFunction($().swipebox)) {
146    var swipebox = $('.swipebox').swipebox();
147    $(document).on('click touchend', '#swipebox-overlay', function (e) {
148      e.preventDefault();
149      if ($(e.target).hasClass('slide')) $.swipebox.close();
150    });
151  }
152
153  // slider
154  if ($.isFunction($().sliderPro)) {
155    var sliderDefaults = {
156      center: {
157        width: 1000,
158        height: 450,
159        slideDistance: 0,
160        visibleSize: '100%',
161        arrows: true,
162        fadeArrows: false,
163        autoScaleLayers: false,
164        breakpoints: {}
165      },
166      wide: {
167        width: '100%',
168        autoHeight: true,
169        slideDistance: 0,
170        arrows: true,
171        fadeArrows: false,
172        fade: true,
173        autoScaleLayers: false,
174        touchSwipe: false,
175        breakpoints: {}
176      },
177      contents: {
178        width: 450,
179        height: 300,
180        aspectRatio: 1.5,
181        slideDistance: 10,
182        visibleSize: '100%',
183        arrows: true,
184        fadeArrows: false,
185        buttons: false,
186        fadeCaption: false,
187        breakpoints: {}
188      }
189    };
190    $('.slider-pro').each(function () {
191      var opt = $(this).data();
192      var number_of_slide = $(this).find('.sp-slide').length;
193      $(this).addClass(opt.type || 'center');
194      if (!this.hasAttribute('data-type')) {
195        return true;
196      }
197      var options = $.extend(
198        true,
199        sliderDefaults[opt.type] || sliderDefaults.center,
200        {}
201      );
202      if (opt.width) {
203        options.width = opt.width;
204      }
205      if (opt.height) {
206        options.height = opt.height;
207      }
208      if (typeof opt.distance !== 'undefined') {
209        options.slideDistance = opt.distance;
210      }
211      if (opt.type == 'contents') {
212        if (opt.width || opt.height) {
213          options.aspectRatio =
214            Math.round((options.width / options.height) * 100) / 100;
215        }
216        if (number_of_slide % 2 === 0) {
217          options.visibleSize =
218            options.width * (number_of_slide - 1) +
219            options.slideDistance * (number_of_slide - 2);
220        }
221      }
222      if (typeof opt.autoplay !== 'undefined') {
223        options.autoplay = opt.autoplay;
224      }
225      if (typeof opt.arrows !== 'undefined') {
226        switch (opt.arrows) {
227          case false:
228            options.arrows = false;
229            $(this).addClass('disable-arrows');
230            break;
231          case 'pc-only':
232            var bp = 768 - scrollbarWidth - 1;
233            options.breakpoints[bp] = options.breakpoints[bp] || {};
234            options.breakpoints[bp].arrows = false;
235            $(this).addClass('sp-disable-arrows');
236            break;
237        }
238      }
239      if (typeof opt.buttons !== 'undefined') {
240        switch (opt.buttons) {
241          case false:
242            options.buttons = false;
243            break;
244          case 'pc-only':
245            var bp = 768 - scrollbarWidth - 1;
246            options.breakpoints[bp] = options.breakpoints[bp] || {};
247            options.breakpoints[bp].buttons = false;
248            break;
249        }
250      }
251      $(this).sliderPro(options);
252    });
253  }
254
255  $('.slide_scroll').click(function (e) {
256    e.preventDefault();
257    var pos = $(this)
258      .closest('section')
259      .next()
260      .offset().top;
261    $('html, body').animate({
262      scrollTop: pos
263    });
264  });
265
266  // Q&A
267  // $('.qa:not(.qa-open) .question').click(function() {
268  //   $(this).toggleClass('open').next('.answer').slideToggle();
269  // });
270
271  // responsive scroll table
272  $('table.responsive-scroll').wrap(
273    '<div><div class="responsive-scroll-container"><div class="responsive-scroll-inner"></div></div><p class="sp-only text-center text-small">※横スクロールで全体を表示します。</p></div>'
274  );
275
276  // responsive list table
277  $('table.responsive-list').each(function () {
278    var header = [];
279    $(this)
280      .find('thead th')
281      .each(function () {
282        header.push($(this).text());
283      });
284    $(this)
285      .find('tbody td')
286      .each(function () {
287        $(this).attr('data-title', header[$(this).index()]);
288      });
289  });
290
291  // combine table
292  $('table.combine')
293    .closest('.col')
294    .css('margin-bottom', 0);
295
296  // Fix SP Menu
297  function fixSpMenu() {
298    var win_h = $(window).height();
299    var hdr_h = $('#header').height();
300    if (
301      $('.menu_icon').is(':visible') &&
302      $('#header').css('z-index') != 'auto'
303    ) {
304      // SP && Fixed
305      $('#header .global_nav>ul').css('max-height', win_h - hdr_h);
306    } else {
307      $('#header .global_nav>ul').css('max-height', 'none');
308    }
309  }
310
311  function fixPageTop(window) {
312    var currentPos = $(window).scrollTop();
313    var $pagetop = $('.pagetop');
314    if (currentPos > 200) {
315      $pagetop.fadeIn(200, function () {
316        $(this).removeClass('hidden');
317      });
318    } else {
319      $pagetop.fadeOut(200, function () {
320        $(this).addClass('hidden');
321      });
322    }
323  }
324
325  function fixMainSize() {
326    if ($('.main_visual').length) {
327      var mainPadding = +$('.main_visual')
328        .css('padding-top')
329        .replace('px', '');
330      var mainHeight = $('.main_visual').height();
331      return mainPadding > mainHeight ? mainPadding : mainHeight;
332    } else {
333      return false;
334    }
335  }
336
337  // Load Event
338  if (ep_theme_options.windowEventLoaded) {
339    windowLoadEvent()
340  } else {
341    $(window).on('load', windowLoadEvent);
342  }
343
344  function windowLoadEvent() {
345    headerOffset = fixMainSize();
346    footerOffset = $('#footer').offset().top;
347    headerHeight = $('#header').height();
348    $('body')
349      .removeClass('down')
350      .addClass('up')
351      .css('paddingTop', function () {
352        return $('#header').css('position') == 'fixed'
353          ? $('#header').height()
354          : 0;
355      });
356    if (typeof WOW !== 'undefined') {
357      new WOW().init();
358    }
359    fixSpMenu();
360    $('.tile').each(function () {
361      $(this)
362        .children()
363        .tile();
364    });
365  }
366
367  // Scroll Event
368  var scrolltimer = false;
369  var prevPos = 0;
370  $(window).on('scroll touchmove', function () {
371    $('body').addClass('scroll');
372    var currentPos = $(this).scrollTop();
373
374    headerOffset = fixMainSize();
375    footerOffset = $('#footer').offset().top;
376
377    if (currentPos > headerOffset) {
378      $('#header')
379        .removeClass('low')
380        .addClass('high');
381    } else {
382      $('#header')
383        .removeClass('high')
384        .addClass('low');
385    }
386
387    if (currentPos + $(this).height() > footerOffset) {
388      $('#footer')
389        .removeClass('low')
390        .addClass('high');
391    } else {
392      $('#footer')
393        .removeClass('high')
394        .addClass('low');
395    }
396
397    fixPageTop(this);
398
399    if (currentPos > prevPos && currentPos > 0) {
400      // down
401      $('body')
402        .removeClass('up')
403        .addClass('down'); //.css('paddingTop', 0);
404      if (currentPos > headerHeight) {
405        $('#header').addClass('hidden');
406      }
407    } else {
408      // up
409      $('body')
410        .removeClass('down')
411        .addClass('up')
412        .css('paddingTop', function () {
413          return $('#header').css('position') == 'fixed' ? headerHeight : 0;
414        });
415      $('#header').removeClass('hidden');
416    }
417    if (!currentPos) {
418      $('body').addClass('scrollTop');
419    } else {
420      $('body').removeClass('scrollTop');
421    }
422    prevPos = currentPos;
423
424    if (scrolltimer !== false) {
425      clearTimeout(scrolltimer);
426    }
427    scrolltimer = setTimeout(function () {
428      $('body').removeClass('scroll');
429      $('body')
430        .removeClass('down')
431        .addClass('up')
432        .css('paddingTop', function () {
433          return $('#header').css('position') == 'fixed' ? headerHeight : 0;
434        });
435      $('#header').removeClass('hidden');
436    }, 500);
437  });
438
439  // Resize Event
440  var resizetimer = false;
441  $(window).resize(function () {
442    if (resizetimer !== false) {
443      clearTimeout(resizetimer);
444    }
445    resizetimer = setTimeout(function () {
446      fixSpMenu();
447      $('.tile').each(function () {
448        $(this)
449          .children()
450          .tile();
451      });
452      headerHeight = $('#header').height();
453      headerOffset = $('#header').offset().top;
454      footerOffset = $('#footer').offset().top;
455      $('.tile').each(function () {
456        $(this)
457          .children()
458          .tile();
459      });
460    }, 200);
461  });
462
463  // main_slider
464  if ($.isFunction($().slick)) {
465    (function ($) {
466      if ($('.main_visual_slick li').length <= 1) return;
467      if ($('.main_visual').css('transform') !== 'none') {
468        var html = $('.main_visual_slick').html();
469        var $ul = $('<ul class="main_visual_slick_thumb">');
470        $('.main_visual').append($ul.html(html));
471      }
472      var fade = false;
473      var arrows = false;
474      var dots = false;
475      var speed = 500;
476      var appendArrows = $('.main_visual_slick');
477      if ($('.main_visual').css('table-layout') === 'fixed') {
478        fade = true;
479        speed = 1000;
480      }
481      if ($('.main_visual').css('list-style-position') === 'inside') {
482        arrows = true;
483        $('.main_visual').append('<div class="main_visual_arrow"></div>');
484        appendArrows = $('.main_visual_arrow');
485      }
486      if ($('.main_visual').css('list-style-type') === 'circle') {
487        dots = true;
488      }
489      var $currentSlick = null;
490      var slick = $('.main_visual_slick')
491        .on('init', function (e, slick) {
492          $(slick.$slides[0]).addClass('slick-visible-content');
493          $currentSlick = $(slick.$slides[0]);
494        })
495        .slick({
496          slidesToShow: 1,
497          autoplay: true,
498          fade: fade,
499          arrows: arrows,
500          dots: dots,
501          appendArrows: appendArrows,
502          autoplaySpeed: 5000,
503          speed: speed
504        })
505        .on('beforeChange', function (e, slick, currentSlide, nextSlide) {
506          $('[data-slick-index="' + nextSlide + '"]').addClass(
507            'slick-visible-content'
508          );
509          $currentSlick = $('[data-slick-index="' + currentSlide + '"]');
510          if ($('.main_visual_slick_thumb').length) {
511            $('.main_visual_slick_thumb_current').removeClass(
512              'main_visual_slick_thumb_current'
513            );
514            $('.main_visual_slick_thumb>li')
515              .eq(nextSlide)
516              .addClass('main_visual_slick_thumb_current');
517          }
518          if ($('.main_visual_copy').css('transform') !== 'none') {
519            var $copy = $('.main_visual_copy li');
520            $copy.eq(currentSlide).removeClass('active');
521            $copy.eq(nextSlide).addClass('active');
522          }
523        })
524        .on('afterChange', function (e, slick, currentSlide) {
525          $currentSlick.removeClass('slick-visible-content');
526        });
527      if ($('.main_visual_copy').css('transform') !== 'none') {
528        $('.main_visual_copy li')
529          .eq(0)
530          .addClass('active')
531          .show();
532      }
533      $('.main_visual_slick_thumb>li').on('click', function () {
534        var index = $(this).index();
535        slick.slick('slickGoTo', index);
536      });
537    })($);
538  }
539
540  if (
541    typeof skrollr !== 'undefined' &&
542    !$('body').hasClass('tablet') &&
543    !$('body').hasClass('mobile')
544  ) {
545    skrollr.init();
546  }
547
548  if (typeof objectFitImages !== 'undefined') {
549    objectFitImages('.ofi img');
550  }
551
552  // pc-only等のタグ前後に出てくる改行コードを除去
553  $(
554    'br.pc-only, br.sp-only, br.tablet-only, br.pc-hide, br.sp-hide, br.tablet-hide, sup, sub'
555  ).each(function () {
556    var $parent = $(this).parent();
557    if (!$parent.length) return true;
558    var html = $parent.html();
559    html = html
560      .replace(/\n/g, '')
561      .replace(/\s*?(<br class="(sp|pc|tablet)-(only|hide)([^>+?])>)\s*/g, '$1')
562      .replace(/(,|\.)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
563      .replace(/(\d)(<br class="(sp|pc|tablet)-(only|hide))/g, '$1 $2')
564      .replace(/\s*?<(sup|sub)/g, '<$1');
565    $parent.html(html);
566  });
567  // FromCake
568  $('.sweetswidget').each(function () {
569    var self = this;
570    var dataset = $(self).data();
571    var shopcode = dataset.widgetcode;
572    if (shopcode === undefined) return true;
573    var count = dataset.widgetcount !== undefined ? dataset.widgetcount : 50;
574    var class_name =
575      dataset.widgetcarousel && dataset.widgetcarousel !== undefined
576        ? 'reservation_widget_carousel_wrap'
577        : '';
578    var url = 'https://sweetsguide.jp/shop/' + shopcode + '/widget';
579    var ajaxOption = {
580      method: 'get',
581      url: url,
582      data: {
583        class_name: class_name,
584        count: count
585      },
586      dataType: 'html'
587    };
588    $.ajax(ajaxOption).done(function (html) {
589      getWidget(self, html);
590    });
591  });
592
593  function getWidget(self, html) {
594    $(self).after(html);
595    var current = $(self).next();
596    $(self).remove();
597    var $container = $(current);
598
599    customTile('h3', $container);
600    // Resize Event
601    var resizetimer = false;
602    $(window).resize(function () {
603      if (resizetimer !== false) {
604        clearTimeout(resizetimer);
605      }
606      resizetimer = setTimeout(function () {
607        customTile('h3', $container);
608      }, 200);
609    });
610    function customTile(selector, $container) {
611      var $selector = $(selector, $container);
612      var h, max;
613      var last = $selector.length - 1;
614      $selector
615        .each(function (i) {
616          $(this).removeAttr('style');
617        })
618        .each(function (i) {
619          h = $(this).outerHeight();
620          if (i === 0 || h > max) max = h;
621          if (i == last) {
622            $selector.each(function (i) {
623              $(this).css('height', max);
624            });
625          }
626        });
627    }
628    if (!$container.hasClass('reservation_widget_carousel_wrap')) return true;
629    var length = $('>li', $container).length;
630    if (length <= 4) {
631      $container.removeClass('reservation_widget_carousel_wrap');
632      return;
633    }
634    $container.removeClass('row_inline');
635    $('>li', $container).each(function () {
636      $(this)
637        .removeClass('span_3 col')
638        .addClass('reservation_widget_carousel');
639    });
640    $container.after('<div class="reservation_widget_arrow"></div>');
641    appendArrows = $container.next();
642    var slickOption = {
643      slidesToShow: 4,
644      autoplay: true,
645      arrows: true,
646      dots: true,
647      appendArrows: appendArrows,
648      responsive: [
649        {
650          breakpoint: 900,
651          settings: {
652            slidesToShow: 3
653          }
654        },
655        {
656          breakpoint: 768,
657          settings: {
658            slidesToShow: 2
659          }
660        }
661      ]
662    };
663    $container.slick(slickOption);
664    customTile('h3', $container);
665  }
666
667  // 遅延読み込み時のtile強制発火
668  if (typeof MutationObserver !== 'undefined') {
669    // IE10-
670    var observer = new MutationObserver(function () {
671      $(window).trigger('resize');
672    });
673
674    var config = {
675      attributes: true,
676      childList: true,
677      characterData: true
678    };
679
680    $('.tile .lazy-hidden').each(function () {
681      observer.observe(this, config);
682    });
683  }
684  
685  if($(".overflow_txt_hidden").length) {
686    $(".overflow_txt_hidden").each(function() {
687      $(this).css("-webkit-line-clamp", `${$(this).data("rows")}`);
688    })
689    $(".overflow_txt_hidden + .more a").on("click", function(e) {
690      e.preventDefault();
691      $(this).toggleClass("close");
692      switch($(this).text()){
693        case "もっと見る":
694          $(this).text("閉じる");
695          break;
696        case "閉じる":
697          $(this).text("もっと見る");
698          break;
699        default:
700          $(this).text("もっと見る");
701          break;
702      }
703      const overflowTxtHidden = $(this).parent().prev(".overflow_txt_hidden");
704      const rows = overflowTxtHidden.data("rows");
705      if(overflowTxtHidden.hasClass("open")) {
706        overflowTxtHidden.css("-webkit-line-clamp", `${rows}`);
707      } else {
708        overflowTxtHidden.removeAttr("style");
709      }
710      overflowTxtHidden.toggleClass("open");
711    })
712  }
713}
714
715//PCヘッダースクロール追従挙動
716$(function() {
717  let scrollTrigger = 300;
718  if($("body.home").length) {
719    scrollTrigger = $(window).height();
720  } else {
721    scrollTrigger = 300;
722  }
723  $(window).on("scroll" , function() {
724    const scrollTop = $(window).scrollTop();
725    if(scrollTop > scrollTrigger) {
726      $("header .global_nav").addClass("fixed_active");
727    } else {
728      $("header .global_nav").removeClass("fixed_active");
729    }
730  })
731})
732
733function loadFunc(callback) {
734  if (
735    sessionStorage.getItem('access') &&
736    wp_theme_options.loader.timming === 'once'
737  ) {
738    $('#loader').css({
739      display: 'none'
740    });
741    callback();
742  } else {
743    setTimeout(function () {
744      callback();
745      $('#loader').fadeOut(wp_theme_options.loader.fadeout);
746    }, wp_theme_options.loader.delay);
747  }
748  sessionStorage.setItem('access', wp_theme_options.loader.timming);
749}
750
751window.addEventListener('DOMContentLoaded', function () {
752  if (
753    typeof wp_theme_options !== 'undefined' &&
754    wp_theme_options.loader &&
755    wp_theme_options.loader.enable &&
756    !(wp_theme_options.loader.home_only && !wp_theme_options.is_front)
757  ) {
758    loadFunc(main);
759  } else {
760    main();
761  }
762});
763
764window.onpageshow = function (event) {
765  if (event.persisted) {
766    window.location.reload();
767  }
768}
769
770var ep_theme_options = typeof ep_theme_options !== 'undefined' ? ep_theme_options : {};
771ep_theme_options.windowEventLoaded = false;
772window.addEventListener('load', function () {
773  ep_theme_options.windowEventLoaded = true;
774});
775
776  

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.