var isSP = false; var isIE = false; var ieVersion = null; var isOldIE = false; var isTablet = false; //IE判定 if( navigator.userAgent.toLowerCase().match(/msie/) || navigator.userAgent.toLowerCase().match(/trident/) ) { isIE = true; ieVersion = navigator.userAgent.toLowerCase().match(/(msie\s|rv:)([\d\.]+)/)[2]; } //SP判定 if( ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/Android(.+)?Mobile/i) || navigator.userAgent.match(/BlackBerry/i))) { isSP = true; } //タブレット判定 if( ( navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/Android((?!Mobile).)+$/i))) { isTablet = true; } //ナビゲーション設定 var navApp = navApp || {}; navApp.nowWatch = 0; navApp.breakPoint = 768; navApp.menu = null; navApp.scrollBox = null; navApp.isFloat = false; navApp.navTimer = null; navApp.element = null; navApp.current_scrollY = 0; navApp.current_scrollY2 = 0; navApp.current_scrollY3 = 0; navApp.current_scrollY4 = 0; navApp.current_float = false; navApp.init = function(){ var self = this; var srcTxt = ""; var closeBtn = ""; this.nowWatch = 0; this.root = ""; // /からのパスが使えないためルート階層への相対パスを作成 var $dir = location.pathname.split("/"); if($(".header-middle h2 .main-title").length > 0){ this.root = $(".header-middle h2 .main-title").eq(0).attr("src").replace("common/images/main_title.png",""); }else{ for(var i=0; i<$dir.length -2; i++){ this.root += "../"; } } //ラッパーを追加 $("#site-header").after('
'); $("#main").appendTo($(".content_wrapper").eq(0)); $(".bottom-document-request").eq(0).appendTo($(".content_wrapper").eq(0)); $(".bottom-document-news").eq(0).appendTo($(".content_wrapper").eq(0)); $("#site-footer").appendTo($(".content_wrapper").eq(0)); //SPのよくある質問をリンク設定 var tmpLink = "よくあるご質問"; $("#site-header #sp-large-menu .nav-title-faq").html(tmpLink); //SPのメニュー下の電話番号をnav の末尾に移動 $("#site-header #sp-large-menu .sp-nav-bottom").eq(0).appendTo($("#site-header #sp-large-menu nav").eq(0)); // console.log($("#site-header #sp-large-menu nav").get(0).scrollHeight , $("#site-header #sp-large-menu .sp-nav-bottom").get(0).scrollHeight) //ラージメニューに閉じるボタン追加 closeBtn = ""; $(".large-menu__container").append(closeBtn); $('.close_btn').hover(function() { $(this).animate({ 'opacity': '0.5' },100); },function(){ $(this).animate({ 'opacity': '1' },100); }); $(".large-menu__container").find(".close_btn").click(function(){ self.hideMenu($("#header-bottom nav li").eq(this.nowWatch)); }) //PC ロールオーバー設定 $("#header-bottom nav li").hover(function(){ self.nowWatch = $("#header-bottom nav li").index(this); $(this).addClass("over"); //if(self.nowWatch < $("#header-bottom nav li").length - 1){ //インジケータ出る srcTxt = self.root + "common/images/img_nav_current" + self.nowWatch + ".png"; //メニュー出る if($(this).find(".large-menu").length > 0){ //ラージメニューを持っていたら //最初に普通のインジケータ $("#nav-bottom__indicator").attr({"src":srcTxt}); $("#nav-bottom").css({"left":$("#header-bottom nav li").eq(self.nowWatch).offset().left,"width":$("#header-bottom nav li").eq(self.nowWatch).width()}); $("#nav-bottom").stop().slideDown(100); clearTimeout(this.navTimer); this.element = $(this); this.navTimer = setTimeout( function(scope, $elem,preNum) { scope.showMenu($elem,preNum); }, 650, self, $(this), self.nowWatch); }else{ //そうでないもの $("#nav-bottom__indicator").attr({"src":srcTxt}); $("#nav-bottom").css({"left":$("#header-bottom nav li").eq(self.nowWatch).offset().left,"width":$("#header-bottom nav li").eq(self.nowWatch).width()}); $("#nav-bottom").stop().slideDown(100); } //} },function(){ self.hideMenu($(this)); }); //PC カレント表示設定 $("#header-bottom nav li").each(function(){ if($(this).hasClass("current")){ self.nowWatch = $("#header-bottom nav li").index(this); srcTxt = self.root + "common/images/img_nav_current" + self.nowWatch + ".png"; $("#nav-indicator__indicator").attr({"src":srcTxt}); $("#nav-indicator").css({"left":$("#header-bottom nav li").eq(self.nowWatch).offset().left,"width":$("#header-bottom nav li").eq(self.nowWatch).width() + 1}); $("#nav-indicator").show(); } }); //SP メニュー表示 $("#sp-menu-btn").click(function(){ var offsetY = $("#site-header").height(); if($("#sp-large-menu").is(":hidden")){ if(self.isFloat){ $(".header-top h1").hide(); offsetY = $("#site-header").height(); self.current_float = true; }else{ offsetY = $("#site-header").height(); self.current_float = false; } self.current_scrollY = $( window ).scrollTop() ; $("#sp-menu-btn").removeClass("menu-onclose"); $("#sp-menu-btn").addClass("menu-onopen"); $("#sp-large-menu").stop().slideDown(500); $("#sp-large-menu").prop( { scrollTop: 0 } ); // スクロール禁止 if($(window).height() > 600){ $(window).on('touchmove.noScroll', function(e) { e.preventDefault(); }); }else{ $("#sp-menu-group").on('touchmove.noScroll', function(e) { e.preventDefault(); }); $(".header-top").on('touchmove.noScroll', function(e) { e.preventDefault(); }); } $(".content_wrapper").fadeOut(100); $(".content_wrapper").css( { position: 'fixed', width: '100%', top: -1 * self.current_scrollY + offsetY, "z-index":-1 } ); }else{ self.hideSpMenu(); } }); this.setScroll(); this.onResize(); }; //スマホ版メニュー隠す navApp.hideSpMenu = function(){ $("#sp-menu-btn").removeClass("menu-onopen"); $("#sp-menu-btn").addClass("menu-onclose"); $("#sp-large-menu").stop().hide(); // スクロール禁止 解除 $(window).off('.noScroll'); $("#sp-menu-group").off('.noScroll'); $(".header-top").off('.noScroll'); $(".header-top h1").show(); $(".content_wrapper").css( { position:"static","z-index":"auto",top:"auto"} ); $(".content_wrapper").fadeIn() $( 'html, body' ).prop( { scrollTop: self.current_scrollY } ); } //ラージメニュー表示 navApp.showMenu = function($elm,preNum){ var srcTxt = ""; var self = this; //遅延処理後にロールオーバーしていたら $(":hover").each(function () { //カーソル位置の全要素を走査 self.menu = $elm.find(".large-menu"); self.nowWatch = $("#header-bottom nav li").index(this); if ($(this).is($("#header-bottom nav li").eq(self.nowWatch)) && self.menu.is(":hidden") && self.nowWatch == preNum) { //hoverの走査中要素 if($(this).find(".large-menu").length > 0){ srcTxt = self.root + "common/images/img_nav_current" + self.nowWatch + ".png"; self.menu.find(".nav-bottom--large .nav-indicator").attr({"src":srcTxt}); self.menu.find(".nav-bottom--large").css({"left":$("#header-bottom nav li").eq(self.nowWatch).offset().left - $("#header-bottom nav ul").position().left,"width":$("#header-bottom nav li").eq(self.nowWatch).width()}); self.menu.css({"left":-($("#header-bottom nav li").eq(self.nowWatch).offset().left)+($("#header-bottom nav ul").position().left)}); self.menu.stop().slideDown(500); self.onResize(); return false; } } }); } //ラージメニュー隠す navApp.hideMenu = function($elm){ $elm.removeClass("over"); //インジケータ消える $("#nav-bottom").hide(); //メニュー消える $(".large-menu").hide(); } //リサイズ navApp.onResize = function(){ var self = this; $(".large-menu").width(980); //PC カレント表示設定 $("#header-bottom nav li").each(function(){ if($(this).hasClass("current")){ self.nowWatch = $("#header-bottom nav li").index(this); $("#nav-indicator").css({"left":$("#header-bottom nav li").eq(self.nowWatch).offset().left,"width":$("#header-bottom .pc-nav li").eq(self.nowWatch).width()}); } }); //スクロールするメニュー要素をチェック if($("#header-bottom").length > 0){ this.scrollBox = $("#header-bottom"); } if($(window).width() <= this.breakPoint){ this.scrollBox = $("#sp-menu-group"); //ボタンのサイズチェック $(".inquiry-link").height($(".inquiry-link").width()/2.75); $(".inquiry-tel").height($(".inquiry-tel").width()/2.75); $(".bottom-document-request .inquiry-sub-link").height($(".bottom-document-request .inquiry-sub-link").width()/8.2); $(".bottom-document-request .inquiry-sub-window").height($(".bottom-document-request .inquiry-sub-link").width()/8.2); $(".bottom-document-request .inquiry-sub-form").height($(".bottom-document-request .inquiry-sub-link").width()/8.2); }else{ $(".inquiry-link").height(100); $(".inquiry-tel").height(100); $(".bottom-document-request .inquiry-sub-link").height(40); $(".bottom-document-request .inquiry-sub-window").height(40); $(".bottom-document-request .inquiry-sub-form").height(40); } //SP メニューの位置 if(!navApp.isFloat){ $("#site-header #sp-large-menu").css({"top":$("#site-header").height()}); }else{ $("#site-header #sp-large-menu").css({"top":$("#sp-menu-group").height()}); } if($(window).height() < 600){ $("#site-header #sp-large-menu nav").height(600) } $("#site-header #sp-large-menu").height($(window).height()); $(".inquiry-link a").height($(".inquiry-link").height()); }; //スクロールの速度 navApp.setScroll = function(){ var self = this; var otherScrollBox = $("#sp-menu-group"); if($("#header-bottom").length > 0){ this.scrollBox = $("#header-bottom"); } if(this.scrollBox != null){ if($(window).width() <= this.breakPoint){ this.scrollBox = $("#sp-menu-group"); otherScrollBox = $("#header-bottom"); } var boxTop = this.scrollBox.offset().top; $(window).scroll(function () { if($(window).scrollTop() >= boxTop) { self.scrollBox.addClass("fixed"); $("#main").css("padding-top","40px"); self.isFloat = true; } else { self.scrollBox.removeClass("fixed"); $("#main").css("padding-top","0"); self.isFloat = false; } otherScrollBox.removeClass("fixed"); self.onResize(); }); } }; (function($){ $(function() { //旧IE判定 if (!$.support.noCloneChecked || (isIE && ieVersion <= 8)) { isOldIE = true; } $('.alpha').hover(function() { $(this).animate({ 'opacity': '0.7' },100); },function(){ $(this).animate({ 'opacity': '1' },100); }); $("a[href^=#]").click(function(e) { e.preventDefault(); // アンカースクロール var speed = 400; // ミリ秒 var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top; $('body,html').animate({scrollTop:position}, speed, 'swing'); }); //ナビゲーション動作 navApp.init(); $(window).on('load resize', function(){ navApp.onResize(); }); $(window).on('load', function() { var url = $(location).attr('href'); if(url.indexOf("?q") != -1){ var id = url.split("?"); id = id[id.length - 1]; id = url.split("=")[1]; var $target = $('#q' + id); if($target.length){ var pos = $target.offset().top - 90; $("html, body").animate({scrollTop:pos}, 750); } } }); $(window).on("orientationchange", function() { if(isSP){ navApp.hideSpMenu(); } }); if(!isSP){ $("a[href='tel:0120-109-708']").unbind(); $("a[href='tel:0120-109-708']").click(function(e){ e.preventDefault(); }) } }); })(jQuery);