/* ---------------------------------------------------------------- - Title : 월드 프렌즈 코리아 - Author : 박은정 (Park eun jeong) - Date : 20131205 - Description : 월드 프렌즈 코리아 ---------------------------------------------------------------- */ var idx1; // 1 denth num var idx2; // 2 denth num /* 상단 GNB */ $(document).ready(function() { $header = $('#header .inner_wrap'); $gnb = $header.find('.gnb'); $gnb_depth1 = $gnb.find('.depth1'); $gnb_depth2 = $gnb.find('.depth2'); var idx; // gnb 열기 function gnb_show(idx) { $gnb_depth1.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $gnb_depth1.eq(idx).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); $gnb_depth2.hide(); $gnb_depth2.eq(idx).parent().find('.depth2').stop().animate({top:69}, 0).show(); gnb_depth2(); $header.stop().animate({ height: 127 }, 200, 'swing'); } // gnb 닫기 function gnb_hide() { $gnb_depth1.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $gnb_depth2.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $header.stop().animate({ height: 81 }, 200, 'swing', function() { $gnb_depth2.stop().animate({top:81}, 0); }); } // gnb 현재 메뉴 1 depth 활성화 function gnb_on(idx1) { if (idx1 > 0) { idx1 = idx1 - 1; $gnb_depth1.eq(idx1).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); } } // gnb 2뎁스 hover function gnb_depth2() { // gnb 2 뎁스 마우스 오버/포커스 시 $gnb_depth2.find('a').on('mouseenter focus', function() { $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); }); // gnb 2 뎁스 마우스 아웃 시 $gnb_depth2.find('a').on('mouseleave blur', function() { $gnb_depth2.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); }); } // gnb 1 뎁스 마우스 오버/포커스 시 $gnb_depth1.on('mouseenter focus', function() { idx = $(this).index('.depth1'); gnb_show(idx); }); // gnb 마우스 아웃 시 $gnb.on('mouseleave', function() { gnb_hide(); gnb_on(idx1); }); // 페이지 로딩 시 메뉴 1 depth 활성화 gnb_on(idx1); // lnb on class 추가 idx2 = idx2 - 1; var $lnb = $('.lnb').find('li'); $lnb.eq(idx2).addClass('on'); $lnb.eq(idx2).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); // lnb 마우스 오버/포커스 시 $lnb.find('a').on('mouseenter focus', function() { if (!$(this).parent().hasClass('on')) { $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); } }); // lnb 마우스 아웃 시 $lnb.find('a').on('mouseleave', function() { if (!$(this).parent().hasClass('on')) { $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); } }); // click 이벤트 clear $('a[href="#"]').on('click',function(e){e.preventDefault();}); }); /* 봉사활동 현황 상단 지도 */ function status_show() { var $valun_status = $('#header .status_map'); var $status_map = $valun_status.find('#map_area'); var $open_btn = $valun_status.find('a'); var map_h = 478; // 지도 높이 if ($status_map.height() == 0) { showMap(); $status_map.stop().animate({ height: map_h }, map_h, 'swing'); $open_btn.find('img').attr("src",function(){return $(this).attr("src").replace("_down","_up");}); } else { $status_map.stop().animate({ height: 0 }, map_h, 'swing'); $open_btn.find('img').attr("src",function(){return $(this).attr("src").replace("_up","_down");}); } } /* sns masonry 정렬 */ function masonry() { var $container = $('.sns_list'); var gutter = 0; var min_width = 253; $container.imagesLoaded(function(){ $container.masonry({ itemSelector : '.article', gutterWidth: gutter, isAnimated: true, columnWidth: function( containerWidth ) { var box_width = (((containerWidth - 2*gutter)/3) | 0) ; if (box_width < min_width) { box_width = (((containerWidth - gutter)/2) | 0); } if (box_width < min_width) { box_width = containerWidth; } $('.box').width(box_width); return box_width; } }); }); } /* 파견현황 지도 over */ function map_over() { $map = $('.map_wrap'); $map_pos = $map.find('.position'); $state_pin = $map_pos.find('li'); $state_pin.hover(function() { $(this).addClass('on'); }, function() { $(this).removeClass('on'); }); } /* 검색 옵션 체크 */ function search_checked(cont_class) { var $search_cont = $(cont_class); var $option_list = $search_cont.find('.list_type1'); var $option_depth1 = $option_list.find('.depth1'); var $option_depth2 = $option_list.find('.depth2'); var $option_check1 = $option_depth1.find('span input[type=radio]'); var $option_check2 = $option_depth2.find('input[type=radio]'); var checked; $option_check1.on('click', function() { checked = $(this).attr('checked'); var check_idx = $(this).index('.list_type1 .depth1 span input'); option_view(check_idx); }); $option_check1.each(function(e) { checked = $(this).attr('checked'); option_view(e); }); /* 2뎁스 옵션 보기 */ function option_view(e) { if (checked) { $option_depth2.css('z-index', '5'); $option_depth1.eq(e).parent().find('.depth1').removeClass('on'); $option_depth1.eq(e).parent().find('.depth2').hide(); $option_depth1.eq(e).addClass('on'); $option_depth1.eq(e).find('.depth2').show().css('z-index', '6'); } /* else { $option_depth2.css('z-index', '5'); $option_depth1.eq(e).removeClass('on'); $option_depth1.eq(e).find('.depth2').hide(); } */ } } /* 탭 보기 - 이미지 탭 버튼 */ function tab_view(idx, cont_class) { var $tab_btn = $(cont_class).find('.tab_btn li'); var $tab_cont = $(cont_class).find('.tab_cont'); $tab_btn.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $tab_btn.eq(idx).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); $tab_cont.hide(); $tab_cont.eq(idx).show(); } /* 해외봉사기관 소개 페이징 */ function overseas_paging(idx) { var page_max = idx * 5; var page_min = page_max - 5; var $overseas_contact = $('.overseas_volun_wrap').find('.organ_wrap'); var $paging_btn = $('.paging').find('li a'); $overseas_contact.hide(); $paging_btn.removeClass('on'); $paging_btn.eq(idx - 1).addClass('on'); for (i = page_min; page_min < page_max; page_min++) { $overseas_contact.eq(page_min).show(); } } /* 국기 이미지 툴팁 */ function tooltip() { $(document).ready(function() { new $.Zebra_Tooltips($('img.tooltip'), { 'background_color': '#4875c6', 'color': '#FFF' }); }); } /* 메인 자료실 탭 */ function tab_data(idx) { $data_wrap = $('.main .data'); $data_cont = $data_wrap.find('li'); $data_cont.find('h2 a img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $data_cont.eq(idx).find('h2 a img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); $data_cont.find('a.thumb').hide(); $data_cont.eq(idx).find('a.thumb').show(); } /* 메인 롤링 배너 - 20140121 수정 */ function rolling_bn(bn_cont, img_obj, btn_obj, rolling_time) { var currSlide = 0, slideTimeout, $slideshow = $(bn_cont), $slideReel = $slideshow.find(img_obj), $slideBtn = $slideshow.find(btn_obj), maxSlide = $slideReel.children().length - 1; var time = rolling_time; var $currCount = $slideshow.find('p .current'); var $allCount = $slideshow.find('p .all'); /* 기본 세팅 */ $slideReel.children().hide(); $slideReel.children().eq(0).show(); $slideBtn.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $slideBtn.children('a').eq(0).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); slideTimeout = setTimeout(function() {nextSlide('play')}, time); $currCount.empty().text(currSlide + 1); $allCount.empty().text(maxSlide + 1); $slideshow.find('.btn_play').hide(); /* 슬라이드 교체 */ function changeSlide(newSlide, direction) { clearTimeout( slideTimeout ); currSlide = newSlide; if ( currSlide > maxSlide ) currSlide = 0; else if ( currSlide < 0 ) currSlide = maxSlide; $slideReel.children().fadeOut(); $slideReel.children().eq(currSlide).fadeIn(); $slideBtn.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $slideBtn.children('a').eq(currSlide).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); if (direction == 'play') { slideTimeout = setTimeout(function() {nextSlide('play')}, time); } else if (direction == 'stop') { clearTimeout( slideTimeout ); } $currCount.empty().text(currSlide + 1); } /* 다음 슬라이드 보기 */ function nextSlide(direction) { changeSlide(currSlide + 1, direction); } /* 이전 슬라이드 보기 */ function prevSlide(direction) { var val1; val1 = currSlide - 1; if (val1 < 0) { val1 = maxSlide; } changeSlide(val1, direction); } // 현재 슬라이드 보기 function currentSlide(idx) { changeSlide(idx, 'stop'); } /* 이전 버튼 클릭 */ $slideshow.find('.btn_next').click(function(ev) { $slideshow.find('.btn_play').show(); $slideshow.find('.btn_stop').hide(); nextSlide('stop'); }); /* 다음 버튼 클릭 */ $slideshow.find('.btn_prev').click(function(ev) { $slideshow.find('.btn_play').show(); $slideshow.find('.btn_stop').hide(); prevSlide('stop'); }); /* 재생 버튼 클릭 */ $slideshow.find('.btn_play').click(function(ev) { $slideshow.find('.btn_stop').show(); $slideshow.find('.btn_play').hide(); slideTimeout = setTimeout(function() {nextSlide('play')}, time); }); /* 정지 버튼 클릭 */ $slideshow.find('.btn_stop').click(function(ev) { $slideshow.find('.btn_play').show(); $slideshow.find('.btn_stop').hide(); clearTimeout( slideTimeout ); }); /* 페이징 버튼 클릭 */ $slideBtn.find('a').click(function() { var btn_idx = $(this).index(); $slideBtn.find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); currentSlide(btn_idx); }); /* 버튼 마우스 오버 */ $slideshow.find('.btn_next, .btn_prev').mouseenter(function(ev) { $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_off","_on");}); }); $slideshow.find('.btn_next, .btn_prev').mouseleave(function(ev) { $(this).find('img').attr("src",function(){return $(this).attr("src").replace("_on","_off");}); }); } /* 위로 가기 */ function scroll_top() { $('html, body').scrollTop(0); } /* 지도 pin 마우스 오버 */ function map_pin() { var $map = $('.map_wrap'); var $pin = $map.find('.position li'); // pin 마우스 오버/포커스 시 $pin.on('mouseenter focus', function() { $(this).css('z-index', '10'); }); // pin 마우스 아웃 시 $pin.on('mouseleave', function() { $pin.css('z-index', '5'); }); } // 월드 프렌즈 활동 국가 탭 사이즈 - 20140109 추가 function active_state() { var $state_tab = $('.volun_active_wrap .article_list .state'); $state_tab.find('span').each(function() { var tab_width = $(this).width(); $(this).width(tab_width); }); } function showMap() { window.frames["iframeWorld"].location.href="/eng/dispatchInfo/eng.voluntary.dispatch_main_top/stateList.do"; }