/*----------------------------------------------------------------------------------- /* /* Init JS /* -----------------------------------------------------------------------------------*/ /*----------------------------------------------------*/ /* nav /*----------------------------------------------------*/ $(function() { let win = $(window); // 헤더 내비게이션 토글 버튼 클릭 이벤트 $('header .nav-trigger').click(function() { if ($('header').hasClass('active')) { $('header').removeClass('active'); } else { $('header').addClass('active'); } }); // 윈도우 창 너비가 1024px 이상일 때, 헤더 내비게이션 드롭다운 이벤트 if (win.width() > 1024) { $('header .fullnav > li').bind({ mouseenter: function() { $('header .depth_2, header .dim').stop().slideDown(200); }, mouseleave: function() { $('header .depth_2, header .dim').stop().slideUp(200); } }); } else { // 모바일 화면에서는 내비게이션 링크를 클릭하면 드롭다운 대신 링크 이동 $('.fullnav > li > a').each(function() { var link = $(this).attr('href'); $(this).attr('data_link', link); $(this).removeAttr('href'); }); } // 윈도우 창 크기 변경 이벤트 win.resize(function() { if (win.width() > 1024) { // 윈도우 창 너비가 1024px 이상일 때, 헤더 내비게이션 드롭다운 이벤트 $('header .fullnav > li').bind({ mouseenter: function() { $('header .depth_2, header .dim').stop().slideDown(200); }, mouseleave: function() { $('header .depth_2, header .dim').stop().slideUp(200); } }); // 모바일 화면에서는 내비게이션 링크를 클릭하면 드롭다운 대신 링크 이동 $('.fullnav > li > a').each(function() { var link = $(this).attr('data_link'); $(this).attr('href', link); $(this).removeAttr('data_link'); }); // 드롭다운 스타일 초기화 $('header .depth_2, header .dim').removeAttr('style'); } else { // 윈도우 창 너비가 1024px 미만일 때, 헤더 내비게이션 드롭다운 이벤트 해제 $('header .fullnav > li').unbind('mouseenter'); $('header .fullnav > li').unbind('mouseleave'); // 모바일 화면에서는 내비게이션 링크를 클릭하면 드롭다운 대신 링크 이동 $('.fullnav > li > a').each(function() { var link = $(this).attr('href'); $(this).attr('data_link', link); $(this).removeAttr('href'); }); } }); }); // 모바일 내비게이션 드롭다운 이벤트 function mobile_navi(_target) { var _target = $(_target); if (_target.parent().hasClass('active')) { _target.parent().removeClass('active'); _target.siblings().slideUp(200); } else { $('.fullnav > li').removeClass('active'); $('.fullnav .depth_2').slideUp(200); _target.parent().addClass('active'); _target.siblings().slideDown(200); } }