/* カスタマイズ用のJavaScriptコードをここに記述してください */
//ブラウザの戻るボタンを禁止
history.pushState(null, null, null);
$(window).on("popstate", function (event) {
if (!event.originalEvent.state) {
history.pushState(null, null, null);
return;
}
});
//ダブルタップ防止
var nmapSlide;
$(function(){
//送信ボタンを押した際に送信ボタンを無効化する(連打による多数送信回避)
$('form').submit(function() {
$(this).submit(function () {
event.preventDefault();
});
});
//リンクを押した際に送信ボタンを無効化する(連打による多数送信回避)
$('a').click(function() {
$(this).click(function () {
event.preventDefault();
});
});
// フリーワード入力での地図使用不可
$(".input-search input.form-text-01").focus(function(){
$('.map-overlay').show();
}).blur(function(){
$('.map-overlay').hide();
});
// 店舗リストスライド
var slideClickFlg = true; //ダブルタップ防止
$('#slide-control-open').on('click', function(){
if(slideClickFlg){
slideClickFlg = false;
nmapSlide = true;
$('.nmap-content-wrap').slideUp(400, function(){
nmapSlide = false
});
//$('.nmap-content-wrap').slideUp();
$('.near-list-wrap').slideDown();
$('.gps-btn').css('display', 'none');
slideClickFlg = true;
}
});
$('#slide-control-close').on('click', function(){
if(slideClickFlg){
slideClickFlg = false;
$('.nmap-content-wrap').slideDown();
$('.near-list-wrap').hide();
setTimeout(function(){
$('.gps-btn').css('display', 'block');
$('html,body').animate({ scrollTop: 0 }, '1');
},400);
slideClickFlg = true;
}
});
$(".store-history-detail").hide();
//地図の高さを設定
var winH = $(window).innerHeight();
var headerH = $('header').outerHeight();
var navH = $('nav.nav-progress').outerHeight();
var backbarH = $('.hdg-level1-01').outerHeight();
var mapH = winH - (headerH + navH + backbarH);
if(mapH > 500){
$('#ZdcEmapMap').css('height', mapH+'px');
} else {
$('#ZdcEmapMap').css('height', '500px');
}
// Event close dialog error when click OK button
$('#btn_close_popup').on('click', function(){
$('#popup_error_transition').hide();
});
// hide overlay
$('.overlay-screen').hide();
});
function getPositionAtCenter(element) {
const {top, left, width, height} = element.getBoundingClientRect();
return {
x: left + width / 2,
y: top + height / 2
};
}
function getDistanceBetweenElements(a, b) {
const aPosition = getPositionAtCenter(a);
const bPosition = getPositionAtCenter(b);
return Math.hypot(aPosition.x - bPosition.x, aPosition.y - bPosition.y);
}