function styleHeaderJs(){ $(".toggle").click(function(){ if($(this).hasClass("active")){ $("html, body").css({"overflow":"hidden", "height":"100%"}); $("#bg2").bind("touchmove", function(e) { e.preventDefault(); }); }else{ $("html, body").css({"overflow":"auto", "height":"auto"}); $("#bg2").unbind('touchmove'); } }); } function motionJs(){ /*$(window).scroll(function(){ var scrollT=$(window).scrollTop(); if(scrollT>200){ $('.sub_top').addClass('on'); }else{ $('.sub_top').removeClass('on'); } });*/ var container = document.getElementById ("page_title"); var textNode = container.firstChild; if (textNode.data.length == 0) { return; } var textNodeLeft = textNode.splitText (textNode.data.length - 1); var boldTag = document.createElement ("span"); container.insertBefore (boldTag, textNodeLeft); boldTag.appendChild (textNodeLeft); } function selectBox() { //셀렉트박스 $('.select_layout').find('.select_title').on('click', function(){ $(this).parent().toggleClass('on'); $(this).parent().find('.list').stop().slideToggle(300); }); $('.select_layout').find('li').on('click', function(){ var hidden = $(this).data('option'), titleName = $(this).text(); $(this).parent().parent().find('.select_hidden').val(hidden); $(this).parent().parent().find('.select_title').text(titleName); //셀렉트박스 자동 닫기 $(this).parent().parent().removeClass('on'); $(this).parent().hide(); }); } function pageTopButton(){ $(window).scroll(function(){ var scrollT=$(window).scrollTop(); if(scrollT>0){ $('#top_btn').fadeIn(); }else{ $('#top_btn').fadeOut(); } }); $("#top_btn").click(function(){ $('body,html').animate({scrollTop: 0}, 300); }); function checkOffset() { var a=$(document).height()-$(window).height(); var b=$('footer').height(); scroll = $(window).scrollTop(); if (scroll > a-b) { $("#top_btn").css("position","absolute"); }else { $("#top_btn").css("position","fixed"); } } $(document).ready(checkOffset); $(document).scroll(checkOffset); } function stickyJs(){ $(".st3 .sub_tab_wrap").addClass("sticky"); $(".sticky").sticky({topSpacing:0, zIndex:100}); $(function(){ $(document).on("scroll", scroll); menu = $('.sticky .sub_tab li a'); menu.on('click', function() { $(document).off("scroll"); var id = $(this).attr('href'), target = this.hash; menu.parents("li").removeClass('on'); $(this).parents("li").addClass('on'); $('html, body').animate({ scrollTop: $(id).offset().top }, { duration: 500, complete: function(){ $(document).on("scroll", scroll); } }); return false; }); }); function scroll(event){ var scrollPos = $(document).scrollTop(); menu.each(function(){ var currLink = $(this); var refElement = $(currLink.attr("href")); if (refElement.position().top <= scrollPos && refElement.position().top + refElement.height() > scrollPos) { menu.parents("li").removeClass("on"); currLink.parents("li").addClass("on"); } else{ currLink.parents("li").removeClass("on"); } }); } } function m22(){ if(!$('#main').hasClass('m22')) return; $(".lot_search_wrap .button_submit").on("click",function(){ $(".lot_search_wrap .modal-login").css('display','flex'); setTimeout(function() { $(".lot_search_wrap .modal-login").addClass('open'); }, 1) $("html, body").css({"overflow":"hidden", "height":"100%"}); $("#bg2").bind("touchmove", function(e) { e.preventDefault(); }); }); $(".lot_search_wrap .search_btn").on("click",function(){ $('.lot_search_wrap form[name="down_search"]').submit(); }); $("body").click(function(e){ if($(".lot_search_wrap .modal-login").hasClass("open")){ // site 라는 특정영역이 열려있을 경우 if(!$(".lot_search_wrap .modal-login").has(e.target).length){ // site에 클릭 이벤트가 발생되어 있는게 없다면 아래 내용을 실행. $('.lot_search_wrap .modal-login').removeClass('open'); setTimeout(function() { $(".lot_search_wrap .modal-login").css('display','none'); }, 50) } } }) //modal-close-btn $(".lot_search_wrap .modal-close").on("click",function(){ $('.lot_search_wrap .modal-login').removeClass('open'); setTimeout(function() { $(".lot_search_wrap .modal-login").css('display','none'); }, 50) $("html, body").css({"overflow":"auto", "height":"auto"}); $("#bg2").unbind('touchmove'); }); $(".lot_search_wrap .modal_submit").on("click",function(){ $('.lot_search_wrap form[name="form_pw"]').submit(); }); } /*m54 form*/ function inquiryCheck() { if(!$('#main').hasClass('m23')) return; if(grecaptcha.getResponse()==""){ alert("스팸방지 체크를 확인해주세요."); return false; } if ($('.inquiry_wrap .radio_btn:checked').length == 0){ alert("'신청구분'을 선택해 주세요."); $('.inquiry_wrap .radio_btn').focus(); return false; } if ($('.inquiry_wrap #i_research').val() == ""){ alert("연구 목적을 입력해주세요."); $('.inquiry_wrap #i_research').focus(); return false; } if ($('.inquiry_wrap #i_name').val() == ""){ alert("신청자를 입력해주세요."); $('.inquiry_wrap #i_name').focus(); return false; } if ($('.inquiry_wrap #i_Institution').val() == ""){ alert("소속기관을 입력해주세요."); $('.inquiry_wrap #i_Institution').focus(); return false; } if ($('.inquiry_wrap #i_type').val() == ""){ alert("셀타입을 입력해주세요."); $('.inquiry_wrap #i_type').focus(); return false; } if ($('.inquiry_wrap #i_quantity').val() == ""){ alert("요구 수량을 입력해주세요."); $('.inquiry_wrap #i_quantity').focus(); return false; } if ($('.inquiry_wrap #i_tel').val() == ""){ alert("전화번호를 입력해주세요."); $('.inquiry_wrap #i_tel').focus(); return false; } if ($('.inquiry_wrap #i_email').val() == ""){ alert("이메일을 입력해주세요."); $('.inquiry_wrap #i_email').focus(); return false; } }; function m60(){ if(!$('#main').hasClass('m60')) return; $('#wrap').addClass('type1'); } function subTabJs(){ var x,y,top,left,down; $(".sub_tab_wrap ul").mousedown(function(e){ e.preventDefault(); down = true; x = e.pageX; left = $(this).scrollLeft(); }); $("body").mousemove(function(e){ if(down){ var newX = e.pageX; $(".sub_tab_wrap ul").scrollLeft(left - newX + x); } }); $("body").mouseup(function(e){down = false;}); // 서브 탭 스크롤 var pageList = ".sub_tab_wrap ul"; var pageListFadeEl = ".scroll_fade"; var pageListItem = ".sub_tab_wrap ul li"; $(pageList).on("scroll", function() { var scrollLeft = $(this).scrollLeft(); var pageListWidth = $(this)[0].scrollWidth - $(this)[0].offsetWidth; if(scrollLeft === pageListWidth){ $(this).siblings(pageListFadeEl).addClass('is-hide'); //alert("aa") } else { $(this).siblings(pageListFadeEl).removeClass('is-hide'); } }); if($(pageListItem).hasClass("on") === true){ var activeWidth = $(".sub_tab_wrap ul li.on").width(); var activeOffset = $(".sub_tab_wrap ul li.on").offset().left; $(pageList).animate({ scrollLeft: activeOffset - activeWidth }, 300); } } function m21(){ if(!$('#main').hasClass('m21')) return; $(document).on("click",".faq_list_wrap .list_wrap",function(e){ $(this).toggleClass("act"); if($(this).attr("class") == "list_wrap act"){ $(this).find(".view").stop(true,true).slideDown(300, "easeInSine"); }else{ $(this).find(".view").stop(true,true).slideUp(300, "easeInSine"); } $(this).siblings().removeClass("act"); $(this).siblings().find(".view").stop(true,true).slideUp(); }); } function m55(){ if(!$('#main').hasClass('m55')) return; $(document).on("click",".qna_list_wrap .list_wrap",function(e){ $(this).toggleClass("act"); if($(this).attr("class") == "list_wrap act"){ $(this).find(".view").stop(true,true).slideDown(300, "easeInSine"); }else{ $(this).find(".view").stop(true,true).slideUp(300, "easeInSine"); } $(this).siblings().removeClass("act"); $(this).siblings().find(".view").stop(true,true).slideUp(); }); } function m24(){ if(!$('#main').hasClass('m24')) return; $(".m24 .section02 .q_wrap").click(function(){ $(this).toggleClass("on"); $(this).next().stop().slideToggle(300); }); } $(function(){ styleHeaderJs(); motionJs(); stickyJs(); selectBox(); subTabJs(); pageTopButton(); m21(); m22(); m24(); m55(); m60(); $(".privacy_slide button.arrow").click(function(){ $(this).toggleClass("on"); $(this).siblings(".list").stop().slideToggle(300); }); });