From 2e8e1bc41ccfc48f4187a67d0ea0e19ec4c46a1a Mon Sep 17 00:00:00 2001 From: gnuboard Date: Mon, 22 Apr 2013 14:13:04 +0900 Subject: [PATCH] =?UTF-8?q?tail.sub.php=20=EC=9D=98=20=EB=A9=94=EB=89=B4?= =?UTF-8?q?=20=EC=9E=90=EB=B0=94=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=84=EB=8F=84=EC=9D=98=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/jquery.menu.js | 106 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 js/jquery.menu.js diff --git a/js/jquery.menu.js b/js/jquery.menu.js new file mode 100644 index 000000000..8eeea4201 --- /dev/null +++ b/js/jquery.menu.js @@ -0,0 +1,106 @@ +$(function(){ + var hide_menu = false; + var mouse_event = false; + var oldX = oldY = 0; + + $(document).mousemove(function(e) { + if(oldX == 0) { + oldX = e.pageX; + oldY = e.pageY; + } + + if(oldX != e.pageX || oldY != e.pageY) { + mouse_event = true; + } + }); + + // 주메뉴 + var $gnb = $(".gnb_1depth > a"); + $gnb.mouseover(function() { + if(mouse_event) { + $(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on"); + $(this).parent().addClass("gnb_1depth_over gnb_1depth_on"); + menu_rearrange($(this).parent()); + hide_menu = false; + } + }); + + $gnb.mouseout(function() { + hide_menu = true; + }); + + $(".gnb_1depth li").mouseover(function() { + hide_menu = false; + }); + + $(".gnb_1depth li").mouseout(function() { + hide_menu = true; + }); + + $gnb.focusin(function() { + $(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on"); + $(this).parent().addClass("gnb_1depth_over gnb_1depth_on"); + menu_rearrange($(this).parent()); + hide_menu = false; + }); + + $gnb.focusout(function() { + hide_menu = true; + }); + + $(".gnb_1depth ul a").focusin(function() { + $(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on"); + var $gnb_li = $(this).closest(".gnb_1depth").addClass("gnb_1depth_over gnb_1depth_on"); + menu_rearrange($(this).closest(".gnb_1depth")); + hide_menu = false; + }); + + $(".gnb_1depth ul a").focusout(function() { + hide_menu = true; + }); + + $('#gnb_ul>li').bind('mouseleave',function(){ + submenu_hide(); + }); + + $(document).bind('click focusin',function(){ + if(hide_menu) { + submenu_hide(); + } + }); + + function submenu_hide() { + $(".gnb_1depth").removeClass("gnb_1depth_over gnb_1depth_over2 gnb_1depth_on"); + } + + // 텍스트 리사이즈 카운트 쿠키있으면 실행 + var resize_act; + var text_resize_count = parseInt(get_cookie("ck_font_resize_count")); + if(!isNaN(text_resize_count)) { + if(text_resize_count > 0) + resize_act = "increase"; + else if(text_resize_count < 0) + resize_act = "decrease"; + + if(Math.abs(text_resize_count) > 0) + font_resize2("container", resize_act, Math.abs(text_resize_count)); + } +}); + +function menu_rearrange(el) +{ + var width = $("#gnb_ul").width(); + var left = w1 = w2 = 0; + var idx = $(".gnb_1depth").index(el); + + for(i=0; i<=idx; i++) { + w1 = $(".gnb_1depth:eq("+i+")").outerWidth(); + w2 = $(".gnb_2depth > a:eq("+i+")").outerWidth(true); + + if((left + w2) > width) { + el.removeClass("gnb_1depth_over").addClass("gnb_1depth_over2"); + } + + left += w1; + } +} \ No newline at end of file