/** * @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)
... */ /* (doTimeTableCell = function(){ var $this = $('.timetable2 table.calendar td>.cell'); var $that = $('.menu', $this); var $target = $(''); var toggleTableCell = function(){ // 대상(메뉴목록) 안보이면 기능 제거 $that.filter(':visible').closest('tr').next('tr.target').detach().find('.date, .menu').empty(); $that.filter(':visible').closest('.cell').attr({ tabindex: '' // -1 하니 [CR] 에서 초점 보임. }).css({ cursor: 'auto' }).off().find('.deco1').detach(); // 대상(메뉴목록) 보이면 기능 동작 $that.filter(':hidden').closest('.cell').attr({ tabindex: '0' }).css({ cursor: 'pointer' }).off().on('click keypress', function(){ // ☆ 키보드 누름에도 동작위해 keypress 추가 // 토글) 날짜 비교로 활성 구분한다. if( $('>td .date', $target).text() != $('.date', $(this)).text() ){ $(this).closest('tr').after($target); $('>td .date', $target).text( $('.date', $(this)).text() ); $('>td .menu', $target).replaceWith( $('.menu', $(this)).clone() ); }else{ $target.detach().find('.date, .menu').empty(); } return false; }); }; $(window).on('load resize', function(){ toggleTableCell(); }); })(); */ (doTimeTableCell = function(){ $('.toggle3').each(function(){ var $this = $(this); //버튼 var $that = $($this.next()); // 대상 var $target = $(''); $this.on('click', function(){ $('tr.target').remove();// 열린tr.target 제거 $('div.cell.on').removeClass('on');// 제거 $this.parent().addClass('on'); $this.closest('tr').after($target); $('>td .toggle3Cont', $target).replaceWith( $that.clone() ); return false; }); }); })(); /** 스크롤화면상단.20140728.MoonYoungShin. * 가변폭까지 고려하니 땀나! */ /* (function(){ var $this = $('#seen1'); // 위치크기조정할거 if(!$this.length) return false; // 20140728. 메인,.. 없으므로 아래 실행 안함. var $sidebar = $('#sidebar'); var $head = $('#head'); $this.originOffsetTop = $this.offset().top; $(window).on('scroll', function(){ $head.realHeight = $head.height(); // #head 위치가 고정(fixed) 높이 고려 if( ($this.originOffsetTop - $head.realHeight) < $(this).scrollTop()){ $this.css({ width: $sidebar.css('width'), // % 라도 px 값 반환. [IE]1px 오차 발생할 수 있음. position: 'fixed', top: 0 + $head.realHeight + 'px' }); }else{ $this.css({ position: 'relative', top: 'auto', width: 'auto' }); } $(':hidden', $this).css({ // ★☆할일 position: 'relative', top: 'auto', width: 'auto' }); }); $(window).on('resize', function(){ $this.originOffsetTop = $this.offset().top; $this.css({ width: $sidebar.css('width') }); }); })(); */ }); /* /jQuery(function($){})(); */ /* ◇◆ Plugin ◇◆◇◆◇◆◇◆◇◆◇◆◇◆◇◆ */ /** ◇◆ PictureRotator.20140814.MoonYoungShin. ☆20150202. * 20150202. [Android4.4.x~] 링크 이동 먹통 오류 해결. * !!required: jquery-1.8.0.min.js 이상, jquery.easing.1.3.js * 반응형 적용 문제 해결. 창 조절에 동작값 다시 구하고 효과별 액션 분기. * 현재페이지/전체페이지 추가 * 아코디언 효과 추가. * 순환 콘텐츠 고도화.. fade, slide 효과 벌레퇴치. * 콘텐츠와 순번이 섞여있을 때 고려 : .mContC>.m 와 .mCont>.m 일 경우 모두 고려함. * .mContC 키보드 운용 바르게 동작하도록 수정. 추가 . mNum 순번 탭 없을 경우 고려 * 세로 슬라이드 추가, mNum, z-index, 키보드 운용할 때.. 즉시 변경으로 해결 * 콘텐츠 a 에 focus 시 콘텐츠 보이며 운용 가능. * 순번 탭 포커싱 선택 추가 * 맨앞뒤 이후 동작 같은 방향으로.. * touch, drag? 콘텐츠에 a 요소가 있으면 touch 는 괜찮지만.. drag 는 동작하지 않는다. * .mCont{position:absolute;} 이면.. 이전, 다음 콘텐츠가 touchmove 에 동작한다. .mCont{position:absolute;} 아니면.. touchend 시 이전, 다음 액션. * addBack() 추가하여 $this 오버 아웃 추가 * 새 활성 콘텐츠 내용 없으면.. 코드 만들어 불러온다. ★☆개발필요! ajax! 만들어진 코드 가져오도록.. /---- * Task.A) 아코디언 키보드 후진. * Task.B) Ajax, loading… 텍스트는 즉시 부르고, 이미지는 전환 완료되면 부른다. ★☆개발필요! ajax! * Task.C) 멀티뷰 페이드, 슬라이드는 보류. (대안! mContC 안에 멀티 콘텐츠 넣기) 기능 재검토 후에도 복잡하면 제거하자. */ $.fn.jQmPR1 = function(options){ if(!this) return false; var config = { interval: 6000, // 간격 밀리초 autoFlag: true, // true: 정지 버튼 클릭 안한 상태, false: 클릭한 상태 effect: null, // 효과 initEffect: null, // 최초 실행 효과 .20140626 duration: 400, // 효과 동작시간 밀리초 delay: 0, // 효과 지연시간 zIndex: 0, // 콘텐츠 겹칠 때 이용 //onnum: parseInt(location.hash.charAt(location.hash.length-1)) || 1, // 초기활성값=#끝수. 실무에는 글쎄요.. onnum: 1, // 초기활성값 oldonnum: 0, // 최초 콘텐츠 없는 상태 easing: 'swing', // 동작 완화. jswing 은 jquery.easing.1.3.js 필요! preAct: 1, // 1: 1번째 액션에서만 실행, 2: 2번째.., .. viewNum: 1, // 멀티뷰. 단수 표시만 가능 (순번은 absolute 로 개별 위치 지정) //frontback: 1, // 1: 정방향(→↓), -1: 역방향(←↑) 감지에 이용 (임의 지정은 하지말자) vertical: 0, // 0: 가로방향 동작, 1: 세로방향 동작 mTabindex: 0, // -1: 순번 탭 포커싱 안함, 0: 함. // DOM Selectors mView: '.mView', // 뷰영역 mCont: '>.mCont', // 콘텐츠 그룹 mContC: '>.mContC', // 단위콘텐츠. 아코디언 효과에는 자식으로 순번 앵커와 진짜콘텐츠를 분리한다. c: '', // 진짜콘텐츠가 .mContC>.c 이면 '>.c' 를 할당하라. 순번 앵커 .mContC>.m 를 추가할 수 있다. mNum: '.mNum', // 순번 페이징 그룹 m: '.m', // 단위 순번은 .mNum>.m 이다. prev: '.mControl .prev', // 이전 버튼 next: '.mControl .next', // 다음 버튼 stop: '.mControl .stop', // (일시)정지 버튼 play: '.mControl .play', // 재생 버튼 pageOn: '.mPage .on', // 현재페이지 pageTotal: '.mPage .total', // 전체페이지 mNumEvent: 'click', // 순번 이벤트. 아코디언 효과에는 'focusin mouseenter click' .20140626 gesture: false, // true: 터치이벤트할당 threshold: 40, // 터치 무브가 값px 이상일 때 반응 ajaxDataUri: '/main/v1html.xml' // ★☆개발필요! ajax! 동적으로 콘텐츠 불러오기 주소로 사용할거다. }; $.extend(config, options); return this.each(function(){ var $this = $(this); $this.effect = config.effect; // 효과 기억 위해! if($this.effect == 'accordion'){ config.initEffect = 'accordion'; } //DOM $this.mView = $(config.mView, $this); $this.mCont = $(config.mCont, $this.mView); $this.mContC = $(config.mContC, $this.mCont); // '>.mContC' $this.mContCc = $(config.c, $this.mContC); // '>.mContC>.c' // 아코디언용 $this.mContCm = $(config.m, $this.mContC); // '>.mContC>.m' // 아코디언용 $this.mNum = $(config.mNum, $this); $this.prev = $(config.prev, $this); $this.next = $(config.next, $this); $this.stop = $(config.stop, $this); $this.play = $(config.play, $this); $this.pageOn = $(config.pageOn, $this); // 현재페이지 $this.pageTotal = $(config.pageTotal, $this); // 전체페이지 $this.cTotal = $this.mContC.length; // 단위콘텐츠 개수. $this.v0 = { endOpacity: parseInt($this.mContC.css('opacity')) // 20140814. 불변해야하므로 함수 밖에서 1번만 값 할당. 안그러면.. 창 크기 조절에 값이 0 이 되버린다. }; ($this.setV0 = function(){ // 동작값 만들기 // default value. 뷰박스(단위콘텐츠크기) 밖에서 시작해서 원 위치에서 끝난다. $this.v1 = { startLeft: parseInt($this.mContC.css('width')), startTop: parseInt($this.mContC.css('height')), endLeft: parseInt($this.mContC.css('left')), endTop: parseInt($this.mContC.css('top')), mContCcWidth: parseInt($this.mContCc.css('width')), // 아코디언용 mContCmWidth: parseInt($this.mContCm.css('width')) // 아코디언용 }; $.extend($this.v0, $this.v1); // $this.v0.endOpacity 값 지워지지 않도록 //console.log($this.v0.endOpacity); })(); ($this.autoOnOff = function(){ // auto play, stop 상태 표시 if(config.autoFlag){ $this.play.removeClass('on').addClass('on'); $this.stop.removeClass('on') }else{ $this.play.removeClass('on') $this.stop.removeClass('on').addClass('on'); } })(); ($this.reset = function(){ // 다시 맞춤 (load, resize, oriented 동작에) //$this.mView.css({width:(config.viewNum*$this.v0.startLeft) + 'px'}); // 멀티뷰*뷰너비. ☆20140731. 이 기능 제거해야 단독뷰 너비 반응형 동작한다. $this.setV0(); // 20140814. 동작값 다시 만들기 })(); // 순번 활성 ($this.changOn = function(){ $this.mNum.each(function(){ // 순번 $(this).children('.m').removeClass('on').eq(config.onnum-1).addClass('on'); }); $this.mCont.each(function(){ // 콘텐츠 $(this).children('.mContC').removeClass('on').eq(config.onnum-1).addClass('on'); for(var i = config.viewNum-1;i--;){ // config.viewNum 개씩 보임. $(this).children('.mContC').eq(config.onnum + i).addClass('on'); } //$(this).children().eq(config.onnum-1).find('a').focus(); // 활성 콘텐츠 자손 a 있으면 포커스 }); // 새, 헌 활성 콘텐츠 객체 구하기 $this.cOnNew = $('.mContC.on' + config.c, $this.mCont); $this.cOnOld = (config.c)? $(config.c, $this.mCont.children().eq(config.oldonnum-1)).delay(config.delay): $this.mCont.children().eq(config.oldonnum-1); $this.cOnNew.css({zIndex:config.zIndex++}); // 활성 콘텐츠 맨위로. if(config.zIndex > $this.cTotal*2){ // zIndex 수가 너무 커지지 않도록 방지 config.zIndex = $this.cTotal + 1; $this.mContC.each(function(){ $(this).css({zIndex:parseInt($(this).css('zIndex'))-$this.cTotal}); }); } // 새 활성 콘텐츠 내용 없으면.. 코드 만들어 불러온다. ★☆개발필요! ajax! 만들어진 코드 가져오도록.. $this.loadContent = function(){ if($this.cOnNew.html() == ''){ var onn = (config.onnum < 10)? '0' + config.onnum: config.onnum; $this.cOnNew.html('
★대체텍스트' + onn + '
'); } } $this.loadContent(); // 콘텐츠 나열. 20131205. 콘텐츠와 순번이 섞여있을 때 고려. $this.mContC.each(function(){ var thisNum = 1 + $(this).prevAll('.mContC').length; var idxGap = (thisNum - config.onnum); //$(this).addClass('on' + idxGap); // 테스트용 $(this).css({left:(idxGap*$this.v0.startLeft) + 'px', top:(idxGap*$this.v0.startTop) + 'px'}); }); // 세로 슬라이드 여부 if(config.vertical){$this.v0.startLeft = 0} else{$this.v0.startTop = 0} // < class=".m" />< class=".c" /> 일 때 //$(config.m, $this.mNum).css({zIndex:parseInt($(config.m, $this.mNum).css('zIndex')) + 1}); // .c 와 형제일 때 제어 버튼을 위로 올려서 보이게 한다. $this.pageOn.text(config.onnum); // 현재페이지 $this.pageTotal.text($this.cTotal); // 전체페이지 })(); // 액션!! ($this.action = function(effect){ switch(effect){ case 'slide': // ★슬라이드 $this.changOn(); if(config.onnum > config.oldonnum){config.frontback = 1} // 정방향 else if(config.onnum < config.oldonnum){config.frontback = -1} // 역방향 if(config.onnum == 1 && config.oldonnum == $this.cTotal){config.frontback = 1} // 정방향. 맨끝→맨앞 else if(config.onnum == $this.cTotal && config.oldonnum == 1){config.frontback = -1} // 역방향. 맨끝←맨앞 // 새 to 활성 동작 $this.cOnNew.css({ left:(config.frontback*$this.v0.startLeft) + $this.offsetXdrag + 'px' , top:(config.frontback*$this.v0.startTop) + 'px' , opacity:$this.v0.endOpacity }); $this.cOnNew.delay(config.delay).stop().animate({ left:$this.v0.endLeft + 'px' , top:$this.v0.endTop + 'px' , opacity:$this.v0.endOpacity }, config.duration, config.easing,function(){}); // 헌 to 비활성 동작 $this.cOnOld.css({ left:(config.frontback*$this.v0.endLeft) + $this.offsetXdrag + 'px' , top:(config.frontback*$this.v0.endTop) + 'px' , opacity:$this.v0.endOpacity }); $this.cOnOld.delay(config.delay).stop().animate({ left:(config.frontback*(-1)*$this.v0.startLeft) + 'px' , top:(config.frontback*(-1)*$this.v0.startTop) + 'px' , opacity:$this.v0.endOpacity }, config.duration, config.easing,function(){}); break; case 'fade': // ★페이드 $this.changOn(); $this.mContC.css({display:'', left:$this.v0.endLeft, top:$this.v0.endTop, opacity:$this.v0.endOpacity}); // 20131209. Overlay 효과 위해 추가 $this.cOnNew.css({opacity:0, zIndex:config.zIndex++}); // 활성 콘텐츠 투명하게 초기화. $this.cOnNew.delay(config.delay).stop().animate({opacity:$this.v0.endOpacity}, config.duration, config.easing, function(){}); $this.cOnOld.delay(config.delay).stop().animate({opacity:0}, config.duration, config.easing, function(){}); // 20131209. Overlay 효과 위해 추가 break; case 'accordion': // ★아코디언.20140626 $this.changOn(); // 활성 on 용으로만 사용. 불필요한 지정값은 아래에서 리셋. $this.mContC.css({left:'auto', top:'auto'}); $this.mContCc.css({zIndex:''}); $this.mContC.each(function(){ if($(this).is('.on')){ $('.m', this).delay(config.delay).stop().animate({width: 0 + 'px'}, config.duration, config.easing, function(){}); $('.c', this).delay(config.delay).stop().animate({width: $this.v0.mContCcWidth + 'px'}, config.duration, config.easing, function(){}); }else{ $('.m', this).delay(config.delay).stop().animate({width: $this.v0.mContCmWidth + 'px'}, config.duration, config.easing, function(){}); $('.c', this).delay(config.delay).stop().animate({width: 0 + 'px'}, config.duration, config.easing, function(){}); } }); break; default: // ★단순 표시 $this.changOn(); } $this.offsetXdrag = 0; // 보정 후 초기화 })(config.initEffect); // 최초 실행 안하다. 아코디언만 한다. $(window).on('resize', function(){ // 창 크기 조절 $this.reset(); // $this.action($this.effect); 하지마라! 과부하 방지. // 20140814. if($this.effect != 'fade'){ // 페이드 효과만 액션 재실행 안함. 하면.. zindex 값이 엉켜 -값도 생긴다. $this.action(); // 콘텐츠 left 값을 다시 맞춰야 한다. } }); $this.prevAct = function(){ // 이전 순번 계산, 액션 실행 config.oldonnum = config.onnum; config.onnum -= config.viewNum; // 뷰영역에 config.viewNum 개씩 보임. if(config.onnum < 1){config.onnum = $this.cTotal; // 맨뒤 순번 config.onnum = config.viewNum*(Math.ceil($this.cTotal/config.viewNum)-1) + 1; // 맨앞 이전은 맨뒤 그룹의 맨앞. config.viewNum 이하면 몇 개든 1그룹으로 계산. } $this.action($this.effect); } $this.nextAct = function(){ // 다음 순번 계산, 액션 실행 // console.log('$this.effect : ' + $this.effect); // 자동 실행에는 값 가지지만, 클릭 시에는 아래 ☆Accessibility 기능으로 null 이 되버림. config.oldonnum = config.onnum; config.onnum += config.viewNum; // 뷰영역에 config.viewNum 개씩 보임. if(config.onnum > $this.cTotal)config.onnum = 1; // 맨뒤 다음은 맨앞 $this.action($this.effect); } $this.prev.on('click', function(e){e.preventDefault(); // 이전 클릭 $this.prevAct(); }); $this.next.on('click', function(e){e.preventDefault(); // 다음 클릭 $this.nextAct(); }); // 순번 이벤트. 20131205. $(config.m, $this.mNum).on(config.mNumEvent , function(e){ e.preventDefault(); // 콘텐츠와 순번 혼합 형태 고려한 순번 계상. 20160626. if($(this).parent().hasClass('mNum')){ // .mNum>.m 또는 ( .mCont.mNum>.m 이고 .mCont.mNum>.mContC ) 이면 var thisNum = 1 + $(this).index() * $(this).parents('.mNum').find('.m').length / $(this).parents('.mNum').children().length; }else{ // .mCont.mNum>.mContC>.m 이면 var thisNum = 1 + $(this).parents('.mContC').index() * $(this).parents('.mNum').find('.m').length / $(this).parents('.mNum').children().length; } if(config.onnum == thisNum) return false; // 활성 순번 클릭하면 동작 무시 config.oldonnum = config.onnum; config.onnum = thisNum; // 클릭한 순번 활성화 $this.action($this.effect); }).attr('tabindex',config.mTabindex); // 순번 탭 포커싱 // auto $this.autoAct = function(){ if(config.autoFlag){$this.nextAct();} } $this.timer1 = setInterval($this.autoAct, config.interval); $this.restartInterval = function(o){ // 자동 순환 재가동 if(o){ clearInterval(o); // 자동 정지 $this.timer1 = setInterval($this.autoAct, config.interval); // 자동 재생 } } // ☆Accessibility $this.find('button, a').addBack().on('focusin mouseenter click', function(e){ // 오버 //$this.find('button, a').on('focusin mouseenter click', function(e){ // 오버 // click 하면 다른 요소가 초점 사라지므로.. if(e.type == 'focusin'){ if($(this).parents('.mContC').length){ // 20131209. 투명 콘텐츠 겹쳐 보이는거 해결. 콘텐츠만 적용 $this.effect = null; // 단순 효과로 변경. 안하면.. 초점 받은 후 동작으로 초점이 사라질 수 있다. $this.mContC.css({display:'', left:$this.v0.endLeft, top:$this.v0.endTop, opacity:0}); $(this).parents('.mContC').css({opacity:$this.v0.endOpacity}); } } clearInterval($this.timer1); }); $this.find('button, a').addBack().on('focusout mouseleave', function(e){ // 아웃 if(e.type == 'focusout'){ // 20131209. 투명 콘텐츠 겹쳐 보이는거 해결 복구 $this.effect = config.effect; // 효과 옵션을 다시 가져온다. if($(this).parents('.mContC').length){ // 콘텐츠만 적용 $this.mContC.css({opacity:$this.v0.endOpacity}); } } if(config.autoFlag){ $this.restartInterval($this.timer1); } }); $this.stop.click(function(e){e.preventDefault(); // 정지 클릭 config.autoFlag = false; $this.autoOnOff(); clearInterval($this.timer1); }); $this.play.click(function(e){e.preventDefault(); // 재생 클릭 config.autoFlag = true; $this.autoOnOff(); $this.restartInterval($this.timer1); }); $('a, area', $this.mContC).attr('tabindex',0).on('focusin', function(e){ // 20131205. 키보드운용.. 범용 위해 재계상. // 콘텐츠와 순번이 섞여있을 때 고려 : .mContC>.m 와 .mCont>.m 일 경우 모두 고려함. var thisIdx = $(this).parents('.mContC').prevAll('.mContC').length; if($(config.m, $this.mNum).length > 0){ //console.log($(config.m, $this.mNum) + ' ' + 'true'); $(config.m, $this.mNum).eq(thisIdx).trigger('click'); }else{ // 순번 탭 없을 때 //console.log($(config.m, $this.mNum) + ' ' + 'false'); config.oldonnum = config.onnum; config.onnum = thisIdx + 1; $this.action($this.effect); } }); // Gesture if(!config.gesture) return false; ($this.gesture1 = function(){ var o = { sx: 0 // start x , sy: 0 // start y , dx: 0 // distance x , dy: 0 // distance y , ex: 0 // end x , ey: 0 // end y , sl: 0 // start left , st: 0 // start top , threshold: config.threshold // 반응 기준값 }; $this.mView.on('touchstart touchmove touchend mousedown mousemove mouseup', function(e){ // $(this) 좌상단에서의 터치 이벤트 상대 위치 x, y $this.offsetLeft = ($(this).offset().left < 0)? 0: $(this).offset().left; // 뷰가 화면 보다 클 때 보정 $this.offsetTop = ($(this).offset().top < 0)? 0: $(this).offset().top; if(e.originalEvent.touches || e.originalEvent.changedTouches){ // 터치 있으면 var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; // 싱글 터치 touch.length = e.originalEvent.touches.length || e.originalEvent.changedTouches.length; }else{ var e = e || window.event; } var x = (e.pageX || touch.pageX) - $this.offsetLeft; var y = (e.pageY || touch.pageY) - $this.offsetTop; if(x < $(this).width() && x > 0 && y < $(this).height() && y > 0){ // $(this) 범위 안이면 동작 if(e.type == 'touchstart' || e.type == 'mousedown'){ $this.onGesture = 1; o.sx = x; o.sy = y; // 터치 시작 위치 기억 o.dx = 0; o.dy = 0; // 터치 이동 거리 초기화 o.sl = parseInt($this.mCont.css('left')); // mCont 가 [1][2][3] 나열되어 있을 때와 동일하게 동작하고.. 이전, 다음 동작 시에는 mContC 로 계산할거다. clearInterval($this.timer1); // 자동 정지 } if(e.type == 'touchmove' || e.type == 'mousemove'){ if($this.onGesture){ o.dx = x-o.sx; o.dy = y-o.sy; // 터치 이동 거리 계산 if(Math.abs(o.dx) > Math.abs(o.dy)){ // 가로 이동 크면 동작 e.preventDefault(); $this.mCont.css('left',(o.sl + o.dx) + 'px'); // 터치 이동 거리만큼 mCont 이동 }else{ $this.onGesture = 0; } } } if(e.type == 'touchend' || e.type == 'mouseup'){ //e.preventDefault(); // 20150202. [Android4.4.x~] 링크 이동 먹통 오류 해결. $this.onGesture = 0; o.ex = x; o.ey = y; // 터치 종료 위치 기억 if(Math.abs(o.dx) > Math.abs(o.dy)){ // 가로 이동 크면 동작 $this.offsetXdrag = parseInt($this.mCont.css('left')) || 0; // mContC 를 이전 다음 동작 시 이동한 만큼 보정할거고.. (NAN이면0으로계산) $this.mCont.css('left',(o.sl) + 'px');// mCont 는 원위치한다. if((o.ex-o.sx) > o.threshold){ $this.prevAct(); } else if((o.ex-o.sx) < -o.threshold){ $this.nextAct(); } else{ $this.returnAct('slide'); } } $this.restartInterval($this.timer1); } }else{ // $(this) 범위 밖이면 원위치 if($this.onGesture){ // 터치중 $this.returnAct('slide'); $this.onGesture = 0; } } $('a',this).click(function(){ if(Math.abs(o.dx) > 2){ // 2px 초과 드래그하면.. 링크 이동 안함. return false; }else{ return; } }); // Android 4.1.2 Webkit 534.30 (GalaxyS2,..) 는 touch 와 mouse 이벤트 동시에 발생하고, if(/touch/.test(e.type)){ $('.test').html($this.onGesture + " " + /touch/.test(e.type) + " " + e.type + " " + Math.abs(o.dx)).css({'border':'1px solid #f00'}); // ★☆점검후제거 }else{ // Desktop Web 은 mouse 이벤트만 발생한다. $('.test').html($this.onGesture + " " + /touch/.test(e.type) + " " + e.type + " " + Math.abs(o.dx)).css({'background':'#0f0'}); // ★☆점검후제거 return false; // 그래서 여기서만 해줘야지.. 올바로 동작 } }); })(); $this.returnAct = function(effect){ // 제자리로 되돌리기 switch(effect){ case'slide': $this.mCont.animate({left:0},'slow','swing', function(){}); break; default: $this.mCont.css('left',0); } } }); } /* /$.fn.jQmPR1 */ /** ◇◆ jQmTicker1.20140804.MoonYoungShin. * !!required: jquery-1.8.0.min.js 이상, jquery.easing.1.3.js /---- * Task) 고도화! */ $.fn.jQmTicker1 = function(options){ if(!this) return false; var config = { interval: 3000 // 간격 밀리초 , autoFlag: true // true: 정지 버튼 클릭 안한 상태, false: 클릭한 상태 , effect: null // 효과 , duration: 0 // 효과 동작시간. 밀리초 , easing: 'swing' // 동작 완화. jswing 은 jquery.easing.1.3.js 필요! //DOM Selectors , mView: '.mView' // 뷰영역 , mCont: '>.mCont' // 콘텐츠 그룹 , mContC: '>.mContC' // 단위콘텐츠. 아코디언 효과에는 자식으로 순번 앵커와 진짜콘텐츠를 분리한다. , prev: '.mControl .prev' // 이전 버튼 , next: '.mControl .next' // 다음 버튼 , stop: '.mControl .stop' // (일시)정지 버튼 , play: '.mControl .play' // 재생 버튼 , onPage: 1 // 초기활성페이지 }; $.extend(config, options); return this.each(function(){ var $this = $(this); $this.effect = config.effect; //DOM $this.mView = $(config.mView, $this); $this.mCont = $(config.mCont, $this.mView); $this.mContC = $(config.mContC, $this.mCont); // '>.mContC' $this.mNum = $(config.mNum, $this); $this.prev = $(config.prev, $this); $this.next = $(config.next, $this); $this.stop = $(config.stop, $this); $this.play = $(config.play, $this); ($this.autoOnOff = function(){ // auto play, stop 상태 표시 if(config.autoFlag){ $this.play.removeClass('on').addClass('on'); $this.stop.removeClass('on') }else{ $this.play.removeClass('on') $this.stop.removeClass('on').addClass('on'); } })(); $this.reset = function(){ // 다시 맞춤 (load, resize, oriented 동작에) config.onPage = 1; $this.action($this.effect); }; // 액션 $this.action = function(effect){ switch(effect){ default: $this.mCont.animate({'top': $this.mView.height() * (1 - config.onPage) + 'px'}, config.duration, config.easing); } $this.offsetXdrag = 0; // 보정 후 초기화 }; $(window).on('resize', function(){ // 창 크기 조정 $this.reset(); $this.action(); // $this.action($this.effect); 마라! 과부하 방지. }); $this.prevAct = function(){ // 이전 계산, 액션 실행 var allPage = $this.mCont.height() / $this.mView.height(); if(config.onPage == 1){ config.onPage = allPage; }else{ config.onPage--; } $this.action($this.effect); } $this.nextAct = function(){ // 이전 계산, 액션 실행 var allPage = $this.mCont.height() / $this.mView.height(); if(config.onPage == allPage){ config.onPage = 1; }else{ config.onPage++; } $this.action($this.effect); } $this.prev.on('click', function(e){e.preventDefault(); // 이전 클릭 $this.prevAct(); }); $this.next.on('click', function(e){e.preventDefault(); // 다음 클릭 $this.nextAct(); }); // 자동 $this.autoAct = function(){ if(config.autoFlag){$this.nextAct();} } $this.timer1 = setInterval($this.autoAct, config.interval); $this.restartInterval = function(o){ // 자동 순환 재가동 if(o){ clearInterval(o); // 자동 정지 $this.timer1 = setInterval($this.autoAct, config.interval); // 자동 재생 } } // 접근성 $this.find('button, a').addBack().on('focusin mouseenter click', function(e){ clearInterval($this.timer1); }); $this.find('button, a').addBack().on('focusout mouseleave', function(e){ if(config.autoFlag){ $this.restartInterval($this.timer1); } }); $this.stop.click(function(e){e.preventDefault(); // 정지 클릭 config.autoFlag = false; $this.autoOnOff(); clearInterval($this.timer1); }); $this.play.click(function(e){e.preventDefault(); // 재생 클릭 config.autoFlag = true; $this.autoOnOff(); $this.restartInterval($this.timer1); }); $this.mCont.find('a').first().on('focusin', function(e){ // 첫앵커 포커스시 맨앞페이지로 config.onPage = 1; $this.mCont.css({'top': $this.mView.height() * (1 - config.onPage) + 'px'}); }); $this.mCont.find('a').last().on('focusin', function(e){ // 끝앵커 포커스시 맨뒤페이지로는 [IE] 문제 있으므로 그대로 두는게 좋다. //var allPage = $this.mCont.height() / $this.mView.height(); //config.onPage = allPage; //$this.mCont.css({'top': $this.mView.height() * (1 - config.onPage) + 'px'}); }); }); } /* /$.fn.jQmTicker1 */ /** ◇◆ jQmFitHeight1.20141224.MoonYoungShin. [IE7] float, clear Bug Fix * 20141224. UA 다운 빈번하여 성능 개선. * !required: [jquery-1.8.0.min.js] 이상. getIEVerSetClass() 실행되어 있어야 한다. * Use) $('.bbs1gallery1').jQmFitHeight1({itemSelector:'>.lst1>.li1', per:4, minWinWidth:768, delay:50}); /---- * Task) Advancement! * Task) Ajax 연동 점검. */ $.fn.jQmFitHeight1 = function(options){ if(!this) return false; if(!$('html').hasClass('IE7')) return false; var config = { itemSelector : '>.lst1>.li1', // 콘텐츠 블록 안에 배치된 개별 요소 per: 4, // 가로 행에 플로트 배치된 수. >>> 20141224. 의미없다!! 폭 반응에 달라지므로.. 계산해야 한다. minWinWidth: 768, // 미만이면 원래 높이값으로 종렬 배치 >>> 20141224. 의미없다!! 있는 경우 자동으로 만들자. delay: 50 // 지연해야 바르게 계산한다. }; $.extend(config,options); return this.each(function(){ var $this = $(this); var newHeight = 0; // 이전 거보다 높이 작으면 이 높이를 넣어준다. var v = { clearRightSum: 0, // clear:right; 개 수. 전체 행 수 계산용 mStack: 0 // load resize 이벤트 발생 수 체크 및 동작 반복 방지용 }; var timer1; // [IE7,8?] resize 이벤트 중복 실행되는 방지용. $this.$item = $(config.itemSelector, $this); $this.fn1 = function(){ clearTimeout(timer1); setTimeout(function(){ newHeight = 0; // 초기화 $this.$item.each(function(){ $(this).css({height: 'auto'}); // 초기화 }); // 1행 아이템 수 계산 $this.$item.each(function(){ if($(this).css('clear') == 'right') v.clearRightSum++; }); config.per = parseInt($this.$item.length / v.clearRightSum); v.clearRightSum = 0; $this.$item.each(function(){ //$(this).css({height: 'auto'}); // [IE7] 1행 1목록 아니라면.. clear 버그 발생하므로.. 의미없다. if($(this).index() % config.per == 0){ // config.per 개씩 newHeight = 0; } if($(this).height() > newHeight){ // 이전 최대값 보다 크면 newHeight = $(this).height(); } // ☆중요!! [IE7] 아래처럼 DOM 속성 변경하면.. 'load resize' 이벤트가 무한반복되는 심각한 문제 발생하였다. // 반응형 스크립트 병용에 의한 시간차로 발생하는 거로 생각되지만 확신은 금물. $(this).css({height: newHeight + 'px'}); }); //console.log(' :: ' + v.mStack + ' :: ' + $this.$item.eq(0).height() + ' :: ' + $this.$item.eq(1).height() + ' :: ' + $this.$item.eq(2).height() + ' :: ' + $this.$item.eq(3).height()); }, config.delay); }; $(window).on('load resize', function(){ // 문서와 이미지 모두 로드되면 실행. ☆[IE7] 이벤트 다수 발생되어 성능 문제 발생! clearTimeout(timer1); timer1 = setTimeout(function(){ if(v.mStack < 1){ v.mStack++; $this.fn1(); }else{ v.mStack = 0; } }, 200); // 200 은 콘솔 로그 확인 결과 적당한 값. }); }); } /** ◇◆ jQmPrevNext1.20141126.MoonYoungShin. 페이지 이전 다음 * Use) $('.recommend1c').jQmPrevNext1(); /---- * Task) To Advance! */ $.fn.jQmPrevNext1 = function(options){ if(!this) return false; var config = { bprev : '.mControl .b.prev', // 이전 bnext : '.mControl .b.next', // 다음 mView : '.mView', // 뷰 mCont : '.mCont', // 개별아이템묶음 mContC : '.mContC' // 개별아이템 }; $.extend(config, options); return this.each(function(){ var $this = $(this); $this.$bprev = $(config.bprev, $this); $this.$bnext = $(config.bnext, $this); (function(){ $this.$bprev.on('click', function(){ var $that = $(this).parent().next(config.mView) $that.$c = $(config.mCont, $that); $that.$cc = $(config.mContC, $that.$c); $that.v = parseInt( $that.outerWidth(true) / $that.$cc.outerWidth(true) ) * $that.$cc.outerWidth(true); $that.vLast = 0; $that.$c.css({'left': (parseInt($that.$c.css('left')) + $that.v) + 'px'}); if( parseInt($that.$c.css('left')) > 0){ $that.vLast = parseInt($that.$cc.last().position().left / $that.v) * $that.v $that.$c.css({'left': (-1 * $that.vLast) + 'px'}); } }); $this.$bnext.on('click', function(){ var $that = $(this).parent().next(config.mView) $that.$c = $(config.mCont, $that); $that.$cc = $(config.mContC, $that.$c); $that.v = parseInt( $that.outerWidth(true) / $that.$cc.outerWidth(true) ) * $that.$cc.outerWidth(true); $that.$c.css({'left': (parseInt($that.$c.css('left')) - $that.v) + 'px'}); if( parseInt($that.$c.css('left')) < (-1 * $that.$cc.last().position().left)){ $that.$c.css({'left': 0 + 'px'}); } }); })(); }); } /* ◇◆ Function ◇◆◇◆◇◆◇◆◇◆◇◆◇◆◇◆ */ /** ◇◆ addOnNav.20140806.MoonYoungShin. 현재활성1·2·3·4차 * Use) addOnNav(); // 하위메뉴 모두 접을 시 현재페이지 활성 실행 * 문서 준비되기 전에 함수 정의 */ function addOnNav(){ var dn_n_n_n = $('body').attr('class'); //var bodyID = $('body').attr('id'); if(!dn_n_n_n) return false; // 에러방지 var depthArr = /d([0-9]+)_([0-9]+)_([0-9]+)_([0-9]+)/.exec(dn_n_n_n) //alert(bodyID); if(!depthArr) return false; // 에러방지. 팝업페이지 등 menu_all 없는 경우 $('#snb1>div.d2>ul>li.m'+depthArr[3]).addClass('on'); // 부메뉴3차 $('#snb1>div.d2>ul>li.on>div.d3>ul>li.m'+depthArr[4]).addClass('on'); // 부메뉴4차 $('.cnb1 .m'+depthArr[5]).addClass('on'); // 콘텐츠메뉴5차 } // 모바일에서 현재활성1·2·3·4차 function addOnNav2(){ $('#mTnb1').find('.open').addClass('on'); $('div.d1>ul>li.open>a').on('click', function(){ // 1차메뉴 클릭 $(this).parent().find('.d2>ul>li.open>.d3').css('display','block'); $(this).parent().find('.d2>ul>li.open>.d3>ul>li.open>.d4').css('display','block'); if($(this).parent().find('.d2>ul>li.open>.d3').css('display') == 'block'){ var thisIndex = $(this).parent().find('.d2>ul>li.open').index() + 1; var d3Legnth = $(this).parent().find('.d2>ul>li.open>.d3>ul>li').length; var d4Legnth = $(this).parent().find('.d2>ul>li.open>.d3>ul>li.open>.d4>ul>li').length; var sLegnth = $(this).parent().find('.d2>ul>li.open>.d3>strong.h2').length; var smain = 35 * sLegnth; var d3Height = 31 * d3Legnth; var d4Height = (d4Legnth - 0.5) / 2; var d4Height2 = Math.ceil(d4Height); var d4Height3 = d4Height2 * 28; var totalHeight = d3Height + d4Height3 + smain; //alert(smainLegnth); if (thisIndex % 2 == 1) { $(this).parent().find('.d2>ul>li.open').next().next().css('margin-top',totalHeight); $(this).parent().find('.d2>ul>li.open').next().next().next().css('margin-top',totalHeight); } else { $(this).parent().find('.d2>ul>li.open').next().css('margin-top',totalHeight); $(this).parent().find('.d2>ul>li.open').next().next().css('margin-top',totalHeight); } } }); } /** ◇◆ jQdoPrevNext.20140801.MoonYoungshin. 단순 이전 다음. * Task) 범용, 효과. */ function jQdoPrevNext(selector){ var $this = $(selector); $this.c = $('.cont li', $this); var v = { sum: $this.c.length, idxOld: $this.c.filter('.on').index(), idxNew: null } $('.menu .m', $this).on('click', function(e){ e.preventDefault(); v.idxOld = $this.c.filter('.on').index(); if($(this).hasClass('prev')){ v.idxNew = (v.idxOld == 0)? (v.sum - 1): v.idxOld - 1; } if($(this).hasClass('next')){ v.idxNew = (v.idxOld == v.sum -1)? 0: v.idxOld + 1; } $this.c.eq(v.idxNew).addClass('on').siblings().removeClass('on'); }); } /** ◇◆ jQtabCont2.20140930.MoonYoungshin. 20141007 * 탭-탭-내용-내용. 이벤트, 활성순번 * 탭-내용-탭-내용. 가능하도록 개선. * Use) jQtabCont2('이벤트', '컨테이너 선택자', '탭메뉴 요소 선택자', 기본 활성 순번, '탭대상 요소 선택자'); * ex1) jQtabCont2('click', '.officeguide1', '.tab', 1, '.cont'); */ function jQtabCont2(e, selector, m, n, c){ var $this = $(selector); $this.e = (e)? e: 'click'; // 이벤트 $this.$m = (m)? $(m, $this): $('.m', $this); // 메뉴 $this.n = (n)? n: 0; // 활성순번 $this.$c = (c)? $(c, $this): $('.c', $this); // 대상 $('a', $this.$m).on($this.e, function(){ $this.$m.removeClass('on'); $(this).parent().addClass('on'); $this.n = $(this).parent(m).index(selector+' '+m)+1; // 20140930. 순번 인덱스 계산 index(selector+' '+m) 로 수정. $this.$c.removeClass('on').hide(); $this.$c.eq($this.n-1).addClass('on').show(); if(!!$(this).attr('href')) return false; }); $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); // 초기실행 } /** ◇◆ jQtabCont3.20140930.MoonYoungshin. 20141007 * 탭-탭-내용-내용. 이벤트, 활성순번. 슬라이드. * 탭-내용-탭-내용. 가능하도록 개선. * slideToggle() 주의! CSS 에 따라서 활성 대상도 처음에 안 보일 수 있다. * Task1) 효과 추가. 고도화 필요하다. */ function jQtabCont3(e, selector, m, n, c){ var $this = $(selector); $this.e = (e)? e: 'click'; // 이벤트 $this.$m = (m)? $(m, $this): $('.m', $this); // 메뉴 $this.n = (n)? n: 0; // 활성순번 $this.$c = (c)? $(c, $this): $('.c', $this); // 대상 $('a', $this.$m).on($this.e, function(){ $this.$mOn = $(this).parent(); $this.n = $this.$mOn.index(selector+' '+m)+1; // 활성순번 = 인덱스+1. // 20140930. 순번 인덱스 계산 index(selector+' '+m) 로 수정. $this.$cOn = $this.$c.eq($this.n-1); // 인덱스 = 활성순번-1 $this.$mOn.siblings(m).removeClass('on'); $this.$mOn.toggleClass('on'); $this.$cOn.siblings(c).removeClass('on').hide(100, 'swing', function(){}); // duration 밀리초 0 은 단순표시. $this.$cOn.toggleClass('on').show(100, 'swing', function(){}); if(!!$(this).attr('href')) return false; }); $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); // 초기실행 } /** scrollTouch.20140515.MoonYoungShin.20140902. 스크롤터치.모바일+데스크탑.멀티 [CR][AndroidDefaultWeb][IE11,10] * !!required: ★ iScroll v5.1.1 "http://iscrolljs.com/" * [~IE8] iScroll 불가하니, CSS {overflow:auto;}. iScroll 오류 안나게 수정 필요! Use0) jQscrollTouch(); // 기본 실행. Mobile 만 = jQscrollTouch('.scroll1wrap'); = jQscrollTouch('.scroll1wrap', {setDesktop: false}); Use1) jQscrollTouch('.scroll1wrap1all1', {setDesktop: true}); // Desktop 포함 task1) 스크롤 트랙 클릭 동작 OK /---- task2) task3) 키보드 좌우 조작하면 초점 콘텐츠만 스크롤 */ function jQscrollTouch(scrollWrapClass, options){ var $this = $(scrollWrapClass = scrollWrapClass || '.scroll1wrap'); // 스크롤 뷰래퍼 if(!$this) return false; var config={ contSelector: '>*:first', // 스크롤 콘텐츠. 뷰영역 자식이 여럿이면 .scroll1cont 로 묶어야 한다. setDesktop: false, // 데스크톱 적용여부. 안한다, true: 한다. maxWidthNone: '>*', // 최대폭제한제거. '>*': 자식, ' *': 자손.. that: 0 // 예비 }; $.extend(config,options); var scrollWrapName = scrollWrapClass.replace(/\./, ''); // 첫문자 제거 ( . 또는 # 등..) if($('html').hasClass('Desktop') && !config.setDesktop){ // setDesktop = false 면 스크롤 생성 막음. $this.removeClass(scrollWrapName); return false; } if($('html').hasClass('lteIE8')) return false; // [~IE8] iScroll 실행 전에 중단! $this.each(function(index){ // var $this = $(this); $(window).on('load', function(){ // 갤2에서 표 우측끝 안보이는 문제 해결. $this.$cont = $(config.contSelector, $this); // 스크롤 영역 자식이 둘 이상일 때 .scroll1cont 로 묶어서 너비를 내부 최대크기로 만든다. $this.css({position: 'absolute'}); $(config.maxWidthNone, $this.$cont).css({'max-width': 'none'}); // 자식들 너비 제한 두지말고..☆자손 고려 필요! $this.$cont.css({width: $this.$cont.width() + 'px'}); $this.$cont.width = $this.$cont.width(); $this.css({position: ''}); // 각각 스크롤 위해 id 부여해서 생성자 함수 IScroll 실행 $this.attr({id: scrollWrapName + index}); // id 부여 scroll1wrap0, scroll1wrap1, .. $this.myScroll = new IScroll( '#'+$this.attr('id'), { // !!required: ★ iScroll eventPassthrough: true, scrollX: true, scrollY: false, preventDefault: false, scrollbars: true, mouseWheel: true, interactiveScrollbars: true, shrinkScrollbars: 'scale', fadeScrollbars: false, keyBindings: { // 가로스크롤 left, right 키만 반응함. pageUp: 33, pageDown: 34, end: 35, home: 36, left: 37, up: 38, right: 39, down: 40 } }); $this.$scrollbarFace = $('.iScrollIndicator', $this); $this.$scrollbarTrack = $('.iScrollLoneScrollbar', $this); $this.$scrollbarFace.attr({'tabindex': '0'}); // 스크롤바 필요할 때만 보이기. var maybeConflict = false; $this.$scrollbarTrack.on('mouseup', function(e){ $this.$scrollbarFace.on('mouseup', function(e){ maybeConflict = true; }); if(!maybeConflict){ // 스크롤바에서는 이벤트 발생안했다면 var a={ scrollToX : 0, // 이동할지점 faceWidth : $this.$scrollbarFace.width(), // 스크롤바폭 trackWidth : $this.$scrollbarTrack.width() // 스크롤트랙폭 }; a.scrollToX = - ((e.offsetX - (a.faceWidth / 2)) / a.trackWidth * $this.$cont.width); if(a.scrollToX > 0){ a.scrollToX = 0; }else if(a.scrollToX < a.trackWidth - $this.$cont.width){ a.scrollToX = a.trackWidth - $this.$cont.width; } $this.myScroll.scrollTo(a.scrollToX, 0, 200, IScroll.utils.ease.circular); }else{ maybeConflict = false; // 초기화하고 아래 동작 수행 // iScroll 플러그인 동작 수행한다. } }); }); // 스크롤바 필요할 때만 보이기. $(window).on('load resize', function(){ if($this.width() > $this.children().eq(0).width()){ // 뷰영역이 콘텐츠 보다 크면 $this.$scrollbarTrack.hide(); $this.removeClass('myscroll'); }else{ $this.$scrollbarTrack.show(); $this.addClass('myscroll'); // 스크롤바 공간확보 } }); }); } /** 콘텐츠메뉴.20140807.MoonYoungShin. 20141010. 활성 없을 때 에러 방지 * Use) makeCnb1(); // 기본실행은 makeCnb1('.cnb1', '.cnb1 ul'); 와 같다. * DOM 생성은 시간차 감지되므로 마크업 바로 아래 실행하라! * 2가지 동작 모두 구현. 1) Select Go WebPage, 2) Tab Prev Next * 2) Tab Prev Next - 활성메뉴 보이도록 뷰 가로 중앙으로 이동 - 맨앞, 맨끝 인지 위해 탄력 동작 추가 - 뷰 우측 메뉴 잘리는 문제 해결 및 고도화 /---- */ function makeCnb1(ss, os){ // subject selector, object selector var $this = (ss)? $(ss): $('.cnb1'); var $that = (os)? $(os): $('ul', $this); var v = { // 마크업 추가 note: '
선택하세요
', toggleOpen: '', // toggleClose: '', mView: '
', mCont: '
', b1prev: '', b1next: '' }; // 1) Select Go WebPage $this.prepend(v.toggleOpen); $this.prepend(v.note); $('li', $this).each(function(){ if($(this).hasClass('on')){ // 활성 클래스 전역변수 _onCnb1 = 'm1', 'm2', .. $that.hide(); $('.note', $this).html($(this).find('a').html()); } }); $('.toggle', $this).on('click', function(){ $that.toggleClass('open'); if($that.hasClass('open')){ $(this).removeClass('open').addClass('close'); $('t1', this).text('메뉴 감추기'); $that.slideDown(200, 'swing', function(){}); }else{ $(this).removeClass('close').addClass('open'); $('t1', this).text('메뉴 보이기'); $that.slideUp(200, 'swing', function(){}); } }); // 2) Tab Prev Next $that.wrap(v.mCont); $this.mCont = $('.mCont', $this); $this.mCont.wrap(v.mView); $this.mView = $('.mView', $this); $this.prepend(v.b1next); $this.prepend(v.b1prev); v.move = 0; // 이동값 setTimeout(function(){ // 활성메뉴 보이도록 뷰 가로 중앙으로 이동 if(!$('li.on', $this).length) return false; // 활성 없을 때 에러 방지 var onLeft = $('li.on', $this).position().left; var onWidth = $('li.on', $this).width(); if(onLeft + onWidth > $this.mView.width()){ $this.mCont.stop().animate({'left': -1 * $('li.on', $this).position().left + ($this.mView.width() - onWidth)/2 + 'px'}, 600, 'swing'); } }, 200); $('.b1.prev', $this).on('click', function(){ // 이전 v.move = parseInt($this.mCont.position().left) + $this.mView.width(); // 뷰폭 가변이면 이벤트 시 계산 $('li', $this).each(function(){ if($(this).position().left > $this.mCont.position().left * (-1) - $this.mView.width()){ v.move = $(this).position().left * (-1); return false; } }); //if( v.move <= 0 ){ if( v.move < 0 ){ // <= 0 로 안한 이유? 위 each 함수에서 v.move 값이 + 되려고 하면 0 으로 만들기에.. $this.mCont.stop().animate({'left': v.move + 'px'}, 200, 'swing'); }else{ // 맨앞 $this.mCont.stop().animate({'left': '50px'}, 200, 'swing', function(){ $this.mCont.animate({'left': '0'}, 100, 'swing'); }); } }); $('.b1.next', $this).on('click', function(){ // 다음 v.move = parseInt($this.mCont.position().left) - $this.mView.width(); $('li', $this).each(function(){ // 맨끝 요소가 잘려보일 때를 대비 if($(this).position().left + $(this).width() > $this.mCont.position().left * (-1) + $this.mView.width()){ v.move = $(this).position().left * (-1); return false; } }); if( v.move > $that.width() * (-1) ){ $this.mCont.stop().animate({'left': v.move + 'px'}, 200, 'swing'); }else{ // 맨끝 v.move += $this.mView.width(); $this.mCont.stop().animate({'left': v.move - 50 + 'px'}, 200, 'swing', function(){ $this.mCont.animate({'left': v.move + 'px'}, 100, 'swing'); }); } }); } /** 콘텐츠메뉴.20140807.MoonYoungShin. 20141010. 활성 없을 때 에러 방지 * Use) makeCnb1(); // 기본실행은 makeCnb1('.cnb1', '.cnb1 ul'); 와 같다. * DOM 생성은 시간차 감지되므로 마크업 바로 아래 실행하라! * 2가지 동작 모두 구현. 1) Select Go WebPage, 2) Tab Prev Next * 2) Tab Prev Next - 활성메뉴 보이도록 뷰 가로 중앙으로 이동 - 맨앞, 맨끝 인지 위해 탄력 동작 추가 - 뷰 우측 메뉴 잘리는 문제 해결 및 고도화 /---- */ function makeTourCnb1(ss, os){ // subject selector, object selector var $this = (ss)? $(ss): $('.tourCnb1'); var $that = (os)? $(os): $('ul', $this); var v = { // 마크업 추가 note: '
선택하세요
', toggleOpen: '', // toggleClose: '', mView: '
', mCont: '
', b1prev: '', b1next: '' }; // 1) Select Go WebPage $this.prepend(v.toggleOpen); $this.prepend(v.note); $('li', $this).each(function(){ if($(this).hasClass('on')){ // 활성 클래스 전역변수 _onCnb1 = 'm1', 'm2', .. $that.hide(); $('.note', $this).html($(this).find('a').html()); } }); $('.toggle', $this).on('click', function(){ $that.toggleClass('open'); if($that.hasClass('open')){ $(this).removeClass('open').addClass('close'); $('t1', this).text('메뉴 감추기'); $that.slideDown(200, 'swing', function(){}); }else{ $(this).removeClass('close').addClass('open'); $('t1', this).text('메뉴 보이기'); $that.slideUp(200, 'swing', function(){}); } }); // 2) Tab Prev Next $that.wrap(v.mCont); $this.mCont = $('.mCont', $this); $this.mCont.wrap(v.mView); $this.mView = $('.mView', $this); $this.prepend(v.b1next); $this.prepend(v.b1prev); v.move = 0; // 이동값 setTimeout(function(){ // 활성메뉴 보이도록 뷰 가로 중앙으로 이동 if(!$('li.on', $this).length) return false; // 활성 없을 때 에러 방지 var onLeft = $('li.on', $this).position().left; var onWidth = $('li.on', $this).width(); if(onLeft + onWidth > $this.mView.width()){ $this.mCont.stop().animate({'left': -1 * $('li.on', $this).position().left + ($this.mView.width() - onWidth)/2 + 'px'}, 600, 'swing'); } }, 200); $('.b1.prev', $this).on('click', function(){ // 이전 v.move = parseInt($this.mCont.position().left) + $this.mView.width(); // 뷰폭 가변이면 이벤트 시 계산 $('li', $this).each(function(){ if($(this).position().left > $this.mCont.position().left * (-1) - $this.mView.width()){ v.move = $(this).position().left * (-1); return false; } }); //if( v.move <= 0 ){ if( v.move < 0 ){ // <= 0 로 안한 이유? 위 each 함수에서 v.move 값이 + 되려고 하면 0 으로 만들기에.. $this.mCont.stop().animate({'left': v.move + 'px'}, 200, 'swing'); }else{ // 맨앞 $this.mCont.stop().animate({'left': '50px'}, 200, 'swing', function(){ $this.mCont.animate({'left': '0'}, 100, 'swing'); }); } }); $('.b1.next', $this).on('click', function(){ // 다음 v.move = parseInt($this.mCont.position().left) - $this.mView.width(); $('li', $this).each(function(){ // 맨끝 요소가 잘려보일 때를 대비 if($(this).position().left + $(this).width() > $this.mCont.position().left * (-1) + $this.mView.width()){ v.move = $(this).position().left * (-1); return false; } }); if( v.move > $that.width() * (-1) ){ $this.mCont.stop().animate({'left': v.move + 'px'}, 200, 'swing'); }else{ // 맨끝 v.move += $this.mView.width(); $this.mCont.stop().animate({'left': v.move - 50 + 'px'}, 200, 'swing', function(){ $this.mCont.animate({'left': v.move + 'px'}, 100, 'swing'); }); } }); } /** ◇◆ jQchangePic3. v20140829 r20150706. MoonYoungshin. 뷰섬네일.이벤트축소판대상할당온제어.이전다음. 제목 추가. * resize 제거하여 간단히 * Use) jQchangePic3('click', '.workenviron1 .photo1', '.m', 1, '.pt1'); * 섬네일 나열형 */ function jQchangePic3(e, selector, m, n, c){ var $this = $(selector); $this.e = (e)? e: 'click'; // 이벤트 $this.$m = (m)? $(m, $this): $('.m', $this); // 메뉴 $this.n = (n)? n: 0; // 활성순번 : 0 은 활성순번 없다. $this.$c = (c)? $(c, $this): $('.c', $this); // 대상 // 링크주소 있는 앵커만 동작 $('a[href]', $this.$m).on($this.e, function(e){e.preventDefault(); $this.$m.removeClass('on'); $(this).parent().addClass('on'); $('img', $this.$c).attr({ src: $(this).attr('href'), alt: $('>*>img', this).attr('alt') }); //$('.t1', $this.$c).html($('.t1', this).text()); // 섬네일도 텍스트 제목 $('.t1', $this.$c).text($('>*>img', $this.$c).attr('alt')); // 제목 $this.n = $(this).parent().index()+1; advanceControl(); }); $('.prev', $this).on('click', function(e){e.preventDefault(); // 이전 $this.n--; if($this.n <= 0) $this.n = $this.n + $this.$m.length; $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); advanceControl(); }); $('.next', $this).on('click', function(e){e.preventDefault(); // 다음 $this.n++; if($this.n > $this.$m.length) $this.n -= $this.$m.length; $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); advanceControl(); }); $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); // 초기실행 function advanceControl(){ // 이전 다음 점멸 $this.onIdx = $this.$m.filter('.on').index(); $this.$m.filter('.on').index() if( $this.onIdx == 0){ $('.prev', $this).hide(); }else{ $('.prev', $this).show(); } if( $this.onIdx == $this.$m.length-1){ $('.next', $this).hide(); }else{ $('.next', $this).show(); } } } /** ◇◆ jQchangePic4.20141104.MoonYoungshin. 뷰섬네일.이벤트축소판대상할당온제어. * Use) jQchangePic4('click', '.tour1photo1', '.m', 1, '.pt1', '.ms'); * 섬네일 페이징형. 제목 텍스트 전달 가능. 동작 고도화 * 이전다음 섬네일. 끝 다음은 반대 끝으로 보냄. * 활성 섬네일 페이지 자동 이동. * 맨앞, 중간, 맨끝 페이지 활성 섬네일 위치 고도화. * 이미지풀 고도화 * 가로중앙정렬, 세로중앙정렬 */ function jQchangePic4(e, selector, m, n, c, ms){ var $this = $(selector); var v = {}; // 변수 담을 객체 $this.e = (e)? e: 'click'; // 이벤트 $this.n = (n)? n: 0; // 활성순번 : 0 은 활성순번 없다. $this.$m = (m)? $(m, $this): $('.m', $this); // 메뉴 $this.$c = (c)? $(c, $this): $('.c', $this); // 대상 $this.$ms = (ms)? $(ms, $this): $('.ms', $this); // = $this.$m.parent() $this.$mCont = $('.mCont', $this); // = $this.$m.parent().parent() $this.$mView = $('.mView', $this); // = $this.$m.parent().parent().parent() v.move = 0; // 이동값 $this.$mCont.css({'width': $this.$ms.width()+'px'}); // width:10000px 를 자식 너비로 만듦. $('a', $this.$m).on($this.e, function(e){e.preventDefault(); // 섬네일 클릭 $this.$m.removeClass('on'); $(this).parent().addClass('on'); $('img', $this.$c).attr({ src: $(this).attr('href'), alt: $('img', this).attr('alt') }); //$('.t1', $this.$c).html($('.t1', this).text()); $('.t1', $this.$c).text($('img', $this.$c).attr('alt')); // 제목 $this.n = $(this).parent().index()+1; advanceControl(); }); $('.prev', $this).on('click', function(e){e.preventDefault(); // 이전 $this.n--; if($this.n <= 0) $this.n = $this.n + $this.$m.length; $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); advanceControl(); }); $('.next', $this).on('click', function(e){e.preventDefault(); // 다음 $this.n++; if($this.n > $this.$m.length) $this.n -= $this.$m.length; $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); advanceControl(); }); $this.$m.eq($this.n-1).find('a').triggerHandler($this.e); // ★☆초기실행 // 20141103. 다양한 이미지 고도화. // >>> CSS필요! li a .f1{ } // {width:100%;max-width:100%;height:100%;max-height:100%;} // X (종횡비왜곡) // {width:100;max-width:100%;height:auto;max-height:none;} // OK // {width:auto;max-width:none;height:100%;max-height:100%;} // OK // {width:auto;max-width:100%;height:auto;max-height:100%;} // OKOK $('li a .f1 img', $this).css({visibility: 'hidden'}); // 크기 맞추기 전에는 숨긴다. $('li.on .deco', $this).hide(); // 장식 숨김 $(window).on('load resize', function(){ // 섬네일 크기 맞춤 $('li a .f1', $this).each(function(){ $this.inHeight = $(this).innerHeight(); $this.inWidth = $(this).innerWidth(); if($('img', this).width() < $this.inWidth){ // .f1 종횡비보다 키 큰 img $('img', this).css({ // 이미지풀 (cover) width: '100%', maxWidth: '100%', height: 'auto', maxHeight: 'none' }); } if($('img', this).height() < $this.inHeight){ // .f1 종횡비보다 폭 큰 img $('img', this).css({ // 이미지풀 (cover) width: 'auto', maxWidth: 'none', height: '100%', maxHeight: '100%' }); } $('img', this).css({ marginLeft: function(){ // 가로중앙정렬 return ($(this).parent().width() - $(this).width())/2 + 'px'; }, marginTop: function(){ // 세로중앙정렬 return ($(this).parent().height() - $(this).height())/2 + 'px'; }, visibility: 'visible' }); $('li.on .deco', $this).show(); // 장식 보임 advanceControl(); }); }); function advanceControl(){ // 이전 다음 점멸 + 위치 이동 $this.onIdx = $this.$m.filter('.on').index(); if( $this.onIdx == 0 ){ $('.prev', $this).addClass('off'); }else{ $('.prev', $this).removeClass('off'); } if( $this.onIdx == $this.$m.length-1 ){ $('.next', $this).addClass('off'); }else{ $('.next', $this).removeClass('off'); } if(!$this.$m.filter('.on').length) return false; // 활성 없을 때 에러 방지 var onLeft = $this.$m.filter('.on').position().left; var onWidth = $this.$m.filter('.on').outerWidth(true); var onPage = parseInt( ( onLeft + onWidth ) / $this.$mView.width() ); if(onPage > 0){ v.move = (-1) * parseInt( $this.$mView.width() * onPage / onWidth ) * onWidth; }else{ v.move = 0; } $this.$mCont.css({'left': v.move + 'px'}); } } function closePop(pop,check){ var checkPop = document.getElementById(check); if(check=="checked") setCookie(pop,"done",1);// 인수1은 쿠키유지일수 var popLayer = document.getElementById(pop); if(popLayer) popLayer.style.visibility="hidden"; } function popupLayer(pop){ if(getCookie(pop)!="done"){ var popLayer = document.getElementById(pop); if(popLayer) popLayer.style.visibility="visible"; } } //쿠키 function setCookie( name, value, expiredays ) { var todayDate = new Date(); todayDate.setDate( todayDate.getDate() + expiredays ); document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" } function getCookie( name ) { var nameOfCookie = name + "="; var x = 0; while ( x <= document.cookie.length ) { var y = (x+nameOfCookie.length); if ( document.cookie.substring( x, y ) == nameOfCookie ) { if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length; return unescape( document.cookie.substring( y, endOfCookie ) ); } x = document.cookie.indexOf( " ", x ) + 1; if ( x == 0 ) break; } return ""; }
' + '
' + '