$(function() {
if (navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)) {
$(function() {
$('.tellink').each(function() {
var str = $(this).html();
if ($(this).children().is('img')) {
$(this).html($('').attr('href', 'tel:' + $(this).children().attr('alt').replace(/-/g, '')).append(str + ''));
} else {
$(this).html($('').attr('href', 'tel:' + $(this).text().replace(/-/g, '')).append(str + ''));
}
});
});
}
// 1回のタップでリンクが開けない問題への対応
var $w = $(window), $target = $('a');
$target.on('touchstart', function(){
var $this = $(this), isScrolling = false;
$w.on('scroll', function(){
isScrolling = true;
});
$this.on('touchend', function(){
if(!isScrolling){
var url = $this.find('a').attr('href');
if(url){
window.location.href = url;
}
}
isScrolling = false;
$this.off('touchend');
});
});
// スマホのhover処理
$('a, input[type="button"], input[type="submit"], button, .touch-hover')
.on('touchstart', function(){
$(this).addClass('hover');
}).on('touchend', function(){
$(this).removeClass('hover');
});
$(function() {
var $elem = $('.js-image-switch');
var sp = '_sp.';
var pc = '_pc.';
var replaceWidth = 767;
function imageSwitch() {
var windowWidth = parseInt($(window).width());
$elem.each(function() {
var $this = $(this);
if(windowWidth >= replaceWidth) {
$this.attr('src', $this.attr('src').replace(sp, pc));
} else {
$this.attr('src', $this.attr('src').replace(pc, sp));
}
});
}
imageSwitch();
var resizeTimer;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
imageSwitch();
}, 200);
});
});
// inview
$('.anime').on('inview', function(event, isInView, visiblePartX, visiblePartY) {
if(isInView){
$(this).stop().addClass('on');
}
// else{
// $(this).stop().removeClass('on');
// }
});
// header fix
var headerFix = $('.header');
//スクロールが100に達したらボタン表示
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
headerFix.addClass('fixed');
} else {
headerFix.removeClass('fixed');
}
});
// pagetop
var topBtn = $('.pagetop');
topBtn.hide();
//スクロールが100に達したらボタン表示
$(window).scroll(function () {
if ($(this).scrollTop() > 400) {
topBtn.fadeIn();
} else {
topBtn.fadeOut();
}
});
//スクロールしてトップ
topBtn.on('click' ,function () {
$('body,html').animate({
scrollTop: 0
}, 400);
return false;
});
// mobile-btn
$("#mobile-menu").on('click' ,function() {
$('.header').toggleClass('open');
});
$(".main-nav a").on('click' ,function() {
$('.header').removeClass('open');
});
$('.mv-slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 4000,
infinite: true,
arrows: false,
});
$('.service-list').slick({
slidesToShow: 4,
slidesToScroll: 1,
// autoplay: true,
autoplaySpeed: 2000,
infinite: true,
responsive: [
{
breakpoint: 767,
settings: {
slidesToShow: 1
}
}
]
});
$('.ranking-sub-icon').matchHeight();
});