/*------------------------------------------------------ 생성일: 2019-10-01 수정일: 2019-03-06 성 명: 최승관 내 용: 대국민 모바일서비스 고도화 - 모바일(웹)홈페이지 --------------------------------------------------------*/ var setOffset = null; var wrapScrollable; var pgSec; var id_offset_map={}; $(document).ready(function () { wrapScrollable = "nav_menu"; pgSec = "page-section"; /* top_fixed */ $(window).scroll(function () { var w_top = $(window).scrollTop(); if ( w_top > 0 ) { $(".topMenu").addClass("fixed"); }else { $(".topMenu").removeClass("fixed"); if($(".mainService").length > 0){ $(".mainService").resize(); } } }); /* menu */ $(function(){ var scroll_divs = $("."+wrapScrollable).children(); id_offset_map.first=0; scroll_divs.each(function( index ) { id_offset_map["#"+scroll_divs[index].id] =scroll_divs[index].offsetTop }); $(".nav_menu").scroll(function() { var scrollPos =$(".nav_menu").scrollTop(); $("."+pgSec).each(function(i){ var divs = $("."+pgSec); divs.each(function(idx){ if(scrollPos>=id_offset_map["#"+this.id]){ $('.nav_left .nav_depth li a.active').removeClass('active'); $('.nav_left .nav_depth li a').eq(idx).addClass('active'); } /* if(idx==0){ console.log(id_offset_map["#"+this.id]); console.log(scrollPosul>li a.active').removeClass('active'); $('.menu>ul>li a').eq(i).addClass('active'); } */ }); }).scroll(); }); /* Layer Navi */ $(".btn_allmenu, .btn.allmenu").on("click", function(){ $(".layer_nav").toggleClass("on").animate({"left":"-=200px"}, 170); $(".layer_nav").attr('tabindex', '0').focus(); $("body").css("overflow", "hidden"); $('.menuMask').show(); if(!setOffset){ var scroll_divs = $("." + wrapScrollable).children(); id_offset_map.first = 0; scroll_divs.each(function(index) { id_offset_map["#" + scroll_divs[index].id] = scroll_divs[index].offsetTop }); setOffset = true; } }); $(".btn_menu_close").on("click", function(){ $("body").css("overflow", "auto"); $(".layer_nav").toggleClass("on").animate({"left":"+=200px"}, 170); $(".btn_allmenu, .btn.allmenu").focus(); $('.menuMask').hide(); }); $('.main-button').on('click', function(e) { e.preventDefault(); var target = $(this).attr("href") $('.nav_menu').stop().animate({ scrollTop: id_offset_map[target]+1 }, 500, function() { location.hash = target-20; }); $('.nav_menu').children(target).find("h2").attr("tabindex","-1").focus(); return false; }); $(function($){ $(".page-section").attr('tabindex', '0'); var navHeight = $('.nav_left').height(); $(".nav_menu .page-section:last").css('min-height', navHeight); /*$('.main-button').click(function(){ var $focusTarget = $($(this).attr('href')); $focusTarget.focus(); })*/ }); /* 전체메뉴 아코디언 서브메뉴 */ /* $('.nav_menu h2').on('click', function() { function slideDown(target) { slideUp(); $(target).addClass('on').next().slideDown(); } function slideUp() { $('.nav_menu h2').removeClass('on').next().slideUp(); } $(this).hasClass('on') ? slideUp() : slideDown(this); }); $('.nav_menu ul li a').on('click', function() { function slideDown(target) { slideUp(); $(target).addClass('on').next().slideDown(); } function slideUp() { $('.nav_menu ul li a').removeClass('on').next().slideUp(); } $(this).hasClass('on') ? slideUp() : slideDown(this); }); */ /* 공유 검색 열기 */ $('.btn_share , .btn_close').on('click', function() { if ($('.share_list').is(':hidden')) { $('.wrap_search').removeClass('active'); $('.share_list').addClass('active'); //$('.share_list, .btn_share').addClass('active'); $('.search').hide(); } else { $('.share_list, .search, .btn_share').removeClass('active'); $('.btn_share').attr('tabindex', '0').focus(); $('.search').show(); } }); /* 검색 열기 */ $('.btn_search, .btn_close_search').on('click', function() { if ($('.wrap_search').is(':hidden')) { $('.wrap_search').addClass('active'); } else { $('.wrap_search').removeClass('active'); $('.btn_search').attr('tabindex', '0').focus(); $('.btn_search').show(); } }); /* 검색 내용 clear */ $('.wrap_search .btn_del').click(function() { $('#total_search').val(''); }); /* 네비게이션 뎁스 열기 */ $('.header_info .page_info .btn_dep_open').click(function(e) { var dep = $('.header_info .page_info .dep'); var nav = $(this).attr('data-role'); var depopen = $('.btn_dep_open'); e.preventDefault(); if($(dep).hasClass("active") ){ $('.page_info li.last a, .nav_arrow, .dep').removeClass('active'); $(dep).attr('tabindex','0').focus(); $('html, body').css({'overflow':'auto'}); $('body').css({'overflow':'auto'}); }else{ $('.header_info .page_info ul li a').removeClass('active'); $(dep).removeClass('active'); $(this).addClass('active').attr('tabindex', '0').focus(); $('#' + nav).addClass('active').attr('tabindex', '0').focus(); } if ($(dep).hasClass('active')) { $('.dep li.close .btn_dep_close').click(function(e) { $('.page_info li.last a, .nav_arrow, .dep').removeClass('active'); $(depopen).attr('tabindex','0').focus(); $('html, body').css({'overflow':'auto'}); }); $('body').css({'overflow':'auto'}); } }); /* 맨위로 가기 */ $('.btn_up').click( function() { $('html, body').animate( { scrollTop : 0 }, 400 ); $('.prev').attr('tabindex', '0').focus(); return false; }); /* 연금정보 tab 메뉴 */ $('.sub_content .tab_menu li').click(function() { $('.wrap_acco:first-child .acco_menu, .wrap_acco:first-child .acco_content').addClass('active').css('display','block'); //탭이동시 이전탭컨텐츠 초기화 var activeTab = $(this).attr('aria-controls'); $('.sub_content .tab_menu li').removeClass('active').attr('aria-selected','false'); $('.sub_content .panel').removeClass('active'); $(this).addClass('active').attr('aria-selected','true'); $('#' + activeTab).addClass('active').attr('aria-selected','true'); return false; }); /* 다중Tab menu */ $(".2depth_tabs").addClass(function(){ return 'tabm' + $(this).find("> li").length; }); $('.2depth_tabs > li > a').click(function(e){ var tab_id = $(this).attr('data-tab'); var parent = $(this).closest('div'); $(parent).find('.2depth_tabs li a').removeClass('on').removeAttr('title'); $(parent).find('.depth_tab_cont').removeClass('on'); $(this).addClass('on').attr('title', $("#tab_title_open").val()); $(parent).find("#"+tab_id).addClass('on'); e.preventDefault(); }); /* 다중Tab menu */ $(".3depth_tabs").addClass(function(){ return 'tabm' + $(this).find("> li").length; }); $('.3depth_tabs li a').click(function(e){ var tab_id = $(this).attr('data-tab'); var parent = $(this).closest('div'); $(parent).find('.3depth_tabs li a').removeClass('on').removeAttr('title'); $(parent).find('.tab_cont').removeClass('on'); $(this).addClass('on').attr('title', $("#tab_title_open").val()); $(parent).find("#"+tab_id).addClass('on'); e.preventDefault(); }); /* 3댑스Tab menu */ /* $(".3depth_tabs").addClass(function(){ return 'tabm' + $(this).find("> li").length; }); $('.3depth_tabs li a').click(function(e){ var tab_id = $(this).attr('data-tab'); var parent = $(this).closest('div'); $(parent).find('li a').removeClass('on').removeAttr('title'); $(parent).find('.tab_cont').removeClass('on'); $(this).addClass('on').attr('title', '탭열림'); $(parent).find("#"+tab_id).addClass('on'); e.preventDefault(); }); */ /* 스크롤 테이블 tabindex */ /* $('.grid_scroll').attr('tabindex', '0'); */ /* var acodian = { click: function(target) { var _self = this, ico = $('.wrap_acco .acco_menu .inner .ico'); $target = $('.acco_menu'); $('.acco_menu button').attr('aria-expanded','false'); $('.wrap_acco:first .acco_menu, .wrap_acco:first .acco_content').addClass('active'); $target.on('click', function() { var $this = $(this); if ($this.next('.acco_content').css('display') == 'none') { $('.acco_content').slideUp().focus(); _self.onremove($target); $this.addClass('active').attr('tabindex','0').focus(); $this.next().slideDown(); var scrollPosition = $('.acco_menu').offset().top; $('.acco_menu').animate({ scrollTop: scrollPosition }, 500); $(ico).attr( 'title', '열림' ); $('.acco_menu button').attr('aria-expanded','true'); $('.acco_content').attr('tabindex','0').focus(); } else { $('.acco_content').slideUp(); $('.acco_menu button').attr('aria-expanded','false'); $(ico).attr( 'title', '닫힘' ); $target.removeClass('active') _self.onremove($target); } }); }, onremove: function($target) { $target.removeClass('active'); } }; acodian.click('.acco_menu'); */ /* accordian 기존 $('.wrap_acco:first-child .acco_menu, .wrap_acco:first-child .acco_content').addClass('active'); $('.acco_menu').on('click', function() { function slideDown(target) { slideUp(); $(target).addClass('active').next().slideDown(); } function slideUp() { $('.acco_menu').removeClass('active').next().slideUp(); } $(this).hasClass('active') ? slideUp() : slideDown(this); $("html, body").animate({scrollTop:$(this).offset().top - 60}, 300); });*/ /* accordian 신규 $('.wrap_acco:first-child .acco_menu, .wrap_acco:first-child .acco_content').addClass('active'); $(".acco_menu .inner").on("click",function(){ $(this).parent().toggleClass('active'); $(this).parent().next('.acco_content').slideToggle() if ($(this).parent().hasClass("active") == true) { } else { }; $("html, body").animate({scrollTop:$(this).offset().top - 60}, 300); });*/ /* accordian 2019-04-22*/ $('.wrap_acco:first-child .acco_menu, .wrap_acco:first-child .acco_content').addClass('active'); $('.wrap_acco .acco_menu > button').off('click'); $('.wrap_acco .acco_menu > button').on("click",function(){ var title = $(this).parent('.acco_menu'); var button = $(this); if (title.hasClass('active')){ $(".wrap_acco .acco_menu").removeClass("active"); title.attr("title", $("#wrap_acco_title_close").val()); } else { title.addClass("active"); title.attr("title", $("#wrap_acco_title_open").val()); $(".wrap_acco .acco_menu").not(title).attr("title", $("#wrap_acco_title_close").val()); $(".wrap_acco .acco_menu").not(title).removeClass("active"); } $("html, body").animate({scrollTop:$(this).offset().top - 99}, 300); }); $(".wrap_acco .acco_menu").each(function(){ if($(this).hasClass("active")){ $(this).attr("title", $("#wrap_acco_title_open").val()); }else{ $(this).attr("title", $("#wrap_acco_title_close").val()); } }); /* accordian */ $(".acrd_tit .btn_more").on("click",function(){ $(this).parent().toggleClass('on'); $(this).parent().next('.acrd_cnt').slideToggle() /* .toggleClass('on') */ if ($(this).parent().hasClass("on") == true) { $(this).text($(this).attr("txt_close")); } else { $(this).text($(this).attr("txt_more")); }; $("html, body").animate({scrollTop:$(this).offset().top - 60}, 300); }); /* show Jumin2 2Sec */ $('button.btn_eye').on('click',function(){ var sThis = $(this); var oInput = $(sThis).parent().find('input'); $(oInput).attr('type','text'); $(sThis).prop("disabled",true); $(sThis).addClass("on"); setTimeout(function(){ $(oInput).attr("type","password"); $(sThis).prop("disabled",false); $(sThis).removeClass("on"); // $(sThis).focus(); // 2초후 focus 이동 }, 2000); // 잠시보여주는 시간 변경시 숫자 변경 ms }); /* Tooltip */ $(function($){ $('.wrap_tooltip .ico').click(function(){ var $self = $(this); var $target = $self.next('.wrap_tooltip .tooltip'); $target.attr("tabindex", "0").show().focus(); $target.find(".btn_close_tooltip").click(function(){ $target.removeAttr("tabindex", "0").hide(); $self.focus(); }) }) }); /* 새소식 View첨부파일 Accordian */ $(".file .btnMore button").on("click",function(){ $(this).parent().toggleClass('on'); $(this).text($(this).parent().hasClass("on")?$(this).attr("onText"):$(this).attr("offText")); $(this).append($("")); $(this).parent().next('.file .download').slideToggle() /* .toggleClass('on') */ }); /* footer 관련기관 팝업 열기 */ $('.agency .agency.type2').on('click', function() { var target = $(this).attr('href'); $(target).show(); $(target).attr('tabindex', '0').focus(); $('.agency .agency.type2 span.ico_arrow').addClass('active'); $('.mask').show(); }); /* 관련기관 팝업 닫기 */ $('.popup_btn_confirm').on('click', function() { $('.popup_wrap').hide(); $('.mask').hide(); $('.agency.type2 span.ico_arrow').removeClass('active'); $('.agency .agency.type2').attr('tabindex', '0').focus(); }); $(window).resize(function(){ $('.popup_wrap').css({ left: ($(window).width() - $('.popup_wrap').outerWidth())/2, top: ($(window).height() - $('.popup_wrap').outerHeight())/2 }); }); $(window).resize(); /*$('.sub_content').css('height', $(window).height()); $(window).resize(function(){ $('.sub_content').css('height', $(window).height()); });*/ /* input common focus, clear */ $('.wrap_input input').on('focus blur', function(){ $(this).closest('.wrap_input').toggleClass('focused'); // 1227 수정 }); $(".wrap_input").each(function() { var $inp = $(this).find("input"), $cle = $(this).find(".btn_clear"); $inp.on("input", function(){ $cle.toggle(!!this.value); }); $cle.on("touchstart click", function(e) { e.preventDefault(); $inp.val("").trigger("input").focus(); }); }); /* 레이어팝업 열기 */ $(".agency.type2").click(function(){ return false; }) $(function($){ $('a[href^="#"].agency.type2').click(function(){ $('.mask').show(); $("body").css("overflow", "hidden"); var $self = $(this); var $target = $($(this).attr('href')); $target.attr("tabindex", "0").show().focus(); $target.find(".popup_btn_confirm").click(function(){ $target.removeAttr("tabindex", "0").hide(); $self.focus(); $(this).off("click"); $('.mask').hide(); $("body").css("overflow", "auto"); }); $(window).resize(function(){ $target.css({position:'fixed'}).css({ left: ($(window).width() - $target.outerWidth())/2, top: ($(window).height() - $target.outerHeight())/2 }); }); $(window).resize(); }) }); /* 레이어팝업 열기 */ /* $('#list_view tbody tr').on('click', function() { var target = $(this).attr('href'); $('#layer_view').show(); $('#list_view tbody tr').attr('tabindex', '0').focus(); $('.mask').show(); }); $('html, body').css({'overflow':'hidden', 'height':'100%'}); $('#wrapper').on('scroll touchmove mousewheel', function(event) { event.preventDefault(); event.stopPropagation(); return false; }); $('.view_btn_content').on('click', function() { $('.view_wrap').hide(); $('.mask').hide(); $('.link_title').attr('tabindex', '0').focus(); }); $(window).resize(function(){ $('.view_wrap').css({ left: ($(window).width() - $('.view_wrap').outerWidth())/2, top: ($(window).height() - $('.view_wrap').outerHeight())/2 }); }); $(window).resize(); $('html, body').css({'overflow':'auto', 'height':'100%'}); $('#wrapper').off('scroll touchmove mousewheel'); $('#list_view tbody tr').attr('tabindex', '0').focus(); */ /* 조직 및 인원현황 상세보기 레이어팝업 */ $('#list_view .link_title').click(function(){ return false; }) $(function($){ $('#list_view .link_title').click(function(){ $('.mask').show(); $('body').css('overflow', 'hidden'); var $self = $(this); var $target = $($(this).attr('href')); $target.attr('tabindex', '0').show().focus(); $target.find('.view_btn_content .popup_btn_confirm').click(function(){ $target.removeAttr('tabindex', '0').hide(); $self.focus(); $(this).off('click'); $('.mask').hide(); $('body').css('overflow', 'auto'); }); $(window).resize(function(){ $target.css({position:'fixed'}).css({ left: ($(window).width() - $target.outerWidth())/2, top: ($(window).height() - $target.outerHeight())/2 }); }); $(window).resize(); }) }); /* 스와이프 */ /* 게시판 상세 */ $(".main_slider").slick({ dots: true, infinite: true, autoplay:true, autoplaySpeed: 3000, pauseOnFocus: true, slidesToShow: 1, slidesToScroll:1, prevArrow:false, nextArrow:false, }); $('.wrap_main_slider .play').hide(); $('.wrap_main_slider .pause').on('click', function() { $('.main_slider').slick('slickPause'); $('.wrap_main_slider .pause').hide(); $('.wrap_main_slider .play').show().focus(); }); $('.wrap_main_slider .play').on('click', function() { $('.main_slider').slick('slickPlay'); $('.wrap_main_slider .play').hide(); $('.wrap_main_slider .pause').show().focus(); }); /* main slider-상단영역 */ $(".main_swipe").slick({ dots: true, infinite: true, autoplay:true, autoplaySpeed: 3000, pauseOnFocus: true, slidesToShow: 1, slidesToScroll:1, prevArrow:false, nextArrow:false, }); $('.main_visual .play').hide(); $('.main_visual .pause').on('click', function() { $('.main_swipe').slick('slickPause'); $('.main_visual .pause').hide(); $('.main_visual .play').show().focus(); }); $('.main_visual .play').on('click', function() { $('.main_swipe').slick('slickPlay'); $('.main_visual .play').hide(); $('.main_visual .pause').show().focus(); }); /* main slider-하단영역 */ $(".btm_swipe").slick({ dots: true, infinite: true, autoplay:true, autoplaySpeed: 3000, pauseOnFocus: true, slidesToShow: 1, slidesToScroll:1, prevArrow:false, nextArrow:false, }); $('.btm_visual .play').hide(); $('.btm_visual .pause').on('click', function() { $('.btm_swipe').slick('slickPause'); $('.btm_visual .pause').hide(); $('.btm_visual .play').show().focus(); }); $('.btm_visual .play').on('click', function() { $('.btm_swipe').slick('slickPlay'); $('.btm_visual .play').hide(); $('.btm_visual .pause').show().focus(); }); /* 수급자가이드북 슬라이드 */ $(".guide_slider").slick({ dots: true, infinite: false, autoplay: false, autoplaySpeed: 3000, pauseOnFocus: false, slidesToShow: 1, slidesToScroll: 1, arrows: true, }); $('.wrap_guide_slider .play').hide(); $('.wrap_guide_slider .pause').on('click', function() { $('.guide_slider').slick('slickPause'); $('.wrap_guide_slider .pause').hide(); $('.wrap_guide_slider .play').show().focus(); }); $('.wrap_guide_slider .play').on('click', function() { $('.guide_slider').slick('slickPlay'); $('.wrap_guide_slider .play').hide(); $('.wrap_guide_slider .pause').show().focus(); }); }); /* footer 전자민원 레이어팝업 */ $('.appDown').on('click', function() { var target = $(this).attr('href'); $(target).show(); $(target).attr('tabindex', '0').focus(); $('.appDown').addClass('active'); $('.mask').show(); }); /* 관련기관 팝업 닫기 */ $('.popup_btn_confirm').on('click', function() { $('.popup_wrap').hide(); $('.mask').hide(); $('.appDown').removeClass('active'); $('.appDown').attr('tabindex', '0').focus(); }); $(window).resize(function(){ $('.popup_wrap').css({ left: ($(window).width() - $('.popup_wrap').outerWidth())/2, top: ($(window).height() - $('.popup_wrap').outerHeight())/2 }); }); $(window).resize(); $('.wrap_input input').on('focus blur', function(){ $(this).closest('.wrap_input').toggleClass('focused'); // 1227 수정 }); $(".wrap_input").each(function() { var $inp = $(this).find("input"), $cle = $(this).find(".btn_clear"); $inp.on("input", function(){ $cle.toggle(!!this.value); }); $cle.on("touchstart click", function(e) { e.preventDefault(); $inp.val("").trigger("input").focus(); }); }); /* 전자민원-레이어팝업 열기 */ $(".appDown").click(function(){ return false; }) $(function($){ $('a[href^="#"].appDown').click(function(){ $('.mask').show(); $("body").css("overflow", "hidden"); var $self = $(this); var $target = $($(this).attr('href')); $target.attr("tabindex", "0").show().focus(); $target.find(".popup_btn_confirm").click(function(){ $target.removeAttr("tabindex", "0").hide(); $self.focus(); $(this).off("click"); $('.mask').hide(); $("body").css("overflow", "auto"); }); $(window).resize(function(){ $target.css({position:'fixed'}).css({ left: ($(window).width() - $target.outerWidth())/2, top: ($(window).height() - $target.outerHeight())/2 }); }); $(window).resize(); }) }); /* footer 1355call-레이어팝업 열기 */ $(".calling").click(function(){ return false; }) $(function($){ $('a[href^="#"].calling').click(function(){ $('.mask').show(); $("body").css("overflow", "hidden"); var $self = $(this); var $target = $($(this).attr('href')); $target.attr("tabindex", "0").show().focus(); $target.find('.popup_btn_content button:nth-child(1), .popup_btn_content button:nth-child(2)').click(function(){ $target.removeAttr("tabindex", "0").hide(); $self.focus(); $(this).off("click"); $('.mask').hide(); $("body").css("overflow", "auto"); }); $(window).resize(function(){ $target.css({position:'fixed'}).css({ left: ($(window).width() - $target.outerWidth())/2, top: ($(window).height() - $target.outerHeight())/2 }); }); $(window).resize(); }) }); /* 지사찾기>오픈시 레이어팝업 */ $(function($){ $('.pop_wrap .popup_btn_content button:nth-child(1), .pop_wrap .popup_btn_content button:nth-child(2)').click(function(){ $('body').css('overflow', 'auto'); $('.popUp').hide(); var $self = $(this); var $target = $($(this).attr('href')); $target.attr('tabindex', '0').show().focus(); $target.find('.pop_wrap .popup_btn_content button:nth-child(1), .pop_wrap .popup_btn_content button:nth-child(2)').click(function(){ $target.removeAttr('tabindex', '0').hide(); $self.focus(); $(this).off('click'); $('.popUp').hide(); $('body').css('overflow', 'hidden'); }); $(window).resize(function(){ $target.css({position:'fixed'}).css({ left: ($(window).width() - $target.outerWidth())/2, top: ($(window).height() - $target.outerHeight())/2 }); }); $(window).resize(); }) }); openLayerAccess = function(layerId){ $("body").children("*").each(function(){ if ( "skip_nav" == $(this).attr("class")){ var aEle = $(this).find("a"); aEle.attr("pre_href", aEle.attr("href")); aEle.attr("href", "#"+layerId); return; } if ( layerId == $(this).attr("id")){ return; } $(this).attr("aria-hidden", "true"); $(this).find("*").each(function(){ if ( undefined !== $(this).attr("tabindex")){ $(this).attr("pre_tabindex", $(this).attr("tabindex")); } $(this).attr("tabindex", "-1"); }); }); var layerElement = $("#"+layerId); if ( undefined !== layerElement.attr("tabindex")){ layerElement.attr("pre_tabindex", layerElement.attr("tabindex")); } layerElement.attr("tabindex", "0"); layerElement.focus(); }; closeLayerAccess = function(layerId){ $("body").children("*").each(function(){ if ( "skip_nav" == $(this).attr("class")){ var aEle = $(this).find("a"); aEle.attr("href", aEle.attr("pre_href")); aEle.removeAttr("pre_href"); return; } if ( layerId == $(this).attr("id")){ return; } $(this).removeAttr("aria-hidden"); $(this).find("*").each(function(){ $(this).removeAttr("tabindex"); if ( undefined !== $(this).attr("pre_tabindex")){ $(this).attr("tabindex", $(this).attr("pre_tabindex")); $(this).removeAttr("pre_tabindex"); } }); }); var layerElement = $("#"+layerId); layerElement.removeAttr("tabindex"); if ( undefined !== layerElement.attr("pre_tabindex")){ layerElement.attr("tabindex", layerElement.attr("pre_tabindex")); layerElement.removeAttr("pre_tabindex"); } //$(".skip_nav").focus(); };