PageSourceSearch

https://www.sakurai-zouen.co.jp/news/wp-content/themes/sakurai_theme_ver.1.0.1/assets/scripts/index.js

js sakurai-zouen.co.jp collected 2026-10-08 02:25:58 UTC 4,556 bytes, 151 lines download raw bytes

1
2$(function () {
3  $('#logo').fadeIn();
4  $('#header').addClass('no');
5
6  //Lazy Load 画像の遅延読み込み
7  $("img.lazy").lazyload({
8    threshold: 200,
9    effect: "fadeIn",
10    effectspeed: 500
11  });
12
13  var wid = $(window).width();
14  if( wid < 768 ){
15      $('.imgChange').each(function(){
16          $(this).attr("src",$(this).attr("src").replace('_pc', '_sp'));
17      });
18  }else{
19      $('.imgChange').each(function(){
20          $(this).attr("src",$(this).attr("src").replace('_sp', '_pc'));
21      });
22  }
23
24  var timer = false;
25  $(window).resize(function() {
26      if (timer !== false) {
27          clearTimeout(timer);
28      }
29      timer = setTimeout(function() {
30          // console.log('resized');
31          var wid = $(window).width();
32          if( wid < 768 ){
33              $('.imgChange').each(function(){
34                  $(this).attr("src",$(this).attr("src").replace('_pc', '_sp'));
35              });
36          }else{
37              $('.imgChange').each(function(){
38                  $(this).attr("src",$(this).attr("src").replace('_sp', '_pc'));
39              });
40          }
41      }, 200);
42  });
43
44
45  // 言語メニューの開閉
46  const $langButton = $(".lang-nav-title");
47  $langButton.on("click", function () {
48      const isOpen = $(this).hasClass("is-open");
49      if (!isOpen) {
50          $(this).addClass("is-open");
51          $(this).next("ul").slideDown();
52      } else {
53          $(this).removeClass("is-open");
54          $(this).next("ul").slideUp();
55      }
56  });
57
58
59  // グローバルメニューの開閉
60  const $menuButton = $("#menu-button");
61  const $globalMenu = $("#global-menu");
62  let nowOffsetY = 0;
63  $menuButton.on("click", function () {
64      const isOpen = $(this).hasClass("is-open");
65      if (!isOpen) {
66          nowOffsetY = $(window).scrollTop();
67          $(this).add($globalMenu).addClass("is-open");
68          $("body")
69              .css({ top: `-${nowOffsetY}px` })
70              .addClass("is-gmenu-opened");
71      } else {
72          $(this).add($globalMenu).removeClass("is-open");
73          $langButton.removeClass("is-open");
74          $langButton.next("ul").slideUp();
75          $("body")
76              .css({ top: 0 })
77              .removeClass("is-gmenu-opened");
78          $("html, body").scrollTop(nowOffsetY);
79      }
80  });
81
82
83  // アンカーリンク
84  function AnkerLink() {
85    const anker_links = document.querySelectorAll("a[href^='#']");
86  
87    for (let i = 0; i < anker_links.length; i++) {
88      anker_links[i].addEventListener("click", function (e) {
89        if (e.preventDefault) {
90          e.preventDefault();
91        } else {
92          e.returnValue = false;
93        }
94        let href = e.target.getAttribute("href");
95  
96        if (!(href === "") || !(href === "#")) {
97          let target = document.querySelector(href);
98          let rect = target.getBoundingClientRect();
99          var x = window.pageXOffset;
100          var y = window.pageYOffset;
101          var moved = rect.top;
102          var time = 1;
103          var num = 60;
104          
105          function tick() {
106            function easing(time, y, moved, num) {
107              if ((time/=num/2) < 1) 
108                return moved/2*time*time + y;
109                return -moved/2 * ((--time)*(time-2) - 1) + y;
110            };
111            window.scrollTo(x, easing(time, y, moved, num));
112            time ++;
113            if (time <= num) {
114              requestAnimationFrame(tick);
115            }
116          }
117          tick();
118        }
119      })
120    };
121  };
122  AnkerLink();
123
124
125  // 端末判定
126  var _ua = (function(u){
127    return {
128        Tablet:(u.indexOf("windows") != -1 && u.indexOf("touch") != -1 && u.indexOf("tablet pc") == -1)
129        || u.indexOf("ipad") != -1
130        || (u.indexOf("android") != -1 && u.indexOf("mobile") == -1)
131        || (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1)
132        || u.indexOf("kindle") != -1
133        || u.indexOf("silk") != -1
134        || u.indexOf("playbook") != -1,
135        Mobile:(u.indexOf("windows") != -1 && u.indexOf("phone") != -1)
136        || u.indexOf("iphone") != -1
137        || u.indexOf("ipod") != -1
138        || (u.indexOf("android") != -1 && u.indexOf("mobile") != -1)
139        || (u.indexOf("firefox") != -1 && u.indexOf("mobile") != -1)
140        || u.indexOf("blackberry") != -1
141    }
142  })(window.navigator.userAgent.toLowerCase());
143
144  if(_ua.Mobile){
145      //この中のコードはスマホにのみ適用
146      $('.imgChange').each(function(){
147
148          $(this).attr("src",$(this).attr("src").replace('_pc', '_sp'));
149      });
150  };
151});

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.