////////////////////////////////////////// // jQuery common ////////////////////////////////////////// $(function(){ "use strict"; var ua; ua = navigator.userAgent; var isTab = (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0); if (isTab) { $('.gnav__item--parent').on('click', function(){ if($(this).is('.open')) { $(this).removeClass('open'); } else { $(this).addClass('open'); } }); } else { //// fade //// $(".fade").hover(function(){ $(this).fadeTo(100, 0.7); },function(){ $(this).fadeTo(300, 1.0); }); //gnav $('.phone-txt').on('click', function(e) { e.preventDefault(); }); $('.gnav__item--parent').hover(function(){ $(this).addClass('open'); },function(){ $(this).removeClass('open'); }); } if($('.slider').length) { $('.slider').slick({ dots: true, arrows: true, autoplay: true, autoplaySpeed: 4000, infinite: true, fade: false, }); } if($('.colorbox').length) { $(".colorbox--inline").colorbox({ inline:true, maxWidth:"90%", maxHeight:"90%" }); } //// pageScroll //// $('.scroll[href^="#"]').click(function(e) { var id = $(this).attr("href"); var offset; if($('.is_sp').css('display') === 'block'){ offset = 75 } else { offset = 50 } var target = $(id).offset().top - offset; $('html, body').animate({ scrollTop:target }, 500); e.preventDefault(); }); $('[data-img="bg"]').each(function(){ var mvImg = $('.bg_img',this).attr('src'); $(this).css('background-image','url('+mvImg+')'); }); //// menu //// var menuBtn = $('#JsMenuBtn'); var wrapper = $('#Wrapper'); $(menuBtn).on('click', function(e) { if($(this).is('.open')) { $(this).add(wrapper).removeClass('open'); } else { $(this).add(wrapper).addClass('open'); } e.preventDefault(); }); $('.item-display__dtl-name').each(function(){ if($(this).text().length === 1) { $(this).parent().addClass('one') } }); $('.topics-nav__item.current').prev().addClass('prev'); $('.topics-nav__item.current').next().addClass('next'); /*form*/ var checkbox = $('.input-checkbox'); var radio = $('.input-radio'); var agreeCheck = $('#JsAgreeCheck'); var submitBtn = $('#JsFormSubmitBtn'); $('.input-icon:checked').parent().addClass('checked'); $(checkbox).on('change', function () { if ($(this).prop('checked')) { $(this).parent().addClass('checked'); } else { $(this).parent().removeClass('checked'); } if($(agreeCheck).prop('checked')){ $(submitBtn).removeClass('off').attr('disabled',false); } else { $(submitBtn).addClass('off').attr('disabled',true); } }); $('.checkbox input').on('change', function () { if ($(this).prop('checked')) { $(this).next().addClass('checked'); } else { $(this).next().removeClass('checked'); } }); var replyBtn = $('#JsReply'); var replyForm = $('#JsReplyForm'); $(radio).on('change', function () { var name = $(this).attr('name'); $('.input-radio[name="' + name +'"]').parent().removeClass('checked'); $(this).parent().addClass('checked'); if($(replyBtn).prop('checked')){ $(replyForm).slideDown(300); } else { $(replyForm).hide(); } }); if($('.form__select').length){ $('.form__select').customSelect(); } if($('.form__select-custom').length){ $('.form__select-custom').customSelect(); } if($(replyBtn).prop('checked')){ $(replyForm).show(); } $("#JsResetBtn").bind("click", function(){ $(this.form).find("textarea, :text, select").val("").end().find(":checked").prop("checked", false); $('.form__label, .checkbox label').removeClass('checked'); $(replyBtn).prop("checked", true).parent().addClass('checked'); $(replyForm).show(); }); $('.faq-list__ttl').on('click',function(e){ if($(this).is('.open')) { $(this).removeClass('open').next().slideUp(300); } else { $(this).addClass('open').next().slideDown(300); } e.preventDefault(); }); var changeImg; //// sp //// function spEvent(){ changeImg = $('[data-img="change"]'); if($(changeImg).length){ $(changeImg).each(function(){ $(this).attr('src', $(this).attr('src').replace('_pc','_sp')); }); } } //// pc //// function pcEvent(){ $(wrapper).removeClass('open'); $(menuBtn).removeClass('open'); changeImg = $('[data-img="change"]'); if($(changeImg).length){ $(changeImg).each(function(){ $(this).attr('src', $(this).attr('src').replace('_sp','_pc')); }); } } if($('.is_pc').css('display') === 'none'){ spEvent(); } else { pcEvent(); } var wWidth = $(window).width(); $(window).on('resize',function(){ var wW = $(window).width(); if(wWidth !== wW){ if($('.is_pc').css('display') === 'none'){ spEvent(); }else { pcEvent(); } } }); /// height var box, col; if ( $('[data-height="col2"]')[0] ) { box = $('[data-height="col2"]'); col = 2; var h = $('html').height(); setInterval(function(){ if ( h != $('html').height() ) { changeHeight(); h = $('html').height(); } },500); changeHeight(); } if ( $('[data-height="col3"]')[0] ) { box = $('[data-height="col3"]'); col = 3; var h = $('html').height(); setInterval(function(){ if ( h != $('html').height() ) { changeHeight(); h = $('html').height(); } },500); changeHeight(); } function changeHeight() { box.height('auto'); var tH = 0; var mH = 0; var cnt = 0; box.each(function(i){ if ( mH == 0 ) { mH = $(this).height(); } else { tH = $(this).height(); if ( mH < tH ) { mH = tH; } } for (var n = cnt; n <= i; n++) { box.eq(n).height(mH); } if ( i%col == col-1 ) { cnt = i+1; mH = 0; } }); } });