// ------------------ responsible config
document.addEventListener("DOMContentLoaded", function() {
const mql = window.matchMedia("screen and (max-width: 767px)");
function checkBreakPoint(mql) {
if (mql.matches) {
var spNav = function() {
$("body").toggleClass("is-open");
};
$('header nav p, a[href="#spec"]').off("click");
$('header nav p, a[href="#spec"]').on("click", spNav);
$('header nav p, a[href="#sample-present"]').off("click");
$('header nav p, a[href="#sample-present"]').on("click", spNav);
$("a[data-fancybox]").off("click");
$('body').append('');
} else {
$("body").removeClass("is-open");
$('div.layer').remove();
$('a[data-fancybox]').on("click", function() {
return false;
});
var ua = navigator.userAgent;
if ((ua.indexOf("iPad") > 0 || (ua.indexOf("Android") > 0 && !ua.indexOf("Mobile") > 0))) {
var orientation = window.matchMedia("(orientation:portrait)");
var zoomPoint = 980;
function orientationChange(orientation) {
if( orientation.matches ) {
$('meta[name="viewport"]').attr("content", "width=" + zoomPoint);
} else {
$('meta[name="viewport"]').attr("content", "width=device-width");
}
}
orientation.addListener(orientationChange);
orientationChange(orientation);
}
}
$(".imgChange").each(function(){
var img = mql.matches ? $(this).attr('src').replace("_pc","_sp") : $(this).attr('src').replace("_sp","_pc") ;
$(this).attr('src', img);
});
}
mql.addListener(checkBreakPoint);
checkBreakPoint(mql);
});
// ------------------ link class and blank
$(function(){
$("a[href^='http']").not('[href*="'+location.hostname+'"]').attr("target","_blank");
$("main a[href^='http']").not('[href*="'+location.hostname+'"]').addClass("blank");
$("main a[href$='zip']").addClass("zip");
$("main a[href$='pdf']").attr("target","_blank").addClass("pdf");
// ------------------ Scroller
$('a[href^="#"]').on("click", function(){
var toplink = "#top";
var href= $(this).attr("href");
var target = $(href == toplink || href == "#" || href == "" ? "html" : href);
var position = target.offset().top;
$("html, body").animate({scrollTop:position}, 500, "swing");
target.focus();
if (target.is(":focus")){
return false;
} else {
target.attr('tabindex','-1');
target.focus();
};
return false;
});
// ------------------ tel cancel
var ua = navigator.userAgent.toLowerCase();
var isMobile = /iphone/.test(ua)||/android(.+)?mobile/.test(ua);
if (!isMobile) {
$('a[href^="tel:"]').on('click', function(e) {
e.preventDefault();
});
}
// ------------------ for IE
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);
});
}
// ------------------ Page top button
var topBtn = $("#pageTop");
var wH = $(window).innerHeight();
$(window).on("scroll",function(){
if ($(this).scrollTop() > wH) {
topBtn.fadeIn();
} else {
topBtn.stop().fadeOut();
}
});
});
/* -----------------------------------
csvLoding
------------------------------------ */
$(function csvLoding() {
var csvList;
var insert = '';
$.ajax({
url: './csv/news.csv',
success: function(data) {
// csv繧帝�蛻励↓譬シ邏�
csvList = $.csv()(data);
// 謖ソ蜈・縺吶kHTML繧剃ス懈�
for (var i = 1; i < 5; i++) {
insert += '';
insert += '- ' + csvList[i][0] + '
';
insert += '- ';
if(csvList[i][2]) {
insert += '';
insert += csvList[i][1] + '';
} else {
insert += csvList[i][1];
}
insert += '
';
insert += '
';
};
$('.l-news_topicks').append(insert);
}
});
});