/* * Name: KEPCO * Part: JavaScript for ui & plug-in * Author : pk.choi */ (function($){ // jQuery.noConfict(); $(document).ready(function() { /* * Part: Navigation(GNB, LNB, UTIL) * Function: * */ //GNB MAIN $('.independent .gnb .depth.depth1').on({ 'mouseenter focusin':function (event) { var $depthbox = $(this).find('.depth_box'); var tarH = $depthbox.find('.sub_meun').height(); //사이버지점 롤오버시 if($(this).find('.depth_box .sub_meun ul.menu_col').length > 0) tarH = $depthbox.find('.sub_meun li').height(); $depthbox.addClass('on'); animateSubdepth($depthbox, tarH, 600, 'easeInOutSine'); $(this).find('>a').css({'background-color':'#fafafa', 'color':'#1658d6'}); } ,'mouseleave':function (event) { var $depthbox = $(this).find('.depth_box'); $depthbox.removeClass('on'); animateSubdepth($(this).find('.depth_box'), 0, 0, null); $(this).find('>a').css({'background-color':'', 'color':''}); } ,'focusout':function (event) { $(this).find('>a').css({'background-color':'', 'color':''}); } }, '>li'); //서브뎁스 마지막 2뎁스메뉴 focusout 이벤트 $('.independent .gnb .depth.depth1 > li .sub_meun').on('focusout', 'li:last', function (event) { // console.log($(this).parent().children().length, $(this).index()); var $depthbox = $(this).parent().parent(); //사이버지점의 경우 if($(this).parent().attr('class') == 'menu_col') $depthbox = $(this).parent().parent().parent().parent(); $depthbox.removeClass('on'); animateSubdepth($depthbox, 0, 0, null); }); //GNB - SUB $('.sub .gnb .gnb_menu').on({ 'mouseenter focusin':function (event) { var $depthbox = $(this).find('.depth_box'); var tarH = $depthbox.find('.sub_depth').height() + 40; if($depthbox.find('.sub_depth .sub_meun').length == 0 && $depthbox.find('.sub_depth .pr_depth').length == 0) tarH = 0; animateSubdepth($depthbox, tarH, 600, 'easeInOutSine'); if(($(this).attr("id")) && $(this).attr("id") != ""){ fncBannerGet($(this).attr("id")); } if($(this).is('.fore')){ $(this).find('>a').not('.indep_menu').css({'background':'none', 'color':'#00dff6'}); }else{ $(this).find('>a').not('.indep_menu').css({'background-color':'#fafafa', 'color':'#1658d6'}); } if($(this).parent().find('li.on').length > 0) { $(this).parent().find('li.on').addClass('prev'); $(this).parent().find('li.on').removeClass('on'); } } ,'mouseleave focusout':function (event) { if(event.type == 'mouseleave') animateSubdepth($(this).find('.depth_box'), 0, 0, null); $(this).find('>a').not('.indep_menu').css({'background-color':'', 'color':''}); if($(this).parent().find('li.prev').length > 0) { $(this).parent().find('li.prev').addClass('on'); $(this).parent().find('li.prev').removeClass('prev'); } } }, '>li'); //서브뎁스 마지막 배너메뉴 focusout 이벤트 $('.sub .gnb .gnb_menu > li .sub_depth .banner').on('focusout',function (event) { animateSubdepth($(this).parent().parent().parent().find('.depth_box'), 0, 0, null); }); //서브뎁스 마지막 3뎁스메뉴 focusout 이벤트 $('.sub .gnb .gnb_menu > li .sub_depth').find('dl:last').children('dt, dd').on('focusout',function (event) { // console.log($(this).parent().children().length, $(this).index()); //console.log($(this).parent().next('.banner').find('a').length) //마지막 3뎁스메뉴 하위의 마지막 4뎁스메뉴이고 배너메뉴가 없다면 if($(this).index() == $(this).parent().children().length - 1 && $(this).parent().next('.banner').find('a').length == 0) animateSubdepth($(this).parent().parent().parent().parent().find('.depth_box'), 0, 0, null); }); //UTIL - 전국사업소,다국어 $('.utill_box ul.depth > li').on({ 'mouseenter focusin':function (event) { $(this).find('.layer_box').addClass('on'); } ,'mouseleave':function (event) { $(this).find('.layer_box').removeClass('on'); } }); $('.utill_box ul.depth > li').has('.layer_box').on('click', '>a', function(){ return false; }); $('.utill_box ul.depth > li').on('focusout', 'ul li:last', function (event) { $(this).parent().parent().parent().removeClass('on'); }); //GNB 서브메뉴 animate function animateSubdepth($target, $tarH, speed, easing){ $target.stop(true, false).animate({'height':$tarH}, speed, easing); } //GNB 6번째 메뉴의 넓이 조정 $("#header .gnb ul.gnb_menu li > .depth_box .sub_depth").find("dl.sub_meun:eq(5)").css({ "width":"133px" //,"border":"1px solid red" }); //검색메뉴 focusin event $('.utill_search > a').on('focusin', function (event) { suggestToggle(); }); //검색 활성화 이후 검색버튼 focusout event $('#suggestBtn').on('focusout', function (event) { suggestToggle(); }); //LNB var $clicked3dep; var $clicked4dep; $("ul.menu3dep > li").each(function(index, element) { if($(this).hasClass('on')){ $clicked3dep = $(this); } }); if(!eval($clicked3dep)){ $clicked3dep = $("ul.menu3dep > li:first-child"); } $("ul.menu4dep > li").each(function(index, element) { if($(this).hasClass('on')){ $clicked4dep = $(this); } }); if(!eval($clicked4dep)){ $clicked4dep = $("ul.menu4dep > li:first-child"); } $("ul.menu3dep > li > a").on('click',function (event) { if($(this).parent().children('ul.menu4dep').length > 0){ //기본 링크를 막는다 event.preventDefault ? event.preventDefault() : event.returnValue = false; //메뉴가 비활성화된 상태 if( $(this).next().css('visibility') == 'hidden') { $('ul.menu3dep > li').removeClass('on'); // if($clicked3dep.find('>ul').attr("class") == "menu4dep") if($clicked3dep.find('>ul').length > 0) $clicked3dep.find('>a').css({'background':'url(/kepco/front/img/com/ico_lnb_more.png) 155px center no-repeat'}); $(this).parent().addClass('on'); $(this).css({'background':'none'}); $clicked3dep = $(this).parent(); } //메뉴가 활성화된 상태 else { $(this).parent().removeClass('on'); $(this).css({'background':'url(/kepco/front/img/com/ico_lnb_more.png) 155px center no-repeat'}); } } }); $("ul.menu4dep > li > a").on('click',function (event) { if($(this).parent().children('ul.menu5dep').length > 0){ //기본 링크를 막는다 event.preventDefault ? event.preventDefault() : event.returnValue = false; //메뉴가 비활성화된 상태 if( $(this).next().css('visibility') == 'hidden') { $('ul.menu4dep > li').removeClass('on'); $clicked4dep.find('>a span').css('background','url(/kepco/front/img/com/ico_lnb_more.png) 132px center no-repeat'); $(this).parent().addClass('on'); $(this).find('span').css('background','none'); $clicked4dep = $(this).parent(); } //메뉴가 활성화된 상태 else { $(this).parent().removeClass('on'); $(this).find('span').css('background','url(/kepco/front/img/com/ico_lnb_more.png) 132px center no-repeat'); } } }); /* * Part: 이용가이드 * Function: * */ var $dh = $(document).height(); /* $("#header .utill_box .left ul.depth1 > li:eq(5)").find('a').on('click',function (event) { showUserGuide(); return false; }); */ $("#header .indep_menu a").on('click',function (event) { showUserGuide(); return false; }); function showUserGuide(){ if ($('#wrap_userguide').length > 0) { //alert('wrap_userguide exists already'); if(!$('#wrap_userguide').is(':animated')){ $('#wrap_userguide').show().stop(true, false).animate({'left':0}, 800, function(){ $(this).find('h1 a').focus(); }); } } else { //wrap_userguide does not exist - create and insert (runs 1st time only) //create HTML markup for lightbox window var lightbox = '
'; //insert lightbox HTML into page $('body').append(lightbox); $('#wrap_userguide').load("/kepco/front/html/ME/F/A/MEFAHP001.html .all_outer_useg", function() { var $wrap = $(this); $wrap.animate({'left':0}, 800, 'easeInOutSine', function(){ $wrap.find('h1 a').focus(); }); $("#gnb_useg a").on('click',function (event) { if(!$(this).hasClass('on')){ var href = this.href + " #container_useg"; $('#container_useg') .empty() .load(href, function(){ $(this).children().appendTo($('.section_useg')).prev().remove(); initEventUserGuide(); initHeightUserGuide($wrap); }); $("#gnb_useg a").removeClass('on'); $(this).addClass('on'); } return false; }); $(".btn_cls_useg .button_cur").on('click',function (event) { hideUserGuide(); return false; }); initEventUserGuide(); initHeightUserGuide($wrap); }); } } function hideUserGuide(){ $('#wrap_userguide').stop(true, false).animate({'left':'100%'}, 800, 'easeInOutSine', function(){ $(this).hide(); }); } //각 container_useg 내의 ui 이벤트 재호출 function initEventUserGuide(){ var index = 0; $('.p_tab a').on('click',function(){ $(this).parent('.p_tab').find('> a').addClass('on').parent('.p_tab').siblings('.p_tab').find('> a').removeClass('on'); $(this).parent('.p_tab').next('div.specific_info_useg').removeClass('blind').siblings('div.specific_info_useg').addClass('blind'); //console.log(this.href.substr(this.href.length - 1)) index = this.href.substr(this.href.length - 1); }) $('.btn_prev_useg a, .btn_next_useg a').on('click',function(){ if($(this).parent().attr('class') == 'btn_prev_useg'){ if(index <= 1){ index = 4; }else{ index--; } }else{ if(index > 3){ index = 1; }else{ index++; } } setSpecInfo(index); }) $('.btns_equal_h2tab a').on('click',function(){ setSpecInfo($(this).index()+1); }) function setSpecInfo($index){ $('.p_tab > a.on').removeClass('on'); $('.p_tab0'+$index+' > a').addClass('on'); $('div.specific_info_useg').addClass('blind'); $('#spec_info_useg0'+$index).removeClass('blind'); index = $index; } //서비스 상세안내 var $total_menus_useg = $('#total_menus_useg a'); var $useg_dotboxes = $('.specific_detailcon_useg .useg_dotbox04'); var $real_contentsboxes = $('.specific_detailcon_useg .real_contentsbox_useg'); $total_menus_useg.each(function(index, element) { $(this).on({ 'click':function (event) { $('.wrap_serviceinfo_useg').hide(); $('.specific_detailcon_useg').show(); $useg_dotboxes.eq(index).show(); $real_contentsboxes.eq(index).show(); } }); }); //서비스 상세안내 목록 이동버튼 $('.go_list_useg a').on('click',function(){ $('.wrap_serviceinfo_useg').show(); $('.specific_detailcon_useg').hide(); $useg_dotboxes.hide(); $real_contentsboxes.hide(); }) } //높이값 재설정 function initHeightUserGuide($obj){ var h = $dh; //console.log($dh, $obj.find('#container_useg').height() + 210); if($dh <= $obj.find('#container_useg').height() + 210){ h = $obj.find('#container_useg').height() + 210; } $obj.find('.bg_body_useg').css({ "height":h }); } });//end : document ready var fncBannerGet = function(varMenuCd){ if(varMenuCd != "" && $("#GnbBanner"+varMenuCd).html() == ""){ $.getJSON("/kepco/banner/getBanner.json", {menuCd: varMenuCd}, function (returnJson) { var thisData = returnJson.bannerVO; if(thisData){ $("#GnbBanner"+varMenuCd).html("\""+thisData.bnrContent+"\""); }else{ $("#GnbBanner"+varMenuCd).html(""); } }); } }; })(jQuery);