//gnb /**** 주 메뉴 *****/ $(function(){ var gnb = this; gnb.$obj = $("#gnbMenu .gnb"); gnb.dep1 = gnb.$obj.children('.depth1'); gnb.dep2 = gnb.dep1.children('.depth2'); gnb.dep3 = gnb.dep2.children('ul').children('li').children('ul') gnb.dep3.prev().children('a').addClass('has_child'); /* 2차메뉴 토글 */ gnb.active ={ over : function(){ gnb.dep2.slideDown('fast'); }, out : function(){ gnb.dep2.slideUp('fast'); }, }; gnb.dep1.on('mouseenter focusin', function() { $(this).siblings().children('.depth2').children('ul').find('ul').slideUp('fast'); slideDown = setTimeout(function() { if(!$("#gnbMenu").hasClass('active')) { gnb.active.over.call(this); }; }, 200); }); $("#gnbMenu").mouseleave(function() { clearTimeout(slideDown); if(!$(this).hasClass('active')) { gnb.active.out.call(this); gnb.dep3.slideUp('fast'); } }); $('a,input,button').not('#gnbMenu .gnb a').focus(function() { clearTimeout(slideDown); if(!$("#gnbMenu").hasClass('active')) { gnb.active.out.call(this); gnb.dep3.slideUp('fast'); }; }); /* 3차메뉴 토글 */ gnb.dep2.children('ul').children('li').on('click', function() { $(this).siblings().children('ul').slideUp('fast'); $(this).children('ul').slideToggle('fast'); }); /* 전체메뉴 보기 */ $('.allmenu').click(function() { if( $(this).hasClass('active') ) { $(this).removeClass('active'); $("#gnbMenu").removeClass('active'); gnb.dep2.slideUp('fast') } else { $(this).addClass('active'); $("#gnbMenu").addClass('active'); gnb.dep2.slideDown('fast') if ( $("body").hasClass("sticky-header") ) { $("body").removeClass("sticky-header"); $(window).scrollTop(150); } } }); // gnb.dep1.children('span').on('mouseenter focusin', function() { // $("#gnbMenu").removeClass('active'); // $('.allmenu').removeClass('active'); // }); }); //lnb var menuJs={ menu : function(aClick,act,act02,act03,act04,act05){ isTouchWebkit = "ontouchstart" in window && "WebKitCSSMatrix" in window; if ( isTouchWebkit ) { var child_count = 0; var aClick = aClick; $(aClick).click(function() { if($(this).parent().parent().parent() != null && $(this).attr('class').indexOf('selected') < 0) { $(this).parent().parent().parent().children('li').each(function() { if($(this).children('span').children('.has_child').attr('class') != null) { if($(this).children('span').children('.has_child').attr('class').indexOf('selected') >= 0 ) { $(this).children('span').children('.has_child').removeClass('selected'); $(this).children('ul').hide(); } } }); } if($(this).attr('class').indexOf('selected') < 0 ) { $(this).addClass('selected'); child_count = $(this).parent().parent().children('ul').children('li').length $(this).parent().parent().children('ul').animate({'height':'toggle'}, 100 + (child_count * 60), 'swing', function(){}); } else { $(this).removeClass('selected'); child_count = $(this).parent().parent().children('ul').children('li').length; $(this).parent().parent().children('ul').animate({'height':'toggle'}, (child_count * 100), 'swing', function(){}); } }); } else { $('.lnb li:nth-child('+ act + ') a').addClass("hover"); $('.lnb .depth2 li a').removeClass("hover"); $('.lnb li:nth-child('+ act + ') .depth2').show(); $('.lnb li:nth-child('+ act + ') .depth2 li:nth-child('+ act02 + ') .dep2_tit').addClass("selected"); var aClick = aClick; $(aClick).click(function() { if($(this).parent().parent().parent() != null && $(this).attr('class').indexOf('selected') < 0) { $(this).parent().parent().parent().children('li').each(function() { if($(this).children('span').children('.has_child').attr('class') != null) { if($(this).children('span').children('.has_child').attr('class').indexOf('selected') >= 0 ) { $(this).children('span').children('.has_child').removeClass('selected'); $(this).children('ul').hide(); } } }); } if($(this).attr('class').indexOf('selected') < 0 ) { $(this).addClass('selected'); child_count = $(this).parent().parent().children('ul').children('li').length; $(this).parent().parent().children('ul').animate({'height':'toggle'}, 100 + (child_count * 60), 'swing', function(){}); } else { $(this).removeClass('selected'); child_count = $(this).parent().parent().children('ul').children('li').length; $(this).parent().parent().children('ul').animate({'height':'toggle'}); } }); } }};