PageSourceSearch

http://iwashita-shika.com/user/theme/iwashita_dc/media/js/common.js

js iwashita-shika.com collected 2026-10-06 08:16:17 UTC 3,205 bytes, 115 lines download raw bytes

1var PC_FIXED = false;
2var SP_FIXED = false;
3var SP_WIDTH = 769;
4var SPEED = 500;
5
6var TEL = '0000000000';
7
8var UA = navigator.userAgent.toLowerCase();
9// iPhone
10var isiPhone = (UA.indexOf('iphone') > -1);
11// Android
12var isAndroid = (UA.indexOf('android') > -1) && (UA.indexOf('mobile') > -1);
13
14function scrollPosition(position) {
15    position -= PC_FIXED && $(window).innerWidth() >= SP_WIDTH || SP_FIXED && $(window).innerWidth() < SP_WIDTH ? $('header').innerHeight() : 0;
16  $('html, body').animate({
17    scrollTop: position
18  }, SPEED);
19}
20
21//(<a href="#top">の様に記述すると滑らかにスクロールする。)
22$(function () {
23  $('a[href^="#"]').click(function () {
24    var position = $(this.hash).length > 0 ? $(this.hash).offset().top : 0;
25    scrollPosition(position);
26    return false;
27  });
28});
29
30// 一定量スクロールするとページトップに戻るが表示される(場所等の指定はcommon.scssにて)
31$(function () {
32  var top_btn = $('.pagetop');
33  top_btn.hide();
34  $(window).scroll(function () {
35    $(this).scrollTop() > 100 ? top_btn.fadeIn() : top_btn.fadeOut();
36  });
37
38  top_btn.click(function () {
39    scrollPosition(0);
40    return false;
41  });
42});
43
44// rollover(_offと末尾についた画像をオンマウスで_onとついた画像に切り替える)
45$(function () {
46  $('img').hover(
47    function () {
48      $(this).attr('src', $(this).attr('src').replace('_off.', '_on.'));
49    },
50    function () {
51      $(this).attr('src', $(this).attr('src').replace('_on.', '_off.'));
52    }
53  );
54});
55
56//スマートフォン時のみ電話発信できる様にする(imgタグ用、imgタグに任意のclassを指定する。)
57$(function () {
58  var device = navigator.userAgent;
59  if (isiPhone || isAndroid) {
60    $(".tel").wrap('<a href="tel:'+TEL+'"></a>');
61  }
62});
63
64$(function () {
65  var menu_btn = $('.slidemenu-btn');
66  var body = $(document.body);
67  var top = 0;
68  var menu_open = false;
69
70  menu_btn.on('click', function () {
71    console.log($(window).scrollTop());
72    if (!menu_open) {
73      top = $(window).scrollTop();
74    }
75    console.log(top);
76    body.toggleClass('open');
77    menu_btn.toggleClass('active');
78    menu_open = true;
79    if (body.hasClass('open')) {
80      body.css({
81        'height': window.innerHeight,
82        'top': -top
83      });
84    } else {
85      body.removeAttr('style');
86      $(window).scrollTop(top);
87      menu_open = false;
88    }
89  });
90});
91
92//ヘッダーが固定の時スマホの時のページ内リンク用
93$(function () {
94  $(document).on('ready', function() {
95    if (location.hash != "") {
96	  var pos = $(location.hash).offset().top;
97	  if (PC_FIXED && $(window).innerWidth() >= SP_WIDTH || SP_FIXED && $(window).innerWidth() < SP_WIDTH) {
98		pos -= $('header').innerHeight();  
99	  }
100      $("html, body").animate({ scrollTop: pos }, 1, "swing");
101    }
102  });
103});
104//クリックで画像変更
105$(function () {
106  $('.slidemenu-btn').click(function () {
107    var img = $(this).children('img');
108    if ($(this).hasClass('active')) {
109      $(img).attr('src', $(img).attr('src').replace('menu', 'close'));
110    }
111    else {
112      $(img).attr('src', $(img).attr('src').replace('close', 'menu'));
113    }
114  });
115});

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.