(function ($) { /*----------------------------------------------------------*/ /* scroll /*----------------------------------------------------------*/ // Scroll function $(window).scroll(function () { var scroll = $(this).scrollTop(); if ($(this).scrollTop() > 1) { $('body').addClass('scrolled'); } else { $('body').removeClass('scrolled'); } }); /*----------------------------------------------------------*/ /* Offset header /*----------------------------------------------------------*/ $(function offset_header() { $('.tk_site-header').css({ "position": "fixed" }); var headerHeight = $('header.tk_site-header').height(); $('#main-contents').css("margin-top", headerHeight + "px"); }); /*----------------------------------------------------------*/ /* Menu-btn /*----------------------------------------------------------*/ $(function () { $('.tk_menu-btn').click(function () { $(this).toggleClass("active"); if ($(this).hasClass('active')) { $('#gmenu-sp').addClass('active'); } else { $('#gmenu-sp').removeClass('active'); } }); }); /*-------------------------------------------*/ /* scroll /*-------------------------------------------*/ $(function () { var headerHeight = $('.tk_site-header').height(); $('a[href^="#"]').click(function () { // 親要素のクラスに「」が存在しない場合のみ実行 if (!$(this).closest('ul').hasClass('nav-tabs')) { var href = $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - headerHeight; //ヘッダの高さ分位置をずらす $("html, body").animate({ scrollTop: position }, 550, "swing"); return false; } }); }); /*-------------------------------------------*/ /* ページトップ /*-------------------------------------------*/ $(function () { var showFlag = false; var topBtn = $('#btn-page-top'); topBtn.css('bottom', '-100px'); //スクロールが100に達したらボタン表示 $(window).scroll(function () { if ($(this).scrollTop() > 100) { if (showFlag == false) { showFlag = true; topBtn.stop().animate({ 'bottom': '15px' }, 200); } } else { if (showFlag) { showFlag = false; topBtn.stop().animate({ 'bottom': '-100px' }, 200); } } }); //スクロールしてトップ topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); }); // end /*-------------------------------------------*/ /* TEL /*-------------------------------------------*/ $(function () { var ua = navigator.userAgent.toLowerCase(); var isMobile = /iphone/.test(ua) || /android(.+)?mobile/.test(ua); if (!isMobile) { $('a[href^="tel:"]').on('click', function (e) { e.preventDefault(); }); } }); /*END--------------------------------------*/ })(jQuery);