$(document).ready(function() { $('#header #gnb').mouseover(function () { $('#header').addClass('menu-open'); $('.depth1 li').addClass('on'); $('.depth2').addClass('on'); }); $('#header').mouseleave(function () { $('#header').removeClass('menu-open'); $('.depth1 li').removeClass('on'); $('.depth2').removeClass('on'); }); $("#header .depth1 > li > a").on('click', function (e) { var index = $(this).parents(".depth1 > li").index(); if ($("#header").hasClass('on') === false || index === 2) { return } e.preventDefault(); $(this).parent("li").toggleClass("active") $(this).siblings(".depth2").stop().slideToggle(); $(this).parent("li").siblings("li").children(".depth2").slideUp(); $(this).parent("li").siblings("li").removeClass("active") }); var jbOffset = $('#header').offset(); $(window).scroll(function () { if ($(document).scrollTop() > jbOffset.top) { $('#quick').addClass('jbFixed'); } else { $('#quick').removeClass('jbFixed'); } }); $(".anchorLink").anchorAnimate(); }); jQuery.fn.anchorAnimate = function(settings) { settings = jQuery.extend({ speed : 700 }, settings); return this.each(function(){ var caller = this $(caller).click(function (event) { event.preventDefault() var locationHref = window.location.href var elementClick = $(caller).attr("href"); var destination = $(elementClick).offset().top-0; $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() { window.location.hash = elementClick -0 }); return false; }) }) } 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) { $("#gnb .depth1 > li.hn" + page.hn + " > a").addClass("on"); //1depth 활성 } $("#gnb .depth2 > li.sn" + page.sn).find(" > a").addClass("on").end().find("> ul").addClass("on").find("> li.cn" + page.cn + " a").addClass("on"); $(".snb ul li.sn" + page.sn).find(" a").addClass("on").end().find("> ul").addClass("on").find("> li.cn" + page.cn + " a").addClass("on"); //2depth 활성 }