// JavaScript Document $(function() { $(".pagetop").click(function() { $('body,html').animate({scrollTop:0}, 500, 'swing'); return false; }); $('a[href^=#]').click(function() { // var mrg = 0; // if($("body").css("background-size") == "cover"){ var mrg = $("#head").outerHeight() + 10; //var mrg = $("#header #menu").outerHeight() + 10; // } var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - mrg; if($(this).hasClass("nomrg")){ position = 0; }     $('body,html').animate({scrollTop:position}, 500, 'swing'); return false; }); $("#menu > ul > li:nth-child(5) > a").on("click", function() { $(this).next().slideToggle(); }); $("#menu > ul > li:nth-child(5) > a").click(function(event){ event.preventDefault(); }); setsize(); imgchg(); setheight(); //本アップ対応 $("a.nolink").click(function(e) { e.preventDefault; return false; }); }); $(window).load(function(){ setsize(); imgchg(); setheight(); movepos(); }); $(window).resize(function () { setsize(); imgchg(); movepos(); }); $(window).scroll(function () { setsize(); imgchg(); }); $(window).on('orientationchange', function(){ setsize(); imgchg(); }); function setsize(){ var hsize = $("#head").outerHeight(); var hm = $("#head #menu").outerHeight(); var hs = hsize - hm - 30; var state = $("#header").css("background-size"); var scl = $('body').scrollTop(); if(scl==0){scl = $('html').scrollTop();} if(state == 'contain'){ if(scl >= hs) { $("#container").css("padding-top",hsize+"px"); $("#header #logo img").css({'height':'20px','bottom':'-15px'}); //$("#head").css({'position':'fixed','top':'-'+hs+'px'}); $("#head").css({'position':'fixed','top':'-'+($("#head").outerHeight() - hm - 30)+'px'}); }else{ $("#head").css({'position':'relative','top':0}); $("#container").removeAttr('style'); $("#header #logo img").removeAttr("style"); } }else{ $("#head").removeAttr('style'); $("#container").css("padding-top",hsize+"px"); $("#header #logo img").removeAttr("style"); } /* $("#container").css("padding-top",hsize+"px"); console.log(); var hsize = $("#header").outerHeight(); $("body").css("padding-top",hsize+"px"); var msize = $("#header #menu").outerHeight(); var hm = hsize - msize - 20; var scl = $('body').scrollTop(); if(scl==0){scl = $('html').scrollTop();} var state = $("#header").css("background-size"); if(state == 'contain'){ if(scl <= hm) { $("body > header").css('top','-'+scl+'px'); }else{ $("body > header").css('top','-'+hm+'px'); } }else{ $("body > header").removeAttr('style'); } */ } function setheight(){ //if($('.contents.recruit.detail ul.voice li h4 span').css('display') != 'block'){ $('#company .contents.vision ul li').matchHeight(); //$('#mychance .contents .about > div').matchHeight(); //} } //他ページよりのアンカーリンク function movepos(){ //var mrg = 0; //if($("body").css("background-size") == "cover"){ var mrg = $("#header").outerHeight() + 10; var mrg = $("#header #menu").outerHeight() + 10; //} var href = location.href; if(href.indexOf("#")>=0 || location.search){ var href=href.substring(href.indexOf("#")+1,href.length); if( location.search || href.indexOf("/menu/page/")>=0 || href.indexOf("/area1/page/")>=0 || href.indexOf("/area2/page/")>=0 ){ href = 'menus'; } if(href.indexOf("?")>=0){ var parm = href.split('?'); href = parm[0]; } }else{ return false; } var position = $("#"+href).offset().top; var speed = 500; $('body,html').animate({scrollTop:position-mrg}, speed, 'swing'); return false; } function imgchg(){ var $el_480 = $('.imgchg_480'); var $el_768 = $('.imgchg_768'); var sp = '_sp.'; var tb = '_tb.'; var pc = '_pc.'; var state = $("#header").css("background-size"); //768以下 $el_768.each(function() { var $this = $(this); var $repstr = $this.attr('src'); var $rep = pc; if ( $repstr.indexOf(pc) != -1) { $rep = pc; } if ( $repstr.indexOf(tb) != -1) { $rep = tb; } if ( $repstr.indexOf(sp) != -1) { $rep = sp; } if(state == 'cover' && $rep != tb){ $this.attr('src', $this.attr('src').replace($rep, tb)); } if(state == 'contain' && $rep != sp){ $this.attr('src', $this.attr('src').replace($rep, sp)); } if(state != 'cover' && state != 'contain' && $rep != pc){ $this.attr('src', $this.attr('src').replace($rep, pc)); } //if ( str.indexOf('hoge') != -1) { }); //480以下 $el_480.each(function() { var $this = $(this); if(state == 'contain'){ $this.attr('src', $this.attr('src').replace(pc, sp));           } else { $this.attr('src', $this.attr('src').replace(sp, pc)); } }); }