$(document).ready(function () { // 메뉴 액션 $(".topnav").hover(function () { $(this).parent().find(".subnav").show(); $(this).parent().hover(function () {}, function () { $(this).parent().find(".subnav").hide(); }); }); // footer 탑버튼 액션 $(".scroll").click(function(event){ event.preventDefault(); $('html,body').animate({scrollTop:$(this.hash).offset().top}, 500); }); // snb $(".menu1").mouseover(function () { $(".snb_sub1").stop().slideDown(200); }); $(".menu1").mouseout(function () { $(".snb_sub1").stop().slideUp(200); }); $(".menu2").mouseover(function () { $(".snb_sub2").stop().slideDown(200); }); $(".menu2").mouseout(function () { $(".snb_sub2").stop().slideUp(200); }); $('#back-top').click(function () { $('body,html').animate({ scrollTop: 0 }, 500); return false; }); $(function () { var offset = $("#quick").offset(); var topPadding = 100; $(window).scroll(function () { if ($(window).scrollTop() > offset.top) { $("#quick").stop().animate({ marginTop: $(window).scrollTop() - offset.top + topPadding }, 500); } else { $("#quick").stop().animate({ marginTop: 0 }); }; }); }); var tabLink = $(".tab_menu li").click(function (e) { e.preventDefault(); var tab_index = tabLink.index(this); $(".tab_menu li").removeClass("on"); $(".tab_menu li").eq(tab_index).addClass("on"); $(".tab_cont > div.first").show(); $(".tab_cont > div").hide(); $(".tab_cont > div").eq(tab_index).show(); }); tab(); // var tabLink = $(".sub_tab_title li").click(function () { // var sub_tab_index = tabLink.index(this); // $(".sub_tab_title li").removeClass("on"); // $(".sub_tab_title li").eq(sub_tab_index).addClass("on"); // $(".sub_cont").hide(); // $(".sub_cont").eq(sub_tab_index).show(); // $('.slider').slick('setPosition'); // }); }); // 서브 탭메뉴, 슬라이드 function tab() { //탭메뉴 실행 함수 function activateTab(tabId) { //초기화 $(".tab_wrap .tit_list > li").removeClass("active"); $(".tab_wrap .tab_list").hide(); //실행 $(`.tab_wrap .tit_list > li a[href*="${tabId}"]`).parent().addClass("active"); $(tabId).show(); } //탭메뉴 클릭할 때 실행 $(".tab_wrap .tit_list > li a").on("click", function(e) { e.preventDefault(); let tabId = $(this).attr("href"); activateTab(tabId, true); }); //페이지 로드 했을 때 탭메뉴 선택 let firstTabId = $('.tab_wrap .tit_list > li:first-child a').attr('href'); activateTab(firstTabId); slider(); //슬라이드 실행 } function slider() { $(".slider").each(function(index) { let $this = $(this); let swiper = undefined; let slideNum = $this.find('.swiper-slide').length //슬라이드 총 개수 let slideInx = 0; //현재 슬라이드 index //디바이스 체크 let oldWChk = window.innerWidth > 768 ? 'pc' : 'mo'; sliderAct(); $(window).on('resize', function() { let newWChk = window.innerWidth > 768 ? 'pc' : 'mo'; if (newWChk != oldWChk) { oldWChk = newWChk; sliderAct(); } }) function sliderAct() { //슬라이드 인덱스 클래스 추가 $this.addClass(`slider${index}`); //슬라이드 초기화 if (swiper != undefined) { swiper.destroy(); swiper = undefined; } //slidesPerView 옵션 설정 let viewNum = oldWChk == 'pc' ? 4 : 2; //loop 옵션 체크 let loopChk = slideNum > viewNum; swiper = new Swiper(`.slider${index} .inner`, { slidesPerView: 1, initialSlide: slideInx, spaceBetween: 10, slidesPerGroup: 1, observer: true, observeParents: true, loop: loopChk, navigation: { prevEl: $(`.slider${index} .btn_prev`)[0], nextEl: $(`.slider${index} .btn_next`)[0], }, on: { activeIndexChange: function() { if ($(`.slider${index}`).parent('.tab_list').css('display') != 'none') { slideInx = this.realIndex; //현재 슬라이드 index 갱신 } } }, autoplay: { delay: 3000, disableOnInteraction: false, }, loop: true, }); } }); } function setPage(arg) { //navigation hn:1depth, sn:2depth, cn:3depth 를 받음 page = jQuery.extend({ hn: "", sn: "", cn: "" }, arg || {}); if (window.console) { console.log("hn : " + page.hn + "\nsn : " + page.sn + "\ncn : " + page.cn); } if (page.hn != 10) { $(".hn" + page.hn + " a").addClass("on"); //1depth 활성 } if (page.hn >= 11) { $(".hn" + page.hn + " a").addClass("on"); //유틸 1depth 활성 } $(".snb li.sn" + page.sn).find(" a").addClass("on").end().find("> ul").addClass("on").find("> li.cn" + page.cn + " a").addClass("on"); //2depth 활성 }