$(function() { page.init(); }); var page = { init: function() { page.common(); }, common: function() { //gnb hover var gnbHeader = $("#header .header_main"); $("#header").hover( function() { gnbHeader.addClass("active"); }, function() { gnbHeader.removeClass("active"); } ); $("#gnb .menu").hover( function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); } ); //gnb mobile var headerGnbWrap = $("#head-area .gnb_wrap"); var headerGnb = $("#gnb"); $("#head-area .btn_menu").on("click", function() { headerGnbWrap.stop(true,true).css("opacity",0).show().animate({ opacity:1 }, 200); headerGnb.stop(true,true).animate({ right:0 },200); return false; }); var headerClose = $("#head-area .btn_close").on("click", function() { headerGnbWrap.stop(true,true).animate({ opacity:0 }, 200, function() { $(this).hide(); }); headerGnb.stop(true,true).animate({ right:-270 },200); return false; }); // var headerClose = $(".gnb_wrap").on("click", function() { // $(this).hide() // }); $("#gnb .link").on("click", function() { if(headerClose.is(":visible")) { var getMenu = $(this).parent(); if(getMenu.hasClass("active")) { getMenu.removeClass("active").find(".sub_menu").stop(true,true).slideUp(200); } else { $("#gnb .menu.active").removeClass("active").find(".sub_menu").stop(true,true).slideUp(200); getMenu.addClass("active").find(".sub_menu").stop(true,true).slideDown(200); } return false; } }); } }