// 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_thumb').each(function(){ var classImg = $(this).attr('class'); var srcImg = $(this).attr('src'); var userAgent = window.navigator.userAgent.toLowerCase(); if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('trident') >= 0) { $(this).wrap('
'); $(this).css('opacity','0'); $(this).removeClass(); } else { $(this).wrap('
'); $(this).removeClass(); } }); }); // アイコン設定 $(function(){ $('#tk_selectLanguage dt').append(''); $('#tk_nFavorite a').append(''); $('#tk_pagePath li+li').prepend(''); $('#tk_fNavS li a').append(''); $('#tk_pageTop a').empty().append(''); }); //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)); // スクロール検知 jQuery(document).ready(function(){ $('body').addClass('tk_scrollTop'); }); $(function(){ if( $(window).scrollTop() > 0){ $('body').removeClass('tk_scrollTop'); } }); $(window).scroll(function(){ if( $(window).scrollTop() > 0){ $('body').removeClass('tk_scrollTop'); } else { $('body').addClass('tk_scrollTop'); } }); $(function(){ var timeoutId; window.addEventListener('scroll',function(){ $('body').addClass('tk_scroll'); clearTimeout(timeoutId); timeoutId = setTimeout(function(){ $('body').removeClass('tk_scroll'); },100); }); }); // 言語選択 $(function(){ $('#tk_selectLanguage dt').click(function(){ $('#tk_selectLanguage dd').slideUp(); $(this).removeClass("tk_open"); if($('#tk_selectLanguage dd').css('display') == 'none'){ $('#tk_selectLanguage dd').slideDown(); $(this).addClass("tk_open"); } }); }); $(window).scroll(function(){ if( $(window).scrollTop() > 0){ $('#tk_selectLanguage dd').slideUp(); $(this).removeClass("tk_open"); } });