$(function() { //関連リンク用 file_url = location.href.substring(location.href.indexOf("/",9),location.href.length); $('.related-link a').each(function() { rObj = new RegExp("^"+file_url+"$", "i"); if ($(this).attr('href').match(rObj)) $(this).parent().css('display', 'none'); }); }); function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //スマホ時フリーダイアルジャンプ if (navigator.userAgent.match(/(iPhone|Android)+[\w\d\s;,:\_\-\.\/\(\)]+(Mobile)+/)) { $(function() { $('.freedial , .tel.clearfix>p , .tel.clearfix>strong , span.tLink').each(function() { var str = $(this).html(); if(str.match(/(0[0-9]{1,4})-([0-9]{1,4})-?([0-9]{3,4})/)){ $(this).html($('').attr('href', 'tel:' + $(this).text().replace(/-/g, '')).append(str + '').addClass("telLink no-icon")); } }); }); } //////////////////////////////////////////// //SP判定(全体) //////////////////////////////////////////// $(function(){ //IE判定 var uaCheck = window.navigator.userAgent.toUpperCase(); var ieCheck = uaCheck.indexOf('MSIE') === -1 && uaCheck.indexOf('TRIDENT') === -1; var htmlElement = document.getElementsByTagName('html'); if (!ieCheck) { htmlElement[0].classList.add("is-IE"); } //従来の判定に加え、iPadの場合もドロップダウン処理は「sp」で対応。 if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/blackberry/i) || navigator.userAgent.match(/iPad/i) || (navigator.userAgent.match(/macintosh/i) && 'ontouchend' in document)) { //SP見た目の処理 //新header用の各種処理 headerDropdownBtn('sp'); headerMegamenu('sp'); } else { //PC見た目の処理 //新header用の各種処理 headerDropdownBtn('pc'); headerMegamenu('pc'); } /////////////////////////////////////////////// // 新header用関数 /////////////////////////////////////////////// //新header ログインドロップダウン function headerDropdownBtn(mode) { var target = $('.l-header__navi-item--dropdown'); var targetBtn = $('.l-header__btn--hasDropdown'); var closeBtn = $('.l-header__dropdown-close'); if(mode == 'pc') { //PC処理(IEは別処理) if (!ieCheck) { //IEの時 targetBtn.on({ "click": function(){ //メガメニューが開いてる場合は閉じる if ($('.l-header__subNavi-link--hasDropdown').hasClass('is-open')) { $('.l-header__megaMenu').hide(); $('.l-header__subNavi-link--hasDropdown').removeClass('is-open'); } $(this).next('.l-header__dropdown-wrap').toggle(); $(this).toggleClass('is-open'); }, }); closeBtn.on('click',function(){ $(this).parents('.l-header__dropdown-wrap').prev('.l-header__btn--hasDropdown').removeClass('is-open'); }); } else { //IE以外 target.on({ "mouseenter": function(){ $(this).find('.l-header__btn').next('.l-header__dropdown-wrap').slideDown(); $(this).find('.l-header__btn').addClass('is-open'); }, "mouseleave": function(){ $(this).find('.l-header__btn').next('.l-header__dropdown-wrap').hide(); $(this).find('.l-header__btn').removeClass('is-open'); } }); } closeBtn.on('click',function(){ $(this).parent('.l-header__dropdown-wrap').hide(); }); } else if(mode == 'sp') { //SP処理 target.find('.l-header__btn--hasDropdown').on({ "click": function(){ //メガメニューが開いてる場合は閉じる if ($('.l-header__subNavi-link--hasDropdown').hasClass('is-open')) { $('.l-header__megaMenu').hide(); $('.l-header__subNavi-link--hasDropdown').removeClass('is-open'); } //ログインドロップダウン処理 if ($(this).hasClass('is-open')) { $(this).next('.l-header__dropdown-wrap').hide(); $(this).removeClass('is-open'); } else { $('.l-header__dropdown-wrap').hide(); target.find('.l-header__btn--hasDropdown').removeClass('is-open'); $(this).next('.l-header__dropdown-wrap').slideDown(); $(this).addClass('is-open'); } }, }); closeBtn.on('click',function(){ $(this).parents('.l-header__dropdown-wrap').prev('.l-header__btn--hasDropdown').removeClass('is-open'); $(this).parents('.l-header__dropdown-wrap').hide(); }); } } //新headerメガメニュー function headerMegamenu(mode) { var target = $('.l-header__subNavi-item--hasDropdown'); var targetBtn = $('.l-header__subNavi-link--hasDropdown'); var closeBtn = $('.l-header__megaMenu-close'); if(mode == 'pc') { //PC処理(IEは別処理) if (!ieCheck) { //IEの時 targetBtn.on({ "click": function(e){ e.preventDefault(); if ($(this).hasClass('is-open')) { $(this).next('.l-header__megaMenu').hide(); $(this).removeClass('is-open'); } else { //ログインドロップダウンが開いている場合は閉じる if ($('.l-header__btn--hasDropdown').hasClass('is-open')) { $('.l-header__dropdown-wrap').hide(); $('.l-header__btn--hasDropdown').removeClass('is-open'); } $('.l-header__megaMenu').hide(); targetBtn.removeClass('is-open'); $(this).next('.l-header__megaMenu').show(); $(this).addClass('is-open'); } }, }); closeBtn.on('click',function(){ $(this).parents('.l-header__megaMenu').prev('.l-header__subNavi-link').removeClass('is-open'); }); } else { //IE以外 target.find('.l-header__subNavi-link--hasDropdown').on('click', function(e){ e.preventDefault(); }); target.on({ "mouseenter": function(){ $('.l-header__megaMenu').hide(); $(this).find('.l-header__subNavi-link').next('.l-header__megaMenu').slideDown(); $(this).find('.l-header__subNavi-link').addClass('is-open'); }, "mouseleave": function(){ $(this).find('.l-header__subNavi-link').next('.l-header__megaMenu').hide(); $(this).find('.l-header__subNavi-link').removeClass('is-open'); } }); } closeBtn.on('click',function(){ $(this).parents('.l-header__megaMenu').prev('.l-header__subNavi-link').removeClass('is-open'); $(this).parents('.l-header__megaMenu').hide(); }); } else if(mode == 'sp') { //SP処理 target.find('.l-header__subNavi-link--hasDropdown').on({ "click": function(e){ e.preventDefault(); //ログインドロップダウンが開いている場合は閉じる if ($('.l-header__btn--hasDropdown').hasClass('is-open')) { $('.l-header__dropdown-wrap').hide(); $('.l-header__btn--hasDropdown').removeClass('is-open'); } //メガメニュー処理 if ($(this).hasClass('is-open')) { $(this).next('.l-header__megaMenu').hide(); $(this).removeClass('is-open'); } else { //一つ開いたら他のを閉じる場合は if (!$('body').hasClass('sp')) { //レスポンシブ非対応や、スマホタブレットなどでPCの見た目を見ているとき $('.l-header__megaMenu').hide(); targetBtn.removeClass('is-open'); } $(this).next('.l-header__megaMenu').show(); $(this).addClass('is-open'); } }, }); closeBtn.on('click',function(){ $(this).parents('.l-header__megaMenu').prev('.l-header__subNavi-link').removeClass('is-open'); $(this).parents('.l-header__megaMenu').hide(); }); } } });