// JavaScript Document
"use strict";
// スムーズスクロール
$(document).ready(function(){
$('a[href^="#"]').on('click', function(){
var speed = 400;
var href = $(this).attr('href');
var target = $(href == '#' || href == '' ? 'html' : href);
var offset = target.offset().top;
$('body,html').animate({
scrollTop:offset
}, speed, 'swing');
return false;
});
});
// トップへ戻るリンク
$(function(){
var topBtn = $('#tk_pageTop');
topBtn.hide();
$(window).scroll(function (){
if ($(this).scrollTop() > $(window).height()){
topBtn.fadeIn();
} else {
topBtn.fadeOut();
}
});
});
// アイコン設定
$(function(){
$('#tk_siteName a').empty().prepend('');
$('#tk_snsMenu [href*="facebook"]').empty().prepend('');
$('#tk_snsMenu [href*="twitter"]').empty().prepend('');
$('#tk_snsMenu [href*="instagram"]').empty().prepend('');
$('#tk_snsMenu [href*="youtube"]').empty().prepend('');
$('#tk_selectLanguage dt').append('');
$('#tk_pagePath li+li').prepend('');
$('#tk_subject .tk_subject').prepend('');
$('#tk_pageTop a').empty().prepend('');
$('#tk_fAddress').empty().prepend('');
});
//svgスプライト表示バグ対策
(function(document, window){
document.addEventListener('DOMContentLoaded', function(){
var baseUrl = window.location.href
.replace(window.location.hash, '');
[].slice.call(document.querySelectorAll('use[*|href]'))
.filter(function(element) {
return (element.getAttribute('xlink:href').indexOf('#') === 0);
})
.forEach(function(element) {
element.setAttribute('xlink:href', baseUrl + element.getAttribute('xlink:href'));
});
}, false);
}(document, window));
// グローバルナビ
$(function(){
$('#tk_selectLanguage').click(function(){
$(this).toggleClass("tk_open");
});
$('#tk_selectLanguage.tk_open dl').mouseout(function(){
$('#tk_selectLanguage').removeClass("tk_open");
});
});
// 多言語リンク
$(function(){
$('#tk_selectLanguage a').attr('target', '_blank');
$('#tk_selectLanguage [href="https://yamagatakanko.com/en/"]').attr('href', 'https://translate.google.com/translate?sl=ja&tl=en&u=https://yamagatakanko.com/');
$('#tk_selectLanguage [href="https://yamagatakanko.com/ko/"]').attr('href', 'https://translate.google.com/translate?sl=ja&tl=ko&u=https://yamagatakanko.com/');
$('#tk_selectLanguage [href="https://yamagatakanko.com/zh_TW/"]').attr('href', 'https://translate.google.com/translate?sl=ja&tl=zh-TW&u=https://yamagatakanko.com/');
$('#tk_selectLanguage [href="https://yamagatakanko.com/zh_CN/"]').attr('href', 'https://translate.google.com/translate?sl=ja&tl=zh-CN&u=https://yamagatakanko.com/');
$('#tk_selectLanguage [href="https://yamagatakanko.com/th/"]').attr('href', 'https://translate.google.com/translate?sl=ja&tl=th&u=https://yamagatakanko.com/');
});