PageSourceSearch

https://otsunestone.com/wp-content/themes/sg001m/js/main.js

js otsunestone.com collected 2026-10-04 04:42:06 UTC 12,118 bytes, 487 lines download raw bytes

1
2
3// main
4
5// eslint-disable-next-line no-undef
6cssVars({
7  rootElement: document
8});
9
10// eslint-disable-next-line no-undef
11var layzr = Layzr({
12  normal: 'data-layzr',
13  threshold: 50
14});
15
16layzr.on('src:after', function (elm) {
17  if(!elm.hasAttribute('data-layzr-bg')) return;
18  elm.style.backgroundImage = 'url(' + elm.getAttribute('src') + ')';
19  elm.removeAttribute('src');
20  elm.removeAttribute('data-layzr-bg');
21});
22
23document.addEventListener('DOMContentLoaded', function() {
24    layzr.update().check().handlers(true)
25}, false);
26
27var userAgent = window.navigator.userAgent.toLowerCase();
28var is_ie = (userAgent.indexOf('msie') != -1 || userAgent.indexOf('trident') != -1) ? true : false;
29
30// eslint-disable-next-line no-undef
31Swiper.prototype.getBreakpoint = function (breakpoints) {
32
33  var window_size = window.innerWidth
34  || document.documentElement.clientWidth
35  || document.body.clientWidth;
36
37  var swiper = this;
38  // Get breakpoint for window width
39  if (!breakpoints) {
40      return undefined;
41  }
42  var breakpoint = false;
43  var points = [];
44  Object.keys(breakpoints).forEach(function (point) {
45      points.push(point);
46  });
47  points.sort(function (a, b) {
48      return parseInt(a, 10) - parseInt(b, 10);
49  });
50  for (var i = 0; i < points.length; i += 1) {
51      var point = points[i];
52      if (swiper.params.breakpointsInverse) {
53          if (point <= window_size) {
54              breakpoint = point;
55          }
56      } else if (point >= window_size && !breakpoint) {
57          breakpoint = point;
58      }
59  }
60  return breakpoint || 'max';
61};
62
63// accordion
64
65$('.js-accordion-btn').on('click tap', function(e) {
66  $(this).next('.js-accordion-target').slideToggle();
67  $(this).parent().toggleClass('is-open');
68});
69
70
71// js menu open
72
73var scrollpos;
74
75$('.js-menu-toggle, .p-spnav-item-link').on('click tap', function() {
76  var status = $('body').attr('data-menu');
77  if( status == 'active' ) {
78    $('body').attr('data-menu', '');
79    $('body').attr('data-bodyfixed', 'false').css({'top': 0});
80    window.scrollTo( 0 , scrollpos );
81  } else {
82    scrollpos = $(window).scrollTop();
83    $('body').attr('data-menu', 'active');
84    $('body').attr('data-bodyfixed', 'true').css({'top': -scrollpos});
85  }
86});
87
88$('.c-pagetop-btn').on('click tap', function() {
89  $('body, html').animate({
90    scrollTop: 0
91  }, 300, 'swing');
92});
93
94// datepicker
95//
96// $(function() {
97//   var headerHeight = $('header').height();
98//   $('.datepicker').click(function(){
99//     $('#ui-datepicker-div').css({
100//       'margin-top': -headerHeight + 'px'
101//     });
102//   });
103// });
104
105$(window).on('load scroll', function() {
106  var h = $(window).height();
107  var w = $(window).width();
108  var scrollTop = $(window).scrollTop();
109  var btm;
110
111  // header bg color
112
113  if( $('.l-header')[0] ) {
114    if (scrollTop > h / 2) {
115      $('.l-header').addClass('is-bgcolor');
116    }
117    else {
118      $('.l-header').removeClass('is-bgcolor');
119    }
120  }
121
122  // pagetop
123
124  if( $('.js-pagetop')[0] ) {
125    if (scrollTop > h / 2) {
126      $('.js-pagetop').addClass('is-active');
127
128    }
129    else {
130      $('.js-pagetop').removeClass('is-active');
131
132    }
133  }
134
135  // pagetop フッターより上の任意の場所で固定する時
136  //
137  // if(w < 768) {
138  //   btm = 5;
139  // }
140  // else {
141  //   btm = 15;
142  // }
143
144  // var docsHeight = $(document).height();
145  // var scrollPosition = h + scrollTop;
146  // var footHeight = $('.p-global-footer').innerHeight();
147
148  // if ( docsHeight - scrollPosition <= footHeight ) {
149  //   $('.js-pagetop').css({
150  //     'position': 'absolute',
151  //     'bottom': footHeight + btm
152  //   });
153  //   $('.js-pagetop').removeClass('is-fix');
154
155  // } else {
156  //   $('.js-pagetop').css({
157  //     'position': 'fixed',
158  //     'bottom' : btm
159  //   });
160  //   $('.js-pagetop').addClass('is-fix');
161  // }
162
163});
164
165/**
166 * アンカースクロール
167 */
168
169$('a:not([href^="tel:"]):not([target])').on('click', function(e) {
170  var url = $(this).attr('href');
171
172  if(url == '#') {
173    return false;
174  }
175
176  if( url.indexOf('#') != -1 ) {
177    var speed = 300;
178    var href= url.match(/#.*$/);
179    var target = $(href[0]);
180    var position = target.offset().top - $('.js-header').outerHeight();
181    // var position = target.offset().top;
182    $('body, html').animate({ scrollTop: position }, speed, 'swing');
183    location.hash = href[0];
184    return false;
185  }
186});
187
188
189/**
190 * サイドナビ アンカー先の要素が表示領域内の時にアクティブにする
191 */
192$(window).on('scroll', function() {
193  $('.js-gnav-link').each(function() {
194    let url = $(this).attr('href');
195    var header = $('.js-header').outerHeight();
196
197    if( url.indexOf('#') != -1 ) {
198      let hash = url.match(/#.*$/);
199      if($(hash[0])[0]) {
200        if ( $(window).scrollTop() + header + 1 > $(hash[0]).offset().top && $(window).scrollTop() + header + 1 < $(hash[0]).offset().top + $(hash[0]).outerHeight() ) {
201          $(this).addClass('is-active');
202        }
203        else {
204          $(this).removeClass('is-active');
205        }
206      }
207    }
208  });
209});
210
211$(document).ready(function() {
212
213  /**
214   * アンカースクロール
215   */
216
217  var hHeight = $('header').outerHeight();
218  var urlHash = location.hash;
219  var speed = 500;
220
221  if(urlHash) {
222    $('body,html').stop().scrollTop(0);
223    setTimeout(function () {
224      var target = $(urlHash);
225      var position = target.offset().top - hHeight;
226      $('body,html').stop().animate({scrollTop:position}, speed, 'swing');
227    }, 1000);
228  }
229
230  $('a[href]').click(function(e) {
231    var anchor = $(this),
232    href = anchor.attr('href'),
233    pagename = window.location.href;
234
235    if(href.match(/#.*/) && $('body').attr('data-menu') == 'active'){
236      $('body').attr('data-menu', '');
237      $('body').css({'overflow':'visible','height':'auto','top':'0'});
238    }
239
240    pagename = pagename.replace(/#.*/,'');
241
242    href = href.replace( pagename , '' );
243
244    if( href.search(/^#/) >= 0 ){
245      e.preventDefault();
246      console.log(3);
247      // eslint-disable-next-line quotes
248      var target = $(href == "#" || href == "" ? 'html' : href);
249      var position = target.offset().top - hHeight;
250      $('html, body').animate({scrollTop:position}, speed, 'swing');
251
252      location.hash = href;
253
254      return false;
255    }
256  })
257
258
259  /**
260   * Twitter fontsize
261   */
262  // eslint-disable-next-line no-undef
263  twttr.events.bind(
264    'loaded',
265    function (event) {
266      event.widgets.forEach(function (widget) {
267        $(widget).contents().find('head').append('<style>.timeline-Header-title {font-size:14px !important;}</style>')
268      });
269    }
270  );
271
272});
273
274
275$(window).on('load', function() {
276
277  loadContents();
278});
279
280function is_mobile() {
281  if (
282    (navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) ||
283    navigator.userAgent.indexOf('iPod') > 0 ||
284    navigator.userAgent.indexOf('Android') > 0
285  ) {
286    return true;
287  }
288  else {
289    return false;
290  }
291}
292
293function getParam(name, url) {
294  if (!url) url = window.location.href;
295  name = name.replace(/[[]]/g, '\\$&');
296  var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
297      results = regex.exec(url);
298  if (!results) return null;
299  if (!results[2]) return '';
300  return decodeURIComponent(results[2].replace(/\+/g, ' '));
301}
302
303function loadContents() {
304
305  var content_show_timeout = ( location.hash && $(location.hash)[0] ) ? 300 : 500;
306  var animate_start_timeout = ( location.hash && $(location.hash)[0] ) ? 300 : 200;
307
308  setTimeout(function() {
309
310    $('body').attr('data-status', 'loaded');
311
312  }, content_show_timeout);
313
314  setTimeout(function() {
315
316    var timer = false;
317    $(window).on('scroll', function () {
318
319      eachAnimate();
320
321      if( timer !== false ){
322        clearTimeout( timer );
323      }
324
325      timer = setTimeout( function() {
326        eachAnimate();
327      }, 400 );
328
329    });
330
331    eachAnimate();
332    setTimeout( function() {
333      eachAnimate();
334    }, 400 );
335
336    var w = $(window).width();
337
338    if( $('.js-main-visual-slide01')[0] && $('.p-main-visual-slide-item.swiper-slide').length > 1) {
339
340      // eslint-disable-next-line no-undef
341      var mainVisualSwiper01 = new Swiper('.js-main-visual-slide01.swiper-container', {
342        effect: 'fade',
343        fadeEffect: {
344          crossFade: true,
345        },
346        loop: true,
347        slidesPerView: 1,
348        speed: 2000,
349        autoplay: {
350          delay: 5000,
351        }
352      });
353    }
354
355    if( $('.js-main-visual-slide02')[0] && $('.p-main-visual-slide-item.swiper-slide').length > 1) {
356
357      // eslint-disable-next-line no-undef
358      var mainVisualSwiper02 = new Swiper('.js-main-visual-slide02.swiper-container', {
359        effect: 'fade',
360        fadeEffect: {
361          crossFade: true,
362        },
363        loop: true,
364        slidesPerView: 1,
365        speed: 2000,
366        autoplay: {
367          delay: 5000,
368        }
369      });
370    }
371
372
373    if( $('.js-index-about-slide')[0] && $('.p-index-about01-slide-item.swiper-slide').length > 1) {
374      // for( var $i = 1 ; $i <=  $('.js-index-about-slide').length ; $i++ ) {
375
376        // eslint-disable-next-line no-undef
377        var aboutSwiper = new Swiper('.js-index-about-slide.swiper-container', {
378        // new Swiper('.js-index-about-slide-' + $i, {
379          effect: 'fade',
380          fadeEffect: {
381            crossFade: true,
382          },
383          loop: true,
384          slidesPerView: 1,
385          spaceBetween: 0,
386          speed: 500,
387          autoplay: {
388            delay: 5000,
389          },
390          navigation: {
391            nextEl: '.js-slider-btn .c-arrow-btn.-next',
392            prevEl: '.js-slider-btn .c-arrow-btn.-prev',
393
394            // nextEl: '.js-slider-btn-' + $i + ' .c-arrow-btn.-next',
395            // prevEl: '.js-slider-btn-' + $i + ' .c-arrow-btn.-prev',
396
397          }
398        });
399      // }
400    }
401
402    // afterLoadFile('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@600;700&family=Noto+Sans+JP:wght@100;300;400;500&display=swap', 'css');
403    afterLoadFile('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@600;700&display=swap', 'css');
404    afterLoadFile('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&display=swap&subset=japanese', 'css');
405    afterLoadFile('https://use.fontawesome.com/releases/v5.15.4/css/all.css', 'css');
406  }, animate_start_timeout);
407
408  /*
409  if( $('.js-work-mobile-select')[0] ) {
410    $('.js-work-mobile-select').on('change', function() {
411
412      var url = $(this).find('option:selected').data('url');
413      if (url !== '') {
414        // $('body').attr('data-status', 'loadstart');
415        setTimeout(function() {
416          window.location = url;
417        }, 400);
418      }
419
420    });
421  }
422  */
423}
424
425function eachAnimate() {
426  $('.js-animate').each(function () {
427    var pos = $(this).offset().top;
428    var h = $(window).height();
429    var offset = ($(this).data('offset')) ? $(this).data('offset') : 200;
430    var scrollTop = $(window).scrollTop() + offset;
431    if (scrollTop > pos - h / 1.5) {
432      $(this).addClass('is-active');
433      $(this).removeClass('js-animate');
434    }
435  });
436}
437
438function afterLoadFile(src, type) {
439
440  if( type == 'js' ) {
441    $('body').append('<script src="'+src+'"></script>');
442  }
443
444  else if( type == 'css' ) {
445    $('body').append('<link rel="stylesheet" href="'+src+'">');
446  }
447
448  else {
449    return false;
450  }
451}
452
453// $(function() {
454//   // 2プログレスバーを生成
455//   $('#loading').progressbar({
456//     value: 37,
457//     max: 150
458//   });
459// });
460
461if(navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) {
462  $('body').on('mousewheel', function () {
463    event.preventDefault();
464    var wd = event.wheelDelta;
465    var csp = window.pageYOffset;
466    window.scrollTo(0, csp - wd);
467  });
468}
469
470/**
471 * コンタクトフォームの要素制御
472 */
473
474// 入力画面
475if( $('.mw_wp_form_input')[0] ) {
476  $('.js-confirm-item, .js-complete-item').remove();
477}
478
479// 確認画面
480if( $('.mw_wp_form_confirm')[0] ) {
481  $('.js-input-item, .js-complete-item').remove();
482}
483
484// 完了・エラー
485if( $('.mw_wp_form_complete, .mw_wp_form_send_error')[0] ) {
486  $('.js-input-item, .js-confirm-item').remove();
487}

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.