// 사이트업 전용 jQuery 프로그램 $(function() { // gnb, lnb 마크업 추가 $('.ABA-gnb a').append(''); $('.ABA-lnb-box a').append(''); $('.ABA-head-lnb').append('
'); $('.ABA-body-lnb').after('
'); $('.ABA-lnb').before('
').after('
'); $('.ABA-lnb-sub').before('
').after('
'); $('.ABA-gnb > li > div > ul').before('
').after('
'); $('.ABA-gnb-sub-1 > ul > li > ul').wrap('
').before('
').after('
'); // gnb var gnb_area = $('#ABA-gnb'); var gnb_wrap = $('.ABA-gnb-wrap'); var gnb_wrap_width = gnb_wrap.width(); var gnb_li = $('.ABA-gnb > li'), gnb_sub_1 = $('.ABA-gnb-sub-1'), gnb = gnb_li.parent(); var gnb_width = gnb.width(); //var gnb_li_all = $('div.ABA-gnb-sub-1 li'); var gnb_v = 'N', gnb_s = 'N', gnb_w = 'N', fix_1 = 'N', fix_2 = fix_leave = fix_w = change_w = 'N'; if (gnb_wrap.is('.GNB-v')) gnb_v = 'Y'; if (gnb_wrap.is('.GNB-s')) gnb_s = 'Y'; if (gnb_wrap.is('.GNB-w')) gnb_w = 'Y'; if (gnb_wrap.is('.fix-1')) fix_1 = 'Y'; if (gnb_wrap.is('.fix-2')) fix_2 = 'Y'; if (gnb_wrap.is('.fix-leave')) fix_leave = 'Y'; if (gnb_wrap.is('.fix-w')) fix_w = 'Y'; if (gnb_wrap.is('.change-w')) change_w = 'Y'; if (browser_type == 'IE6') gnb_s = 'N'; // 와이드 gnb 서브인 경우 마크업 추가, 본 위치 유지 if (gnb_w === 'Y') { var gnb_w_parent = gnb_wrap.attr('wide-parent'); if (gnb_w_parent === undefined) gnb_w_parent = 'content'; gnb_area.removeAttr('id'); gnb_wrap.parents('.ABA-' + gnb_w_parent + '-box').eq(0).css('margin-bottom', '0').wrap('
'); gnb_area = $('#ABA-gnb'); gnb_area.append('
'); var wide_gnb_sub_ul_wrap = $('.AB-wide-gnb-sub > .ABA-layout-align'); gnb_sub_1.each(function(index) { var obj_clone = $(this).clone(); if (change_w !== 'Y' || index === 0) obj_clone.css('display', 'block'); wide_gnb_sub_ul_wrap.append(obj_clone); }); gnb_sub_1.remove(); gnb_sub_1 = $('.ABA-gnb-sub-1'); gnb_sub_1.eq(0).addClass('AB-first'); gnb_sub_1.eq(gnb_sub_1.length-1).addClass('AB-last'); var wide_gnb_sub = $('.AB-wide-gnb-sub'); if (fix_w === 'Y') { if (change_w !== 'Y') fix_1 = 'Y'; wide_gnb_sub.css({display:'block',position:'relative'}); } } var gnb_sub_2 = $('div.ABA-gnb-sub-2'); var gnb_sub_2_ul = $('ul.ABA-gnb-sub-2-ul'); gnb_sub_2_ul.css('display', 'block'); // IE에서 보였다 사라지는 현상을 없애기 위해 style.css 파일에서 display:none 해 놓은 것을 ABA-gnb-sub-2 를 hidden 으로 감싼 후에 block 처리 함. var current_gnb = $('.AB-current-gnb'); var current_gnb_sub_1; if (gnb_v !== 'Y') current_gnb_sub_1 = gnb.find('.AB-current-gnb>.ABA-gnb-sub-1'); // gnb-v 가 아닐 때만 필요 // effect_1="slide|fade|blind|highlight|bounce|clip|drop|explode|fold|highlight|puff|pulsate|scale|shake|size,up|down|left|right,속도,지연" var effect_1 = effect_2 = effect_lnb = sub_w_fit = sub_l_fit = ''; if (mobile_device !== 'Y' || gnb_wrap.attr('effect-mobile') === 'N') { if (gnb_wrap.attr('effect-1') !== undefined) effect_1 = gnb_wrap.attr('effect-1'); if (gnb_wrap.attr('effect-2') !== undefined) effect_2 = gnb_wrap.attr('effect-2'); if (gnb_wrap.attr('effect-lnb') !== undefined) effect_lnb = gnb_wrap.attr('effect-lnb'); } effect_1 = effect_1.split(','); effect_2 = effect_2.split(','); effect_lnb = effect_lnb.split(','); // 서브1차메뉴 가로크기 보정 값 if (gnb_wrap.attr('sub-w-fit') === undefined) sub_w_fit = 0; else sub_w_fit = gnb_wrap.attr('sub-w-fit') === 'X' ? gnb_wrap.attr('sub-w-fit') : parseInt(gnb_wrap.attr('sub-w-fit')); // 서브1차메뉴 좌측위치 보정 값 if (gnb_wrap.attr('sub-l-fit') === undefined) sub_l_fit = 0; else sub_l_fit = gnb_wrap.attr('sub-l-fit') === 'X' ? gnb_wrap.attr('sub-l-fit') : parseInt(gnb_wrap.attr('sub-l-fit')); if (gnb_w === 'Y' && fix_w !== 'Y') { gnb_area.mouseleave(function() { setTimeout(function() { if (gnb_s === 'Y') wide_gnb_sub.hide_nb(); else wide_gnb_sub.css('display', 'none'); }, parseInt(effect_1[3])); }); } // GNB 메뉴 위치 설정 //var zidx = 1000; var chg_left = 0; gnb_li.each(function(index) { // GNB
  • 개수 만큼 var this_gnb_sub_1 = gnb_sub_1.eq(index); if (gnb_v === 'Y') var this_gnb_sub_1_width = $(this).width(); // gnb-sub-1 가로폭에 사용할 값 세팅 else var this_gnb_sub_1_width = this_gnb_sub_1.width(); var this_left = $(this).position().left; if (this_left > 0 && this_left + this_gnb_sub_1_width >= gnb_width) { // GNB
  • 좌측위치 + GNB 서브 가로폭 >= GNB 가로폭 (GNB 서브메뉴가 GNB 우측 영역을 벗어나는 경우) var xy = this_left + this_gnb_sub_1_width - gnb_width; // 우측 끝 선에 맞춤 if (gnb_v !== 'Y') xy += sub_w_fit; if (sub_l_fit !== 'X') this_gnb_sub_1.css('left', this_left - xy + sub_l_fit); } else { // 벗어나지 않는 경우 //if (gnb_w == 'N') { // 일반 gnb-sub if (sub_l_fit !== 'X') this_gnb_sub_1.css('left', this_left + sub_l_fit); // 상위 li left 에 맞춤 /*} else { // 와이드 gnb-sub if (chg_left == 0) chg_left = this_left; // 겹치지 않는 경우 상위 li 에 맞춤 this_gnb_sub_1.css('left', Math.max(chg_left, this_left)); // 겹치는 경우 겹치지 않도록 조정된 left 에 맞춤 if (this_gnb_sub_1_width != null || this_gnb_sub_1_width > $(this).width()) chg_left += this_gnb_sub_1_width; // 이전 ul width 값 만큼 더함 else chg_left = 0; // 이전 ul 이 없거나 작으면 0 으로 세팅하여 다음 번 루틴 때 상위 li left 값 배정 }*/ } if (gnb_v === 'Y') { $('.ABA-gnb-sub-2', this_gnb_sub_1).css({left:this_gnb_sub_1_width-10, top:0}); if (sub_w_fit !== 'X') this_gnb_sub_1.width(this_gnb_sub_1_width + sub_w_fit); } //this_gnb_sub_1.css('z-index', zidx); //zidx--; }); if (gnb_v === 'Y') { // 수직으로 펼쳐지는 GNB인 경우 /*var parent_gnb_sub_2; // 서브2차 노출 위치 설정 gnb_sub_2.each(function() { parent_gnb_sub_2 = $(this).parents('div.ABA-gnb-sub-1'); console.log(parent_gnb_sub_2.attr('class')); $(this).css('left', parent_gnb_sub_2.width()); $(this).css('top', '0'); });*/ gnb.find('div[class*=ABA-gnb-sub]').addClass('AB-live-menu'); // 펼쳐질 서브메뉴(ul) 들에 클래스 주입, 이미 펼쳐진 서브메뉴는 제외 } else { // 수평으로 펼쳐지는 GNB인 경우 current_gnb_sub_1.removeClass('AB-hidden').addClass('AB-show'); gnb.find('div[class*=ABA-gnb-sub]:not(.AB-show)').addClass('AB-live-menu'); // 펼쳐질 서브메뉴(ul) 들에 클래스 주입, 이미 펼쳐진 서브메뉴는 제외 } // 마우스 오버/아웃시 메뉴노출 설정 var gnb_a_all = gnb_area.find('li>a'); if (gnb_s === 'Y') { // 슬라이드 메뉴인 경우 gnb_a_all.mouseover(m_over_slide).focus(m_over_slide); // 각 메뉴의 링크에 마우스를 올렸을 때 m_over_slide 함수 호출 gnb.mouseleave(function() { // gnb 영역에서 마우스가 벗어났을 때 if (gnb_v === 'Y') gnb.find('div[class*=ABA-gnb-sub]').hide_nb().addClass('AB-live-menu'); else gnb.find('div[class*=ABA-gnb-sub]:not(.AB-show)').hide_nb().addClass('AB-live-menu'); if (gnb_v !== 'Y' && current_gnb_sub_1.is('.AB-show')) current_gnb_sub_1.show_nb().removeClass('AB-live-menu'); }); } else { gnb_a_all.mouseover(m_over_display).focus(m_over_display); gnb.mouseleave(function() { if (gnb_v === 'Y') gnb.find('div').css('display', 'none').addClass('AB-live-menu'); else gnb.find('div[class*=ABA-gnb-sub]:not(.AB-show)').css('display', 'none').addClass('AB-live-menu'); if (gnb_v !== 'Y' && current_gnb_sub_1.is('.AB-show')) current_gnb_sub_1.css('display', 'block').removeClass('AB-live-menu'); }); } gnb_li.mouseover(function() { // 마우스오버시 current_gnb.addClass('TCGNB'); // 현재 메뉴 복원 표시 달기 if (fix_leave !== 'Y') current_gnb.removeClass('AB-current-gnb'); // 현재 메뉴 표시 제거 $(this).addClass('AB-current-gnb'); // 오버된 메뉴에 현재 메뉴 표시 }); gnb_li.click(function() { // AJAX="Y" 활성시 필요 $('.TCGNB').removeClass('TCGNB'); $(this).addClass('TCGNB'); if (fix_leave !== 'Y') $('.AB-current-gnb').removeClass('AB-current-gnb'); $(this).addClass('AB-current-gnb'); }); gnb_li.mouseleave(function() { // 마우스 아웃시 if ($(this).is('.TCGNB')) return; // 현재 메뉴인 경우 표시 변경 없음 $(this).removeClass('AB-current-gnb'); // 현재 메뉴 표시 제거 current_gnb = $('.TCGNB'); // 복원 표시된 메뉴 찾기 current_gnb.addClass('AB-current-gnb'); // 현재 메뉴 복원 current_gnb.removeClass('TCGNB'); // 복원표시 제거 $(this).children('.ABA-gnb-sub-1').addClass('AB-live-menu'); }); // lnb var lnb_li = $('.ABA-lnb > li'), lnb_sub = $('.ABA-lnb-sub'); lnb_li.mouseover(function() { $('ul', $(this)).eq(0).show_nb(); $(this).children('a').addClass('_lnb_ov_'); }); lnb_li.mouseleave(function() { $(this).children('a').removeClass('_lnb_ov_'); }); lnb_li.click(function() { // AJAX="Y" 활성시 필요 $('.AB-current-lnb').removeClass('AB-current-lnb'); $(this).addClass('AB-current-lnb'); }); function m_over_slide() { var gnb_a = $(this); var parent_ul = gnb_a.parent('li').parent('ul'); var next_gnb_sub = gnb_a.next('div[class*=ABA-gnb-sub]:not(.AB-none)'); // gnb-sub-1(2) 는 마우스가 올려진 a 의 다음 요소로 마크업 되어 있음 if (next_gnb_sub.length <= 0) next_gnb_sub = gnb_a.next().children('div[class*=ABA-gnb-sub]'); // .ui-effects-wrapper 가 씌워진 상태 일 수 있어 한번 더 찾음 if (gnb_w !== 'Y') { var parent_ul_gnb_sub; if (fix_2 === 'Y') parent_ul_gnb_sub = parent_ul.find('div[class*=ABA-gnb-sub-1]'); else parent_ul_gnb_sub = parent_ul.find('div[class*=ABA-gnb-sub]'); if (next_gnb_sub.is('.AB-live-menu')) { parent_ul_gnb_sub.addClass('AB-live-menu'); if (fix_leave !== 'Y') parent_ul_gnb_sub.hide_nb(); next_gnb_sub.removeClass('AB-live-menu').show_nb(); } else if (!next_gnb_sub.length) { parent_ul_gnb_sub.addClass('AB-live-menu'); if (fix_leave !== 'Y') parent_ul_gnb_sub.hide_nb(); } } else { if (parent_ul.is('.ABA-gnb')) { // GNB에 마우스 올린 경우 if (change_w === 'Y') { // 서브1차가 1개씩 노출되는 설정 parent_ul_gnb_sub = $('div[class*=ABA-gnb-sub-1]', wide_gnb_sub); // 서브1차메뉴 전체 선택(동적으로 변경된 마크업을 감안) parent_ul_gnb_sub.css('display', 'none'); parent_ul_gnb_sub.eq(gnb_a.parent().index()).css('display','block'); // 마우스가 올라간 메뉴의 순번에 맞는 gnb-sub-1 을 노출 } if (wide_gnb_sub.css('display') === 'none') wide_gnb_sub.show_nb(); } else if (parent_ul.find('div[class*=ABA-gnb-sub]').length > 0) { // 서브1차에 마우스 올린 경우 if (next_gnb_sub.css('display') !== 'block') { gnb_sub_2.hide_nb(); next_gnb_sub.show_nb(); } } } } function m_over_display(){ var gnb_a = $(this); var parent_ul = gnb_a.parent('li').parent('ul'); var next_gnb_sub = gnb_a.next('div[class*=ABA-gnb-sub]'); if (gnb_w !== 'Y') { var parent_ul_gnb_sub; if (fix_2 === 'Y') parent_ul_gnb_sub = parent_ul.find('div[class*=ABA-gnb-sub-1]'); else parent_ul_gnb_sub = parent_ul.find('div[class*=ABA-gnb-sub]'); if (next_gnb_sub.is('.AB-live-menu')) { parent_ul_gnb_sub.addClass('AB-live-menu'); if (fix_leave !== 'Y') parent_ul_gnb_sub.css('display', 'none'); next_gnb_sub.removeClass('AB-live-menu').css('display', 'block'); } else if (!next_gnb_sub.length) { parent_ul_gnb_sub.addClass('AB-live-menu'); if (fix_leave !== 'Y') parent_ul_gnb_sub.css('display', 'none'); } } else { if (parent_ul.is('.ABA-gnb')) { if (change_w === 'Y') { parent_ul_gnb_sub = $('div[class*=ABA-gnb-sub-1]', wide_gnb_sub); parent_ul_gnb_sub.css('display', 'none'); parent_ul_gnb_sub.eq(gnb_a.parent().index()).css('display','block'); } if (wide_gnb_sub.css('display') === 'none') wide_gnb_sub.css('display', 'block'); } else if (parent_ul.find('div[class*=ABA-gnb-sub]').length > 0) { if (next_gnb_sub.css('display') != 'block') { gnb_sub_2.css('display', 'none'); next_gnb_sub.css('display', 'block'); } } } } $.fn.show_nb = function () { var this_obj = this; if (this_obj.css('display') !== 'none') return this; if (effect_1 != '' && effect_2 != '' && effect_lnb != '') { setTimeout(function() { if (gnb_w === 'Y' || (this_obj.is('.ABA-lnb-sub') && this_obj.prevAll('a').is('._lnb_ov_')) || (!this_obj.is('.AB-live-menu') && (this_obj.is('.ABA-gnb-sub-2') || this_obj.parent().is('.AB-current-gnb') || this_obj.parent().parent().is('.AB-current-gnb')))) { var effect_info = effect_1; if (this_obj.attr('class') !== undefined) { if (this_obj.attr('class').indexOf('ABA-gnb-sub-2') > -1) effect_info = effect_2; else if (this_obj.attr('class').indexOf('ABA-lnb-sub') > -1) effect_info = effect_lnb; } this_obj.show(effect_info[0], {direction : effect_info[1]}, parseInt(effect_info[2])); } }, parseInt(effect_1[3])); } else { this.show('fast'); } return this; } $.fn.hide_nb = function () { var this_obj = this; //console.log(this_obj); if (this_obj.length <= 0 && this_obj.css('display') === 'none') return this; if (effect_1 != '' && effect_2 != '' && effect_lnb != '') { setTimeout(function() { var effect_info = effect_1; if (this_obj.attr('class') !== undefined) { if (this_obj.attr('class').indexOf('ABA-gnb-sub-2') > -1) effect_info = effect_2; else if (this_obj.attr('class').indexOf('ABA-lnb-sub') > -1) effect_info = effect_lnb; } this_obj.hide(effect_info[0], {direction : effect_info[1]}, parseInt(effect_info[2])); }, parseInt(effect_2[3])); } else { this.hide('fast'); } return this; } // 메뉴고정 옵션 처리 if (fix_1 === 'Y') { gnb_sub_1.removeClass('AB-hidden').addClass('AB-show'); gnb.unbind("mouseleave"); gnb_li.unbind("mouseover").unbind("mouseleave"); $('.GNB-a').unbind("mouseover").unbind("focus"); } if (fix_2 === 'Y') { gnb_sub_2.removeClass('AB-hidden').addClass('AB-show'); gnb.unbind("mouseleave"); gnb_sub_1.find('li>a').unbind("mouseover").unbind("focus"); } // 새글등록버튼 클릭 시 $('.btn_new_article').css('cursor', 'pointer'); $('.btn_new_article').click( function() { $('#global_dialog').attr('title', "새 글을 등록할 코너를 선택하세요"); $('#global_dialog').load('insiter.php?design_file=article_new_pop.php').dialog( { modal: true, width:400, height:500 /*buttons: [ { text: "Ok", click: function() { $(this).dialog("close"); } } ]*/ } ); } ); });