$(function() { var m_dur = 1000; // 애니메이션 진행 속도 var m_meth = "easeOutExpo"; // 애니메이션 진행 타입 // 메뉴 불러오기 if($('#top1menu').length > 0 && $('#lnb_device').length > 0) { $("#lnb_device").html($("#top1menu").html()); } // 메뉴 열기 $(document).on('click', '#open_mn', function(){ $('#topmenu').addClass('active').show().animate({right:0,opacity:1},m_dur/2,m_meth); $('html').css({"overflow":"hidden"}); mobileMenu(); }); // 메뉴 닫기 $(document).on('click', '#m_close', function(){ m_lnbClose() m_lnbHideAll(); }); // 모바일메뉴 이벤트 function mobileMenu() { // 1차메뉴 첫번째 항상 on $('#lnb_device .topMenuLi > a').attr('title', '열기'); $('#lnb_device .topMenuLi').first().addClass('on').children('a').attr('title', '닫기'); // 1차메뉴 클릭시 $(document).on('click', '#lnb_device .topMenuLi > a', function(e) { e.preventDefault(); m_lnbHideAll(); $(this).attr('title', '닫기'); $(this).closest('li').addClass('on'); }); // 2차 메뉴 클래스 지우기 $('#lnb_device .top2m').each(function(){ $(this).find('.topSubm').first().removeClass('on'); }); } // 2차메뉴 숨김 function m_lnbHideAll(){ $('#lnb_device .topMenuLi').removeClass('on'); $('#lnb_device .topMenuLi>a').attr('title', '열기'); } // 메뉴 닫기 function m_lnbClose(){ $('#topmenu').stop(true, true).removeClass('active').removeAttr('style'); $('html').removeAttr('style'); } // 3차메뉴 없을경우 $('.top3m').each(function() { if ($(this).find('li').length === 0) { $(this).addClass('no3th'); } }); $(window).resize(function(){ if ($(window).width() > 1024){ m_lnbClose(); m_lnbHideAll(); } }); });