(function($){ $(function(){ setsize(); /**サイドバー位置調整**/ setsize(); $("body").delay(600).queue(function(){ setnav(); }); /**スマホメニュー開閉**/ var $body = $('body'); $('#spmenu').on('click', function () { $body.toggleClass('side-open'); $('#js__overlay').on('click', function () { $body.removeClass('side-open'); }); if( $('body').hasClass('side-open') ) { $(window).on('touchmove.noScroll', function(e) { e.preventDefault(); }); }else{ $(window).off('.noScroll'); } }); /**ページ内スクロール**/ $('a[href^="#"]').on('click',function() { var href= $(this).attr('href'); var target = $(href == '#' || href == '' ? 'html' : href); var position = 0; if(target.length){ position = target.offset().top; } var mh = $(".sidebar-primary #sidemenu").outerHeight()+20; //if($(document).width() > 1200 ) { mh = 30; } if($('.site-title').css('font-weight') == '100' || $('.site-title').css('font-weight') == '200' ) { mh = 30; } //if($(document).width() < 768) { mh = $('.site-header').outerHeight() + $('.breadcrumb').outerHeight() + $(".sidebar-primary #sidemenu").outerHeight()+20; } if($('.site-title').css('font-weight') == '400' || $('.site-title').css('font-weight') == '500' ) { mh = $('.site-header').outerHeight() + $('.breadcrumb').outerHeight() + $(".sidebar-primary #sidemenu").outerHeight()+20; } //var mh = $(".site-header").outerHeight() + $(".site-header + nav > div").outerHeight() + $(".breadcrumb").outerHeight()+10; var speed = 1000; $('html,body').stop().animate({scrollTop:position-mh} ,speed, 'swing'); return false; }); $('.pagetop').on('click',function() { $('html,body').stop().animate({scrollTop:0} ,1000, 'swing'); }); if( $('#mw_wp_form_mw-wp-form-177').length ){ $('#mw_wp_form_mw-wp-form-177 td span.mwform-zip-field input:nth-child(1)').attr('id','zip'); $('#mw_wp_form_mw-wp-form-177 td span.mwform-zip-field input:nth-child(2)').attr('id','zip1'); } if( $('#mw_wp_form_mw-wp-form-347').length ){ $('#mw_wp_form_mw-wp-form-347 td span.mwform-zip-field input:nth-child(1)').attr('id','zip'); $('#mw_wp_form_mw-wp-form-347 td span.mwform-zip-field input:nth-child(2)').attr('id','zip1'); } if( $('#mw_wp_form_mw-wp-form-382').length ){ $('#mw_wp_form_mw-wp-form-382 td span.mwform-zip-field input:nth-child(1)').attr('id','zip'); $('#mw_wp_form_mw-wp-form-382 td span.mwform-zip-field input:nth-child(2)').attr('id','zip1'); } if( $('#mw_wp_form_mw-wp-form-711').length ){ $('#mw_wp_form_mw-wp-form-711 td span.mwform-zip-field input:nth-child(1)').attr('id','zip'); $('#mw_wp_form_mw-wp-form-711 td span.mwform-zip-field input:nth-child(2)').attr('id','zip1'); } if( $('#mw_wp_form_mw-wp-form-731').length ){ $('#mw_wp_form_mw-wp-form-731 td span.mwform-zip-field input:nth-child(1)').attr('id','zip'); $('#mw_wp_form_mw-wp-form-731 td span.mwform-zip-field input:nth-child(2)').attr('id','zip1'); } $('.entry-content .flow li').matchHeight(); if($(".mhlist").length){ $('.mhlist > div.wall').matchHeight(); } //prpのタブ if($('#prptab').length){ $('#prptab').responsiveTabs({ startCollapsed: 'accordion' }); } }); $(window).load(function(){ $('.entry-content .flow li').matchHeight(); if($(".mhlist").length){ $('.mhlist > div.wall').matchHeight(); } setsize(); setnav(); }); $(window).resize(function () { setsize(); setnav(); }); $(window).scroll(function () { setsize(); setnav(); }); $(window).on('orientationchange', function(){ setsize(); $("body").delay(600).queue(function(){ setnav(); }); }); function setsize(){ //ヘッダー高さ headh = $(".site-header").outerHeight(); headb = $(".breadcrumb").outerHeight(); heads = $(".sidebar-primary #sidemenu").outerHeight(); //if($(document).width() <= 768) { if($('.site-title').css('font-weight') == '400' || $('.site-title').css('font-weight') == '500' ) { $(".site-container, .breadcrumb, .sidebar-primary #sidemenu").removeAttr('style');//リセット if($('body').hasClass('subtop')){ $(".site-container").css("padding-top",(headh+10)+"px"); }else{ $(".site-container").css("padding-top",(headh+headb+heads+10)+"px"); $(".breadcrumb").css("top",headh+"px"); $(".sidebar-primary #sidemenu").css({"top":((headh+headb)-2)+"px"}); } }else{ $(".site-container, .breadcrumb, .sidebar-primary #sidemenu").removeAttr('style'); } //トップページ if($(".home .kamoku").length){ //if($(document).width() <= 1280) { if($('.site-title').css('font-weight') != '100' ) { $(".home .kamoku li").removeAttr('style');//リセット hkw = $(".home .kamoku li").width(); $(".home .kamoku li").css("height",hkw+"px"); hkfs1 = (hkw/185)*70; $(".home .kamoku li a i").css({"font-size":hkfs1+"px"}); hkfs2 = (hkw/185)*18; if(hkfs2 < 12){ hkfs2 = 12; } if(hkfs2 > 18){ hkfs2 = 18; } $(".home .kamoku li a p").css({"font-size":hkfs2+"px"}); }else{ $(".home .kamoku li,.home .kamoku li a i,.home .kamoku li a p").removeAttr('style');//リセット } } if($(".home .kamoku2").length){ //if($(window).width() <= 840) { //if($(window).width() <= 1280) { if($('.site-title').css('font-weight') != '100' ) { $(".home .kamoku2 li").removeAttr('style');//リセット hkw = $(".home .kamoku2 li").width(); $(".home .kamoku2 li").css("height",hkw+"px"); hkfs1 = (hkw/185)*70; $(".home .kamoku2 li a i").css({"font-size":hkfs1+"px"}); hkfs2 = (hkw/185)*18; if(hkfs2 < 12){ hkfs2 = 12; } if(hkfs2 > 18){ hkfs2 = 18; } $(".home .kamoku2 li a p").css({"font-size":hkfs2+"px"}); }else{ $(".home .kamoku2 li,.home .kamoku2 li a i,.home .kamoku2 li a p").removeAttr('style'); } } //診療トップページ if($(".subtop .kamoku").length){ //if($(document).width() <= 1280) { if($('.site-title').css('font-weight') != '100' ) { $(".subtop .kamoku li").removeAttr('style');//リセット hkw = $(".subtop .kamoku li").width(); $(".subtop .kamoku li").css("height",hkw+"px"); hkfs2 = (hkw/185)*18; if(hkfs2 < 14){ hkfs2 = 14; } if(hkfs2 > 18){ hkfs2 = 18; } $(".subtop .kamoku li a p").css({"font-size":hkfs2+"px","height":hkw+"px","line-height":hkw+"px"}); //if($(document).width() <= 480) { if($('.site-title').css('font-weight') == '500' ) { $(".subtop .kamoku li a p > span").css({"font-size":(hkfs2-2)+"px"}); }else{ $(".subtop .kamoku li a p > span").removeAttr('style'); } }else{ $(".subtop .kamoku li,.subtop .kamoku li a p,.subtop .kamoku li a p > span").removeAttr('style'); } } //fbnr //if($(document).width() > 768 ) { fh = $('.site-header').outerHeight(); fp = $('html').scrollTop(); if(fp==0){ fp = $('body').scrollTop(); } console.log(fh+":"+fp); //if( ( fp >= fh ) || ( $(document).width() < 768 )){ if( ( fp >= fh ) || ( $('.site-title').css('font-weight') == '400' || $('.site-title').css('font-weight') == '500' )){ $("#flink, .pagetop").addClass('active'); }else{ $("#flink, .pagetop").removeClass('active'); } //} } function setnav(){ if($(".sidebar-primary #sidemenu").length){ //リセット $(".entry").removeAttr('style'); console.log($(document).width()); rp = $(".site-header").outerHeight() + $(".site-header + nav > div").outerHeight() + $(".breadcrumb").outerHeight(); sp = $(window).scrollTop(); console.log(rp+":"+sp); //if($(document).width() <= 1200 && $(document).width() >768) { if($('.site-title').css('font-weight') == '300' ) { headw = $(".entry").offset().left; headb = $(".breadcrumb").outerHeight(); $(".entry").css("padding-top","80px"); if(sp >= rp){ $(".sidebar-primary #sidemenu").css({"position":"fixed","top":"-2px","left":headw+"px"}); }else{ $(".sidebar-primary #sidemenu").css({"position":"absolute","top":headb+"px","left":headw+"px"}); } } }else{ $(".sidebar-primary #sidemenu, .entry").removeAttr('style'); } } })(jQuery);