/** * @File Name : jq.js * @Description : jQuery 코드가 들어갈 것이다. (jQuery 아니더라도) 새로 만든 간단한 코드가 들어가기도 한다. * @Modification Information *
* 수정일 | 수정자 | 수정내용 * 2015.06.19 | 김소화 | 최초 등록 * 2015.10.20 | 김소화 | 터치슬라이드 추가 gesture: true * 2015.10.20 | 김소화 | jQchangePic3 수정 * 2016.06.27.| 조대환 | 담당자 요청으로 메인비주얼(#vpr1) 시간 7 > 2초로 수정 ** @author 디자인팀 김소화 * @since 2015.06.19 * * @Copyright (C) IACTS.CO.KR All rights reserved. */ /* ◇◆ Base ◇◆ */ /* [~IE7] console 에러 방지 */ if(window.console == undefined){console = {log:function(){}};} /* Mobile | Desktop 구분 */ if(window.orientation != undefined){$('html').addClass('Mobile');}else{$('html').addClass('Desktop');} /* [Mobile]툴바감춤 */ if(window.addEventListener){window.addEventListener('load',function(){setTimeout(scrollTo,0,0,1);},false);} /** ◇◆ UA구분(IE version).20140901.MoonYoungShin. * Result) [IE8] [IE9] [IE11] */ $.browser = {}; (function getIEVerSetClass(){ // Returns the version of Internet Explorer or a -1 for other browsers. $.browser.msie = false; $.browser.rv = -1; if(navigator.appName == 'Microsoft Internet Explorer'){ $.browser.msie = true; $.browser.ua = navigator.userAgent; $.browser.re = new RegExp('MSIE ([0-9]{1,}[\.0-9]{0,})'); if($.browser.re.exec($.browser.ua) != null){ $.browser.rv = parseFloat( RegExp.$1 ); } $('html').addClass('IE' + $.browser.rv); // IE7, IE8, IE9, IE10 (IE11~ 제외!) } if($.browser.rv <= 8 && $.browser.rv > -1){ $('html').addClass('lteIE8'); // ~IE8 }else{ $('html').addClass('gteIE9orSUA'); // IE9~, Standard User Agent } }()); /* ◇◆◇◆◇◆◇◆◇◆◇◆◇◆◇◆ */ $(window).on('load', function(){ // 문서와 이미지 모두 로드되면 실행. // backgroundSize[IE6~8]Support.20141016. * ☆required: jquery.backgroundSize.js $('.bsContain').css({backgroundSize: 'contain'}); $('.bsCover').css({backgroundSize: 'cover'}); }); /* /$(window).on('load', function(){}); */ /* ◇◆◇◆◇◆◇◆◇◆◇◆◇◆◇◆ */ jQuery(function($){ $(function(){ // DOM ready 실행 함수를 중첩하면 여기 안 코드는 밖보다 나중에 실행. }); /* /$(function(){}); */ /* ◇◆ 함수.메소드 실행 ◇◆◇◆◇◆ */ // >> 마크업 바로 아래 실행 코드 추가 권장! addOnNav(); // 현재활성1·2·3·4차 addOnNav2(); // 모바일 메뉴 현재활성1·2·3·4차 jQscrollTouch('.scroll1wrap', {setDesktop: false}); jQscrollTouch('.scroll1wrap1all1', {setDesktop: true}); $('#life2c1').jQmPrevNext1(); $('#tour2c1').jQmPrevNext1(); //모바일버전에서 사이드 바가 나왔다가 들어갈때 #wrap의 z-index값 변경 $('#sidebar #sidebar1top .toggle').click(function(){ if($('#sidebar1c').css("display") == "none"){ $('#wrap').css('z-index','40'); } else{ $('#wrap').css('z-index','20'); } }); $("iframe").each(function() {$(this).attr("frameborder", '0');}); /* MainPage */ $('#vpr1').jQmPR1({interval:5000, mTabindex:'-1', gesture: true, threshold: 10}); $('#vpr2').jQmPR1({interval:2000, mTabindex:'-1', gesture: true, threshold: 10}); $('#vpr3').jQmPR1({interval:2000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr1c1').jQmPR1({interval:2000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr1c2').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr2c1').jQmPR1({interval:2000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr2c2').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr3c1').jQmPR1({interval:2000, mTabindex:'-1', gesture: true, threshold: 10}); $('#pr3c2').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#quickLink1s1').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#quickLink1s2').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#quickLink1s3').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('#tourSite1').jQmPR1({interval:4000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#banner1').jQmPR1({interval:6666, mTabindex:'-1', gesture: true, threshold: 10}); $('#recommend1').jQmPR1({interval:6666, mTabindex:'-1', autoFlag: false, gesture: true, threshold: 10}); $('#tourMenu1').jQmPR1({interval:6666, mTabindex:'-1', autoFlag: false, gesture: true, threshold: 10}); $('.quicIcon1').jQmPrevNext1(); $('#festival1').jQmPR1({interval:4000, mTabindex:'-1', gesture: true, threshold: 10}); $('.tourVisual1').jQmPR1({interval:2000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#tour1around1s1').jQmPR1({interval:2000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#tour1around1s2').jQmPR1({interval:2000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#tour1around1s3').jQmPR1({interval:2000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#event1').jQmPR1({interval:2000, autoFlag: false, mTabindex:'-1', gesture: true, threshold: 10}); $('#mNews1').jQmPR1({interval:6666, mTabindex:'-1', gesture: true, threshold: 10}); /* SubPages */ $('.selectDate1').jQmPrevNext1(); $('.btn1.toggle2').on('click', function(e){ var that = $(this).attr('href'); // 토글 대상 e.preventDefault(); $('.supportList1 .link1').removeClass('on'); $('.supportList1s').slideUp(); $(this).parent().addClass('on'); if($(this).parent().parent().parent().find(that).css("display") == "none"){ $(this).parent().parent().parent().find(that).slideDown('fast'); } else{ $('.supportList1 .link1').removeClass('on'); } return false; }); //모바일 전화걸기 $('.calling').each(function(){ var url = $(this).text(); var clone = $(''+url+''); if($('html').hasClass('Mobile')){ $(this).empty().append(clone); } }); /* 관광지 상세보기 탭 자동조절 */ $(function(){ var col = $('.tour1info2 h2>a').length; if(col <= 5){ $('.tour1info2 h2>a').parent().parent().addClass('col-'+col); } else { $('.tour1info2 h2>a').parent().parent().addClass('col-5'); } }); $(window).on('load', function(){ var position = $("#timetable1schedule1").offset(); if($('#timetable1schedule1 > .schedule1list1 > .lst1 > li').hasClass('li1')){ $('html,body').animate({ scrollTop : position.top }, 100); // 이동 }else{} }); /* 플로우챠트 마지막은 화살표 없애기. (2열에서) */ $(window).on('load', function(){ $('.flowchart1 li:last-child').addClass('last'); }); /* 아이프레임 보더 없애기 */ $("iframe").each(function() { $(this).attr("frameborder", '0'); }); // N/A /* ◇◆ 바로 실행 .doAction ◇◆◇◆◇◆ */ (function doTapping(selector){ $('.tapping').each(function(){ var $this = $(this); // 토글 버튼 var $that = $($this.attr('href')); // 토글 대상 // 토글 클릭 $this.on('click', function(){ $('.townInfo1s').removeClass('on').hide(); $that.addClass('on').show(); return false; }); }); })(); /* ☆Fix z-index youtube video embedding */ $('iframe.youtube, #video1 iframe, .bbs1video1 iframe').each(function(){ var url = $(this).attr("src"); $(this).attr("src", url+"?wmode=opaque"); }); /** ◇◆ 선택메뉴.20141022.MoonYoungShin. doToggle() 토대로 개발. * Use1) See Markup Code … */ (function doSelectmenu1(selector){ $('.selectmenu1').each(function(){ var $this = $('.title .a1', this); // 제목+여닫기 버튼 var $that = $($this.attr('href')); // 표적(옵션 블록) var $title= $('.t1', $this); // 제목 텍스트 var $option = $('.option .a1', $that); // 옵션 요소 var thatOn = 0; // 옵션 블록 focusout 고도화 $this.parent().removeClass('on'); $that.removeClass('on').hide(); $this.on('click', function(){ $this.parent().toggleClass('on'); $that.toggleClass('on'); $that.toggle(); $this.focus(); // 제목으로 초점 보내기 return false; }); $option.on('click', function(){ $(this).parent().siblings().removeClass('on'); $(this).parent().addClass('on'); $title.text($(this).text()); // 제목을 선택한 옵션으로.. $this.triggerHandler('click'); thatOn = 1; // 옵션 클릭으로 옵션 블록 focusout 되면서 0 으로 변한 값을 1 로 바꿔준다, $this.triggerHandler('click'); 가 재실행되는 것을 방지한다. return false; }); $that.on('focusout', function(){ thatOn = 0; setTimeout(function(){ if(!thatOn){ // 옵션 블록 focusin 되거나, 옵션 클릭으로 focusout 되는 경우는 실행안한다. $this.triggerHandler('click'); } }, 50); return false; }); $that.on('focusin', function(){ thatOn = 1; return false; }); }); })(); /** ◇◆ 토글.20140722.MoonYoungShin. 고도화. 효과 지정 가능. 20140929.설명보강. * Use1) 통합 검색 * ☆ toggle 이 탭처럼 동작하려면 (내가 on 이면 형제는 off), 나와 형제가 클래스 값이 각각 1개이고 같아야 한다. 클래스 값이 2개 이상되면 수정필요! * 토글 메뉴와 대상의 부모가 같아야 한다. * 적용 콘텐츠: 패밀리 사이트, .. * Use2) … */ (function doToggle(selector){ $('.toggle').each(function(){ var $this = $(this); // 토글 버튼 var $that = $($this.attr('href')); // 토글 대상 var $sib = $that.parent().siblings('.' + $that.parent().attr('class')); // 형제 콘텐츠. $this 말고 $that 에서 찾아야 정확하다. // 초기화. 토글 버튼 비활성, 대상 감추기 $this.removeClass('on'); $that.removeClass('on').hide(); // 토글 클릭 $this.on('click', function(){ if($this.hasClass('donot')) return false; // 토글 동작 원치 않는 경우 // 형제 콘텐츠 닫기 $sib.each(function(){ $(this).removeClass('on'); var $this = $('.toggle', this); // 형제 콘텐츠 토글 버튼 var $that = $($this.attr('href')); // 형제 콘텐츠 토글 대상 $this.removeClass('on'); $that.removeClass('on').hide(); }); // 내 토글 동작 $this.toggleClass('on'); $that.toggleClass('on'); if($this.hasClass('showhide')){ $that.toggle(); }else if($this.hasClass('slide')){ $that.slideToggle(200, 'swing', function(){}); }else if($this.hasClass('fade')){ $that.fadeToggle(100, 'swing', function(){}); }else if($this.hasClass('animate1')){ $that.animate({ left: 'toggle', top: 'toggle', width: 'toggle', height: 'toggle', opacity: 'toggle' }, 200, function(){}); }else{ // 기본 토글 //$that.toggle('swing'); // $that.toggle(400, 'swing'); 과 같다. $that.toggle(); } $this.parent().find('.toggle').focus(); // 초점 보내기 return false; }); // 닫기 클릭 $('.close', $that).on('click', function(){ var closeHref = $(this).attr('href'); if($this.attr('href') == closeHref){ $this.triggerHandler('click'); } return false; }); }); })(); /** 글자크기조절.20140718.MoonYoungShin. */ (function setFontSize(ss, os){ // subject selector, object selector var $this = (ss)? $(ss): $('#fontsize1'); var $that = (os)? $(os): $('#body_content'); $('.plus', $this).on('click', function(){ $that.css('fontSize','1.4em'); return false; }); $('.minus', $this).on('click', function(){ $that.css('fontSize','1em'); return false; }); })(); /** 현재위치.20140718.MoonYoungShin. */ (function onLocation(ss){ // subject selector, object selector var $this = (ss)? $(ss): $('#location1'); $('a', $this).last().addClass('on'); })(); /** 검색창 설정 * tablet에서 숨었다 보였다 함. **/ $(window).on('load resize', function(){ var winWidth = $(window).width(); if( 767 > winWidth){ $('#search1c').css('display', 'block'); } else if ( winWidth >= 768 ){ $('#search1c').css('display', 'none'); } }); /** jQmTnbD4a1() 주메뉴(전체메뉴)1·2·3·4차. * For tablet, mobile * ☆required: jquery-1.8.0.min.js 이상, jquery.easing.1.3.js 'easeInOutQuad' **/ $.fn.jQmTnbD4a1 = function(options){ if(!this) return false; var config = { that: '#tnb1c', // 여닫는 대상 콘텐츠 선택자 home: 'a.b1.gohome', // 홈 아이콘 메뉴 action: '' // 예비 }; $.extend(config,options); return this.each(function(){ var $this = $(this); // 전체 메뉴 래퍼 var $that = $(config.that); var $home = $(config.home, $this); $that.width = $that.width(); $('div.d1 a+div', $this).prev().parent().addClass('hasSubNav'); $('div.d1>ul>li>a', $this).click(function(){ // 1차메뉴 클릭 $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li').removeClass('on'); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('hasSubNav')){ $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li>a').next('div').slideUp(100, 'swing', function(){}); $(this).next('div').slideToggle(100, 'swing', function(){}); return false; } }); $('div.d2>ul>li>a', $this).on('click', function(){ // 2차메뉴 클릭 $(this).parent().siblings().removeClass('on'); $(this).parent().toggleClass('on'); $('div.d2>ul>li').css('margin-top',''); if($(this).parent().hasClass('hasSubNav')){ $(this).parent('li').siblings().find('>a').next('div').slideUp(100, 'swing', function(){}); //$(this).next('div').slideToggle(100, 'swing', function(){}); // 2차메뉴를 클릭하여 3차메뉴가 열릴때 아래에 3차메뉴들은 d3Height 수만큼 밀림 if($(this).next('div').css("display") == "none"){ var d3Height = $(this).next('div.d3').height(); var thisIndex = $(this).parent('li').index() + 1; $(this).next('div').slideDown(100, 'swing', function(){}); // 홀수와 짝수에 따라서 아래로 밀리는 li가 달라짐. if (thisIndex % 2 == 1) { $(this).parent('li').next().next().css('margin-top',d3Height); $(this).parent('li').next().next().next().css('margin-top',d3Height); } else { $(this).parent('li').next().css('margin-top',d3Height); $(this).parent('li').next().next().css('margin-top',d3Height); } } else { $(this).next('div').slideUp(100, 'swing', function(){}); $(this).parent('li').next().css('margin-top',''); $(this).parent('li').next().next().css('margin-top',''); $(this).parent('li').next().next().next().css('margin-top',''); } return false; } }); $('div.d3>ul>li>a', $this).on('click', function(){ // 3차메뉴 클릭 var d3Height = $(this).parent('li').parent('ul').parent('div.d3').height(); var d4Legnth =$(this).next('div').find('ul>li').length; var d4Height = (d4Legnth - 0.5) / 2; var d4Height2 = Math.ceil(d4Height); var d4Height3 = d4Height2 * 28; var dSum = d3Height + d4Height3; var dSum2 = d3Height - d4Height3; var thisIndex = $(this).parent('li').parent('ul').parent('div.d3').parent('li').index() + 1; //$(this).parent('li').siblings().find('>a').next('div').slideUp(100, 'swing', function(){}); $(this).parent().siblings().removeClass('on'); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('hasSubNav')){ if($(this).next('div').css("display") == "none"){ $(this).next('div').slideDown(100, 'swing', function(){}); // 홀수와 짝수에 따라서 아래로 밀리는 li가 달라짐. if (thisIndex % 2 == 1) { $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().css('margin-top',dSum); $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().next().css('margin-top',dSum); } else { $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().css('margin-top',dSum); $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().css('margin-top',dSum); } } else { $(this).next('div').slideUp(100, 'swing', function(){}); if (thisIndex % 2 == 1) { $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().css('margin-top',dSum2); $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().next().css('margin-top',dSum2); } else { $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().css('margin-top',dSum2); $(this).parent('li').parent('ul').parent('div.d3').parent('li').next().next().css('margin-top',dSum2); } } return false; } }); }); } $('#mTnb1').jQmTnbD4a1(); /** jQmTnbD2a1() 주메뉴(전체메뉴)1·2차. * For desktop * ☆required: jquery-1.8.0.min.js 이상, jquery.easing.1.3.js 'easeInOutQuad' **/ $.fn.jQmTnbD2a1 = function(options){ if(!this) return false; var config = { that: '#tnb1c', // 여닫는 대상 콘텐츠 선택자 home: 'a.b1.gohome', // 홈 아이콘 메뉴 action: '' // 예비 }; $.extend(config,options); return this.each(function(){ var $this = $(this); // 전체 메뉴 래퍼 var $that = $(config.that); var $home = $(config.home, $this); $that.width = $that.width(); //$('div.d1 a+div', $this).prev().parent().addClass('hasSubNav'); //$('div.d1>ul>li>a', $this).click(function(){ // 1차메뉴 클릭 // $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li').removeClass('on'); // $(this).parent().toggleClass('on'); // if($(this).parent().hasClass('hasSubNav')){ // $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li>a').next('div').slideUp(100, 'swing', function(){}); // $(this).next('div').slideToggle(100, 'swing', function(){}); // return false; // } //}); $('div.d1 a+div', $this).prev().parent().addClass('hasSubNav'); $('div.d1>ul>li>a', $this).mouseenter(function(){ $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li').removeClass('on'); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('hasSubNav')){ $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li>a').next('div').slideUp(100, 'swing', function(){}); $(this).next('div').slideToggle(100, 'swing', function(){}); return false; } }); $('#tnb1').mouseleave(function(){ $('#tnb1 div.d1 > ul > li').removeClass('on'); $('#tnb1 div.d2').slideUp(100, 'swing', function(){}); }); $('div.d1>ul>li>a', $this).focusin(function(){ // 접근성 $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li').removeClass('on'); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('hasSubNav')){ $(this).parent().parent().parent().parent().siblings().find('div.d1>ul>li>a').next('div').slideUp(100, 'swing', function(){}); $(this).next('div').slideToggle(100, 'swing', function(){}); return false; } }); $('#info2c1 li.m4 a', $this).focusout(function(){ // 접근성 $('#tnb1 div.d1 > ul > li').removeClass('on'); $('#tnb1 div.d2').slideUp(100, 'swing', function(){}); }); }); } $('#tnb1').jQmTnbD2a1(); /** jQmSnbD3() 부메뉴2·3·4차.20140722.MoonYoungShin. * !!required: jquery-1.8.0.min.js 이상, jquery.easing.1.3.js 'easeInOutQuad' * 2차메뉴 누르면 3(,4차)메뉴 우로 슬라이드 * 3차메뉴 누르면 4차메뉴 하로 슬라이드 * 하위메뉴 없으면 해당 페이지로 이동 * 3(,4차)메뉴 에서 < 누르면 1(,2차)메뉴 나타남 * 홈 아이콘 누르면 홈페이지로 이동 * × 아이콘 주메뉴 접힘. /---- * Task1) action 고도화 */ function isMobile() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); } $.fn.jQmSnbD3 = function(options){ if(!this) return false; var config = { action: '' // 예비 }; $.extend(config,options); return this.each(function(){ var $this = $(this); // 부메뉴 메뉴 래퍼 $('div.d2 a+div', $this).prev().parent().addClass('hasSubNav'); $('div.d2>ul>li>a', $this).click(function(){ // 2차메뉴 클릭 $(this).parent().siblings().removeClass('on'); $(this).parent().toggleClass('on'); if (isMobile()) { if($(this).parent().hasClass('hasSubNav')){ return false; } } }); $('div.d3>ul>li>a', $this).on('click', function(){ // 3차메뉴 클릭 $(this).parent().siblings().removeClass('on'); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('hasSubNav')){ return false; } }); }); } $('#snb1').jQmSnbD3(); /** ◇◆ 달력셀클릭.아래TR생성.수정. 김소화20150903. * Use)