// JavaScript Document
$(function() {
$('a[href^="#"],a[href*="#"]').not('#tabs a').on('click',function() {
var mrg = $("#f-header").outerHeight() ;
if($(window).width() < 640){ mrg = 0; }
href = $(this).attr("href");
var hrefs=href.substring(href.indexOf("#")+1,href.length);
href = "#"+hrefs;
var target = $(href == "#" || href == "" ? 'html' : href);
if(target.length){
var position = target.offset().top - mrg;
$('body,html').animate({scrollTop:position}, 500, 'swing');
return false;
}
});
/**アコーディオン開閉**/
$('#main div#contents ul.plist2 li p').stop().on('click',function (e) {
e.preventDefault();
$(this).stop().next('div.dlist').slideToggle();
});
$(document).stop().on('click','#main div#contents ul.plist2 li div.dlist .svg-inline--fa',function (e) {
e.preventDefault();
$(this).stop().parent('div.dlist').slideToggle();
});
/*
$(document).on('click','#fancybox-img',function (e) {
location.href = '../pcat3/';
});
$(document).on('click','.swiper-container.mainimg .swiper-slide',function () {
$('.swiper-slide.swiper-slide-duplicate > a').removeAttr('');
});
*/
$('#head #hmenu > div ul.menu#menu-hmenu2 li.en > a').stop().on('click',function (e) {
e.preventDefault();
$('#head #hmenu > div ul.menu#menu-hmenu2 li.en > ul').stop().slideToggle();
});
$('#head #hmenu > div ul.menu#menu-hmenu2 li.tel a').stop().on('click',function (e) {
e.preventDefault();
location.href='tel:0352872941';
});
$('#menubtn').stop().on('click',function (e) {
e.preventDefault();
$('#head #header > div ul.menu#menu-gmenu').stop().slideToggle();
$(this).toggleClass('open');
});
$('#main.product_archive #contents .contents ul.rlist li span').stop().on('click',function (e) {
e.preventDefault();
$(this).toggleClass('checked');
});
$('.entry #contents .mw_wp_form td input#facility').attr('readonly',true);
setsize();
//本アップ対応
$("a.nolink").click(function(e) {
e.preventDefault;
return false;
});
//telリンク
if(uaname != "sp"){
$(".tel a").click(function(e) {
e.preventDefault;
return false;
});
}
if($('.mwform-zip-field').length){
$('.mwform-zip-field > input:first-child').attr('id','zip');
$('.mwform-zip-field > input:last-child').attr('id','zip1');
$('.mwform-zip-field > input.postal-code2:first-child').attr('id','zip2');
$('.mwform-zip-field > input.postal-code2:last-child').attr('id','zip21');
}
if($('input.hidden').length){
$('input.hidden').attr('readonly','readonly');
}
if($('.entry #contents tr:first-child td select').length){
$('.entry #contents tr:first-child td select').attr('readonly','readonly');
}
if($('.mw_wp_form').length){
var val = $('#jobget').val();
if(val){
$('#jobset').val(val);
}
}
movepos();
/**sendtag**/
/*
$(document).on('click','#main.product_single .doc div a,#main.download #results tbody td:last-child a',function(){
const sendurl = $(this).attr('href');
let sendtitle = $(this).attr('title');
if(!sendtitle){ sendtitle = $(this).text(); }
console.log('url:'+sendurl+' title:'+sendtitle);
_cam('send', { "url": sendurl, "title": sendtitle });
});
$(document).on('click','a',function(){
const sendurl = $(this).attr('href');
const target = 'skylake.kmecsone.jp/public/file/document/download/';
if (sendurl.indexOf(target) !== -1) {
let sendtitle = $(this).attr('title');
if(!sendtitle){ sendtitle = $(this).html(); }
console.log('url:'+sendurl+' title:'+sendtitle);
_cam('send', { "url": sendurl, "title": sendtitle });
}
});
*/
});
if(navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) {
$('body').on("mousewheel", function () {
event.preventDefault();
var wd = event.wheelDelta;
var csp = window.pageYOffset;
window.scrollTo(0, csp - wd);
});
}
$(window).on('load',function(){
setsize();
setscroll();
movepos();
$('#head #header #hmenu li.search #___gcse_0 .gsc-control-cse td input[type="text"]').attr('placeholder','製品名・キーワードを入力');
});
$(window).on('resize',function () {
setsize();
//movepos();
});
$(window).on('scroll',function () {
//setsize();
setscroll();
});
$(window).on('orientationchange', function(){
setsize();
});
function setsize(){
var hsize = $("#head").outerHeight();
$("#container").css("padding-top",hsize+"px");
}
//他ページよりのアンカーリンク
function movepos(){
var mrg = $("#f-header").outerHeight() ;
var href = location.href;
if(href.indexOf("#")>=0 || location.search){
var hrefs=href.substring(href.indexOf("#")+1,href.length);
href = hrefs;
if($("#"+href).length){
var position = $("#"+href).offset().top;
var speed = 500;
$('body,html').animate({scrollTop:position-mrg}, speed, 'swing');
}
}else{
return false;
}
var hashString = location.hash.substr(1);
history.replaceState('', document.title, window.location.pathname);
}
var timeoutId ;
function setscroll(){
$(".fadeOff").each(function(){
var imgPos = $(this).offset().top;
var scroll = $(window).scrollTop();
var windowHeight = $(window).height();
var mrg = windowHeight/4;
if (scroll > imgPos - windowHeight + mrg){
$(this).addClass("fadeOn");
}
});
}