$(function() { page.init(); }); var page = { init: function() { page.common(); }, common: function() { //bg cover $(".bg_cover > .bg_img").each(function() { $(this).parent().css("background-image","url(" + $(this).attr("src") + ")"); }); //gnb hover var gnbHeader = $("#header .header_main"); $("#gnb").hover( function() { gnbHeader.addClass("active").stop(true,true).animate({ height:380 }, 200); }, function() { gnbHeader.stop(true,true).animate({ height:60}, 200, function() { $(this).removeClass("active"); }); } ); $("#gnb .menu").hover( function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); } ); //gnb mobile �޴� var headerGnbWrap = $("#header .gnb_wrap"); var headerGnb = $("#gnb"); $("#header .btn_menu").on("click", function() { headerGnbWrap.stop(true,true).css("opacity",0).show().animate({ opacity:1 }, 200); headerGnb.stop(true,true).animate({ right:0 },200); return false; }); var headerClose = $("#header .btn_close").on("click", function() { headerGnbWrap.stop(true,true).animate({ opacity:0 }, 200, function() { $(this).hide(); }); headerGnb.stop(true,true).animate({ right:-270 },200); return false; }); $("#gnb .link").on("click", function() { if(headerClose.is(":visible")) { var getMenu = $(this).parent(); if(getMenu.hasClass("active")) { getMenu.removeClass("active").find(".sub_menu").stop(true,true).slideUp(200); } else { $("#gnb .menu.active").removeClass("active").find(".sub_menu").stop(true,true).slideUp(200); getMenu.addClass("active").find(".sub_menu").stop(true,true).slideDown(200); } return false; } }); } } $(document).ready(function(){ var dep1_menu = $("#gnb > li"); var dep2_menu = $("#gnb .sub_menu > li"); var dep3_menu = $("#gnb .sub_menu .3dep-menu > li") var dep1_menu_length = $(dep1_menu).length; var dep2_menu_length = $(dep1_menu).eq(dep1-1).find(dep2_menu).length; var subTitle = $(dep1_menu).eq(dep1-1).children('a').text(); var btnCount = 0; /* 서브 타이틀 설정 */ $("#sub-title-bg").find('.sub-visual-title').text(subTitle); /* 서브메뉴 채우기 */ var dep2menu = $(dep1_menu).eq(dep1-1).find(dep2_menu).parent('.sub_menu').html(); $("#topmenu01 .sub-menu").append(dep2menu) /* for(j=0; dep2_menu_length > j; j++){ //$("#topmenu01 .sub-menu").append('
  • '); var dep2_menu_text = $(dep1_menu).eq(dep1-1).find(dep2_menu).eq(j).children('a').text() $("#topmenu01").find('li').eq(j).find('span').text(dep2_menu_text); var dep2_menu_link = $(dep1_menu).eq(dep1-1).find(dep2_menu).eq(j).children('a').attr('href'); $("#topmenu01").find('li').eq(j).children('a').attr("href", dep2_menu_link); } */ /* 서브메뉴 선택시 on 클래스 추가 */ $("#topmenu01 .sub-menu > li").each(function(){ if($(this).find('.3dep-menu').length){ $(this).find('.3dep-menu').children('li').each(function(){ var test02 = $(this).find('a').attr('href'); if(test02.match(window.location.pathname)){ $(this).parents('li').addClass('on'); } }) } if($(this).find('a').attr("href").match(window.location.pathname)){ $(this).addClass('on'); } }) /* 2DEP BTN MENU */ if($(".btn-wrap").hasClass('btn-txt')){ $(dep1_menu.eq(dep1-1).find(dep2_menu)).each(function(){ var text = $(this).children('a').text(); var link = $(this).children('a').attr("href"); $("#content .btn-txt ul li").eq(btnCount-1).find('a').text(text); $("#content .btn-txt ul li").eq(btnCount-1).find('a').attr("href", link) /* 2DEP BTN MENU (li eq -1번째) */ if($(this).find('a').attr("href").match(window.location.pathname)){ var index = $(this).index(); if(index > 0){ $("#content .btn-txt ul li").eq(index-1).addClass('active'); } } btnCount++; })/* 3DEP BTN MENU */ }else if($(".btn-wrap").hasClass('3dep-btn-txt')){ var dep3menu = $(dep1_menu).eq(dep1-1).find(dep2_menu).eq(dep2-1).find(dep3_menu).parent('.3dep-menu').html() $(".3dep-btn-txt ul").append(dep3menu) } /*else if($(".btn-wrap").hasClass('3dep-btn-txt')){ $(dep1_menu.eq(dep1-1).find(dep2_menu).eq(dep2-1).find(dep3_menu)).each(function(){ var dep3txt = $(this).children('a').text(); var dep3link = $(this).children('a').attr("href"); console.log(dep3txt) $("#content .3dep-btn-txt ul li").eq(btnCount).find('a').text(dep3txt); $("#content .3dep-btn-txt ul li").eq(btnCount).find('a').attr("href", dep3link) btnCount++; }) } */ /* 3DEP BTN MENU ADD CLASS ACTIVE */ $(".3dep-btn-txt ul li").each(function(){ if($(this).find('a').attr("href").match(window.location.pathname)){ $(this).addClass('active'); } }) /* 클리닉 페이지 서브-서브메뉴 */ /* var dep3menu = $(dep1_menu).eq(dep1-1).find(dep2_menu).eq(dep2-1).find(dep3_menu).parent('.3dep-menu').html() $("#sub-dep3-menu > .sub-menu").append(dep3menu) */ /* $("#sub-dep3-menu ul li").each(function(){ if($(this).find('a').attr("href").match(window.location.pathname)){ $(this).addClass('active'); } })*/ })