jQuery(window).load(function() { //풀다운메뉴 //서브메뉴중 숨겨진것은 밑에서 가로위치 설정시 안되서 일단 보여준후 마지막에 다시 숨겼다 $('.drop_gnb ul').css('display','block'); $('.drop_gnb li').hover(function(){ $(this).find('ul:first').slideDown(200); },function(){ $(this).find('ul:first').slideUp(3); }); //이상하게 아이폰에선 최초 hover 이벤트가 발생하지 않고, 서브메뉴 보이지 않고 바로 링크로 이동하는것때문에 추가 $('.drop_gnb li').mouseover(function(){ $(this).find('ul:first').slideDown(200); }); //키보드론 복잡해서 1단계만 보여준다 $('.drop_gnb>li>a').focus(function(){ $('.drop_gnb>li>ul').css('display','none'); $(this).parent('li').find('ul:first').slideDown(200); }); $('.pulldown_all>li>a').focus(function(){ if($('#hmenu_sbox').css('display')=="none") sbox_open(); }); //하위메뉴 지시 화살표 $('.drop_gnb ul li').has('ul').find('>a').addClass('arrow'); $('.drop_gnb>li').has('ul').find('>a').append($('
')); //목차아이콘 $('.drop_gnb.vertical_menu>li>a').addClass('symbol'); //세로풀다운메뉴 첫번째 서브메뉴 위치설정 $('.drop_gnb.vertical_menu.pulldown_menu').each(function() { var $main=$(this); var direct=$main.attr('direct'); var fixh=$main.attr('fixh'); if(fixh=="1") var offset=$main.offset(); $main.find('>li>ul').each(function() { if(fixh=="1") { var offset2=$(this).offset(); var position=$(this).position(); } if(direct=="left") { if(fixh=="1") { $(this).css({'left':'-'+($(this).outerWidth())+'px','top':offset.top-offset2.top+position.top}); } else { $(this).css({'left':'-'+($(this).innerWidth()-10)+'px','top':'-1px'}); } } else { if(fixh=="1") { $(this).css({'left':($(this).parents('li').innerWidth())+'px','top':offset.top-offset2.top+position.top}); } else { $(this).css({'left':($(this).parents('li').innerWidth()-10)+'px','top':'-1px'}); } } }); }); //서브메뉴 구분선 $('.drop_gnb.pulldown_menu, .smartmenu').each(function() { //서브메뉴 가로위치설정 var $main=$(this); var direct=$main.attr('direct'); var fixh=$main.attr('fixh'); if(fixh=="1") var offset=$main.offset(); $main.find('ul').each(function() { $(this).find('ul').each(function() { if(fixh=="1") { var offset2=$(this).offset(); var position=$(this).position(); } if(direct=="left") { if(fixh=="1") { $(this).css({'left':-$(this).parents('ul').outerWidth()+'px','top':offset.top-offset2.top+position.top}); } else { $(this).css('left',(10-$(this).parents('ul').innerWidth())+'px'); } } else { if(fixh=="1") { $(this).css({'left':$(this).parents('ul').innerWidth()+'px','top':offset.top-offset2.top+position.top}); } else { $(this).css('left',($(this).parents('ul').innerWidth()-10)+'px'); } } }); $('').insertBefore($(this).find('>li:gt(0)').find('>a')); }); }); $('.drop_gnb ul').css('display','none'); //가로 기본메뉴 var roll_gnb_need_init=0; $('.roll_gnb').each(function() { var $ul=$(this); //원래 구분자는 모듈내 스크립으로 정의했었는데.그렇게 하다보니 실제 삽입되기전 서브메뉴위치조정이 되버려 여기에 넣었다 //이렇게하면 lava사용시 위치가 제대로 안맞아서 원래대로 모듈내 스크립에서 삽입 //if($ul.attr('opt')!="noline") $('
  • ').insertBefore($ul.find('>li[num]:gt(0)')); var is_hmenu3=$ul.attr('hmenu3'); if($ul.next('div').length>0) { var $sub=$ul.next('div'); $ul.find('>li[num]').each(function() { var $li=$(this); var num=$li.attr('num'); var $subul=$sub.find('>ul[num="'+num+'"]'); if(is_hmenu3!="1") $('
  • ').insertBefore($subul.find('>li[num]:gt(0)')); $li.bind('mouseover',function() { roll_gnb_toggle(num, $li, $li.parent('ul')); }); $li.find('a').bind('focus',function() { roll_gnb_toggle(num, $li, $li.parent('ul')); }); }); if(is_hmenu3!="1") { repos_gnbsub($ul,$sub); jQuery(window).bind('resize',function() {repos_gnbsub($ul,$sub);}); } } }); //세로 펼치는 메뉴(일부) $('.drop_gnb_v li').has('ul').find('>a').append($('
    ')); $('.drop_gnb_v li>a').addClass('symbol'); //서브메뉴 구분선 $('.drop_gnb_v ul').each(function() { $('').insertBefore($(this).find('>li:gt(0)').find('>a')); }); //하이라이트시 색상을 처리하기위함(:hover 만으로 처리하기엔 이미 on 메뉴를 off시키는데 한계가 있어 이렇게 처리했다) $('.pulldown_all li, .drop_gnb li, .drop_gnb_v li, .drop_gnb_h>li, .roll_gnb.no_use_2nd>li, .roll_gnbSub>li, .smartmenu li').hover(function(){ var $this=$(this); if(!$this.parent('ul').hasClass('smartmenu')) { //$this.parent('ul').find('>li>a').removeClass('active');//마우스오버시 기존 active 메뉴도 비활성화하는 스타일(이 경우 간혹 클릭시 마우스아웃된것으로 인식해 기존 active메뉴가 활성화잠깐되어보이는현상이 있어서 지금은 사용안함 $this.parent('ul').find('>li').not('.on').find('>a').removeClass('active');//대신이렇게함으로써 기존active 메뉴는 계속 활성화되어 보이고, 아래 주석처리해놓은코드도 필요없게 되었다 $this.find('>a').addClass('active'); } $this.parent('ul').find('>li>a>img[on]').each(function() { $(this).attr('src',$(this).attr('off')); }); $this.find('>a>img[on]').attr('src',$this.find('>a>img').attr('on')); $this.parent('ul').find('>li>a[ton]').each(function() { $(this).html($(this).attr('toff')); }); $this.find('>a[ton]').html($this.find('>a').attr('ton')); },function(){ var $this=$(this); if(!$this.parent('ul').hasClass('smartmenu')) { $this.parent('ul').find('>li').not('.on').find('>a').removeClass('active').trigger('blur'); //$this.parent('ul').find('>li.on>a').addClass('active'); } $this.parent('ul').find('>li>a>img[on]').each(function() { $(this).attr('src',$(this).attr('off')); }); $this.parent('ul').find('>li.on>a>img[on]').attr('src',$this.parent('ul').find('>li.on>a>img[on]').attr('on')); $this.parent('ul').find('>li>a[ton]').each(function() { $(this).html($(this).attr('toff')); }); $this.parent('ul').find('>li.on>a[ton]').html($this.parent('ul').find('>li.on>a[ton]').attr('ton')); }); var roll_gnb_pendingTimeout=false; $('.roll_gnb>li, .roll_gnbSub>li, .hmenu3vmenu .drop_gnb_v>li').hover(function(){ roll_gnb_need_init=0; clearTimeout(roll_gnb_pendingTimeout); },function(){ roll_gnb_need_init=1; roll_gnb_pendingTimeout=setTimeout(roll_gnb_out,300); }); //이미지사용시 오버설정 $('.pulldown_all a, .drop_gnb a, .drop_gnb_h a, .drop_gnb_v a, .roll_gnb.no_use_2nd a, .roll_gnbSub a, .smartmenu a').focus(function(){ var $this=$(this); $this.parent('li').parent('ul').find('>li').not('.on').find('>a').removeClass('active'); $this.addClass('active'); var $img=$this.find('img'); if($img.length>0) $img.attr('src',$img.attr('on')); if($this.is('[ton]')) $this.html($this.attr('ton')); }); $('.pulldown_all a, .drop_gnb a, .drop_gnb_h a, .drop_gnb_v a, .roll_gnb.no_use_2nd a, .roll_gnbSub a, .smartmenu a').blur(function(){ var $this=$(this); $this.parent('li').parent('ul').find('>li').not('.on').find('>a').removeClass('active'); //$this.parent('li').parent('ul').find('>li.on>a').addClass('active'); var $img=$this.find('img'); if($img.length>0) $img.attr('src',$img.attr('off')); if($this.is('[toff]')) $this.html($this.attr('toff')); }); // 메뉴주소가 #... 처럼 현재페이지링크시 메뉴 하이라이트용 $('ul li[slink]>a').click(function(){ $(this).parents('ul').find('a').removeClass('active'); $(this).parents('ul').find('li').removeClass('on'); $(this).parents('li').find('>a').addClass('active'); $(this).parents('li').addClass('on'); }); if($('ul.pulldown_all').length>0) { var $ul_pulldown_all=$('ul.pulldown_all'); var is_full=($ul_pulldown_all.attr('is_full')=="1")?1:0; var is_mcover=($ul_pulldown_all.attr('is_mcover')=="1")?1:0; if(is_full && is_mcover) { $($ul_pulldown_all.parents('[id^="cell_"],td[id^="td_"]')[0]).prepend('
    '); } else { $ul_pulldown_all.after('
    '); } var close_sbox=0; var sbox_pendingTimeout=false; $('ul.pulldown_all,#hmenu_sbox').mouseenter(function(){ close_sbox=0; clearTimeout(sbox_pendingTimeout); if($('#hmenu_sbox').css('display')=="none") sbox_open(); }).mouseleave(function(){ close_sbox=1; sbox_pendingTimeout=setTimeout(sbox_close,300); }); var $hmenu_sbox_img=$('#hmenu_sbox_img'); if($hmenu_sbox_img.length>0) $('#hmenu_sbox').prepend($hmenu_sbox_img); var max_height=0; var max_height2=0; $('ul.pulldown_all ul').each(function() { var tval=$(this).outerHeight(false); if(tval>max_height) max_height=tval; tval=$(this).height(); if(tval>max_height2) max_height2=tval; }); if(is_mcover) { max_height+=$ul_pulldown_all.outerHeight()+$ul_pulldown_all.position().top; $('#hmenu_sbox').css({'top':'0','margin-top':'0'}); } $('#hmenu_sbox').height(max_height); $('ul.pulldown_all ul').height(max_height2+parseInt($('#hmenu_sbox').css('borderTopWidth'),10)); function sbox_open() { if(is_full || $ul_pulldown_all.attr('is_layer')=="1") { var width=0; if(is_full) { if(is_mcover) { $('#hmenu_sbox').css({'width':'100%', 'left':0}); } else { width=document.documentElement.scrollWidth+$('#hmenu_sbox').width()-$('#hmenu_sbox').outerWidth(false); var offset=$ul_pulldown_all.parent().offset(); $('#hmenu_sbox').css({'width':width, 'left':offset.left * -1}); } } else { width=$ul_pulldown_all.parent().width()+$('#hmenu_sbox').width()-$('#hmenu_sbox').outerWidth(false); $('#hmenu_sbox').css('width',width); } } //서브전체보여주기를 하는경우 smartmenu를 이용하여 모바일환경(햄버거버튼이 보이는상황)인경우는 제외시킨다 if($('ul.pulldown_all[class]').length==0 || $('ul.pulldown_all').attr('class').search(/smartmenu\d/)==-1 || $('ul.pulldown_all').parents('.oz_navbar').find('label[id^="mobile_btn"]').length==0 || $('ul.pulldown_all').parents('.oz_navbar').find('label[id^="mobile_btn"]').is(':hidden')) { $('ul.pulldown_all ul').stop(true,true).slideDown(220); } $('#hmenu_sbox').stop(true,true).slideDown(190); if($hmenu_sbox_img.length>0) { var offset=$('ul.pulldown_all li>ul').offset(); if(typeof(offset)!="undefined") $hmenu_sbox_img.css({left:offset.left-$hmenu_sbox_img.width()}).show(); } if(is_mcover) $('body').addClass('is_mcover'); } function sbox_close() { if(close_sbox==1) { $('ul.pulldown_all ul').stop(true,true).slideUp(200); $('#hmenu_sbox').stop(true,true).slideUp(220); if(is_mcover) $('body').removeClass('is_mcover'); } } } //가로서브메뉴스타일은 서브메뉴 div 이 메인 div 밖에 있기 때문에 위의 다른 스타일의 hover 처럼 처리하면 문제가 생겨 이렇게 처리했다 function roll_gnb_toggle(num, $li, $menu) { jQuery('.roll_gnbSub, .drop_gnb_v', $menu.next('div')).css('display','none'); if(num!=-1) { var $target=jQuery('ul[num="'+num+'"]', $menu.next('div')); if($target.find('li').length>0) $target.css('display','block'); } jQuery($menu).find('>li').not('.on').find('>a').removeClass('active'); if(num!=-1) $li.find('>a').addClass('active'); $menu.find('>li>a>img[on]').each(function() { $(this).attr('src',$(this).attr('off')); }); if(num!=-1) $li.find('>a>img[on]').attr('src',$li.find('>a>img').attr('on')); $menu.find('>li>a[ton]').each(function() { $(this).html($(this).attr('toff')); }); if(num!=-1) $li.find('>a[ton]').html($li.find('>a').attr('ton')); } //위의 이유로 마우스오버시 타임을 걸어 오버를 처리한다 function roll_gnb_out() { if(roll_gnb_need_init==1) { $('.roll_gnb').each(function() { var $ul=$(this); var auto_sub=$ul.attr('auto_sub'); $ul.find('>li').not('.on').find('>a').removeClass('active'); //$ul.find('>li.on>a').addClass('active'); if($ul.find('>li.on').length>0) { if(auto_sub=="0") { $('.drop_gnb_v', $ul.next('div')).css('display','none'); } else { $ul.find('>li.on').trigger('mouseover'); } } else { roll_gnb_toggle(-1, "", $ul); } }); } } //각 서브메뉴 좌우위치조정 function repos_gnbsub($ul,$sub) { var t_mainmenu_width=$ul.outerWidth(false); $ul.find('>li[num]').each(function() { var $li=$(this); var tpos=$li.position().left; var num=$li.attr('num'); var $subul=$sub.find('>ul[num="'+num+'"]'); var twidth=$subul.outerWidth(false); if((tpos + twidth) >= t_mainmenu_width) { $subul.css('right',0); } else { $subul.css('left',tpos+'px'); } }); } }); jQuery(window).focus(function() { $('.drop_gnb ul, .pulldown_all ul, #hmenu_sbox').slideUp(3); }); function in_array(id, li_list) { for(var i=0; i