/*============================
class='tel'の箇所はスマホ環境で
電話リンクを含んだaタグが追加される
============================*/
if (navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)) {
$('.tel').each(function() {
var str = $(this).html();
if ($(this).children().is('img')) {
$(this).html($('').attr('href', 'tel:' + $(this).children().attr('alt').replace(/-/g, '')).append(str + '')); //画像のALTがtel:に挿入される
} else {
$(this).html($('').attr('href', 'tel:' + $(this).text().replace(/-/g, '')).append(str + ''));
}
});
}
/*============================
スムーズスクロール
ページ内リンク(#から始まるリンク)に対して発動
============================*/
$('a[href^="#"]').not('.-modal').on('click', function() {
var speed = 500;
var href = $(this).attr('href');
var target = $(href == '#' || href == '' ? 'html' : href);
var position = target.offset().top;
$('html, body').animate({
scrollTop: position
}, speed, 'swing');
return false;
});
/*============================
アニメーション
■data-trigger='single'
■data-trigger='group'
============================*/
document.addEventListener('DOMContentLoaded', function() {
var singles = document.querySelectorAll('[data-trigger="single"]');
var singlesArray = Array.prototype.slice.call(singles, 0);
var groups = document.querySelectorAll('[data-trigger="group"]');
var groupsArray = Array.prototype.slice.call(groups, 0);
var options = {
root: null,
rootMargin: '0px 50%',
threshold: 0,
};
var observerS = new IntersectionObserver(doWhenIntersectS, options);
var observerG = new IntersectionObserver(doWhenIntersectG, options);
singlesArray.forEach(function (single) {
observerS.observe(single);
});
groupsArray.forEach(function (group) {
observerG.observe(group);
});
function doWhenIntersectS(entries) {
var entriesArray = Array.prototype.slice.call(entries, 0);
entriesArray.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('is-animated');
}
});
}
function doWhenIntersectG(entries) {
var entriesArray = Array.prototype.slice.call(entries, 0);
entriesArray.forEach(function (entry) {
var children = entry.target.children;
if (entry.isIntersecting) {
Array.prototype.slice.call(children, 0).forEach(function (child) {
child.classList.add('is-animated');
});
}
});
}
});
$(window).on('load', function() {
$('[data-trigger="single"]').each(function() {
var elemPos = $(this).offset().top;
var scroll = $(window).scrollTop();
var windowHeight = $(window).height();
if (scroll > elemPos - windowHeight + 65) {
$(this).addClass('is-animated');
}
});
$('[data-trigger="group"]').each(function() {
var elemPos = $(this).offset().top;
var scroll = $(window).scrollTop();
var windowHeight = $(window).height();
if (scroll > elemPos - windowHeight + 65) {
$(this).children().addClass('is-animated');
}
});
});
//同意チェックボックスと送信ボタンの連動
function change() {
var element;
if(document.getElementById('privacy').checked) {
element = document.getElementById('submit');
element.disabled = false;
element.classList.remove('btn--disabled');
} else {
element = document.getElementById('submit');
element.disabled = true;
element.classList.add('btn--disabled');
}
}
//決済画面ローディングアニメーション
$('#settlement').on('click', function() {
$('#loading').show();
});
$('#information-slider').slick({
autoplay: false,
autoplaySpeed: 2000,
dots: true,
speed: 1000,
fade: true
});
$('#information-slider .slick-prev').prependTo('#information-slider .slick-dots');
$('#information-slider .slick-next').appendTo('#information-slider .slick-dots');
$('.license__list ul').addClass('notes');
$('.license__list li').addClass('notes__list');