// img replace function imgReplace(obj,flag){ var imgSrc = obj.attr("src"); if(flag == "on"){ imgSrc = imgSrc.replace("_off.","_on."); } else if(flag == "off"){ imgSrc = imgSrc.replace("_on.","_off."); } obj.attr("src",imgSrc); } var $win = $(window), $doc = $(document), $html = $('html'), $body = $('body'); var gnb1Idx = gnbDep1-1, gnb2Idx = gnbDep2-1, gnb3Idx = gnbDep3-1; var viewMode, resizeTimer = null; var Detect = { isDesktop : function(){ var platform = "win16|win32|win64|mac", result = false; if( navigator.platform ){ ( platform.indexOf(navigator.platform.toLowerCase()) < 0 ) ? result = false : result = true ; } return result; }, isTouch : function(){ var _isTouchDevice = 'ontouchstart' in document.documentElement; return _isTouchDevice; } }; /* * [PC/Tablet] Main KeyVisual */ (function($){ var $fheader = $('#fheader'), $mv = $('#fmainVisual'), $list = $mv.find('.list'), nowIdx, _whole, _quarter,_half, _third, _mobileUI = false, speed = { duration: 800, queue: false, easing: 'easeInOutExpo' }, txtTimer = null; var mV = { init : function(speed){ if ($body.width() > 640){ if (_mobileUI){ mV.bindEvent(); _mobileUI = false; } _whole = parseInt($fheader.outerWidth(),10), _half = Math.ceil(_whole/2), _quarter = Math.ceil(_whole/4), _third = Math.ceil(_half/3); $mv.css({width : _quarter*4+10 ,overflow : 'hidden'}) $list.stop().animate({width :_quarter },speed); } else { $mv.css('width','auto'); $list.css('width','100%'); $list.find('>a').off(); _mobileUI = true; } }, //PC만 페이지로딩시 좌측에서 날아들어옴 2013-08-28 pcStart : function(){ if ($body.width() > 640){ $list.css('width',0); _whole = parseInt($fheader.outerWidth(),10), _half = Math.ceil(_whole/2), _quarter = Math.ceil(_whole/4), _third = Math.ceil(_half/3); $mv.css({width : _quarter*4+10 ,overflow : 'hidden'}) $list.stop().animate({width :_quarter },{ duration: 1200, queue: false, easing: 'easeInOutExpo' }); } }, reset: function(speed) { mV.init(speed); mV.txtHover(-1); $list.removeClass('on').find('>a').addClass('close').find('.num img').USimgNameChg({'src':['_on','_off']}); }, action : function(idx){ var $target = $list.eq(idx); $target.find('.num img').USimgNameChg({'src':['_off','_on']}); $target.siblings().find('.num img').USimgNameChg({'src':['_on','_off']}); $target.addClass('on').stop().animate({width : _half },speed); $target.siblings().removeClass('on').stop().animate({width : _third },speed); $list.find('>a').addClass('close'); $target.find('>a').removeClass('close'); nowIdx = idx; }, txtHover : function(idx){ (idx == -1) ? target = 5 : target = idx; $list.not(':eq('+target+')').find('.on').stop().fadeTo(400,0,function(){ $list.not(':eq('+target+')').find('.off').show().stop().fadeTo(1000,1); }); if (target < 4){ $list.eq(target).find('.off').stop().fadeTo(400,0,function(){ $(this).hide(); $list.eq(target).find('.on').css('display','block').stop().fadeTo(1000,1); }); } }, resize : function(){ $win.resize(function(){ mV.reset(0); }); }, bindEvent : function(){ if (!Detect.isTouch()){ $list.find('>a').on({ 'click mouseenter focusin' : function(e){ if ($(this).hasClass('close')){ clearTimeout(txtTimer); var $this = $(this); var idName = $this.parent('div').attr('id'); var targetIdx = idName.charAt(idName.length -1); txtTimer = setTimeout(function(){ mV.action(targetIdx,speed); mV.txtHover(targetIdx); },200) e.preventDefault(); } } }); $mv.on({ 'mouseleave' : function(){ mV.reset(); }, 'focusin' : function(e){ e.stopPropagation(); } }); $body.on('focusin', function(e) { mV.reset(); e.stopPropagation(); //e.preventDefault(); }); } else { $list.find('>a').on({ 'click' : function(e){ if($body.width() > 640 && $(this).hasClass('close')) { var idName = $(this).parent('div').attr('id'); var targetIdx = idName.charAt(idName.length -1); mV.action(targetIdx,speed); mV.txtHover(targetIdx); e.preventDefault(); } } }); } } }; $(function(){ if(Detect.isDesktop()){ mV.pcStart() } else { mV.init(); //PC만 페이지로딩시 좌측에서 날아들어옴 } mV.resize(); mV.bindEvent(); }) }(jQuery)); /*폴딩*/ $.fn.extend({ /* * IMG fileName & alt modify * @name : USimgNameChg * @use : $(a).USimgNameChg({ 'src' : ['_off','_on'], //앞 문자열을 뒤 문자열로 변경 'alt' : ['열림','닫힘'] }) */ USimgNameChg : function(options){ $(this).each(function(){ var $this = $(this); if (options.alt && options.alt.length == 2){ $this.attr('alt', $this.attr('alt').replace(options.alt[0], options.alt[1])); } if (options.src && options.src.length == 2){ $this.attr('src', $this.attr('src').replace(options.src[0], options.src[1])); } }); }, /* * selectBox * @name : USfoldingBox * @html : target > .ui-fold-btn //폴딩버튼으로 보통 a태그에 클래스 추가 * > .ui-fold-list //폴딩되는 영역으로 ul 혹은 div에 클래스 추가 */ USfoldingBox : function(options){ var selectArray = $(this), speed = { duration: 500, queue: false, easing: 'easeInOutExpo' }, defaults = { devide : false, //true 일 경우 셀렉트영역 mouseleave시 숨김처리 autoFocusEnter : false, //키보드포커스가 들어오면 자동펼침 _stateChange : '', //버튼 상태변화를 class, image로 지정 class는 on 추가/제거, image는 _on / _off _addEvent : false, //추가 개별 event _openEvent : false, _closeEvent : false }; var option = $.extend({},defaults,options); selectArray.each(function(){ var $folderBox = $(this), $selectList = $folderBox.find('.ui-fold-list'); if (option.devide){ //각 셀렉트박스를 개별인것 처럼 $folderBox.on({ 'mouseleave' : function(){ closeEvent(); } }) } if (option._addEvent){ option._addEvent(); } if (option.autoFocusEnter){ //btn에 focusIn 일때 자동펼침 $folderBox.find('.ui-fold-btn').on({ 'mouseenter focusin' : function(e){ ( $selectList.is(':visible') ) ? closeEvent() : openEvent(); e.preventDefault(); e.stopPropagation(); return false; } }); } else { //btn에 focusIn 일때 안 펼침 $folderBox.find('.ui-fold-btn').on({ 'click' : function(e){ ( $selectList.is(':visible') ) ? closeEvent() : openEvent(); e.preventDefault(); e.stopPropagation(); } }); } $folderBox.on('mousedown focusin', function(e){ e.stopPropagation(); }) $body.on('mousedown focusin', function(e) { closeEvent(); e.stopPropagation(); //e.preventDefault(); }); function openEvent(){ $folderBox.find('.ui-fold-btn').addClass('on'); if (option._openEvent){ speed.complete = option._openEvent; } $selectList.slideDown(speed); if (option._stateChange == 'image'){ $folderBox.find('.ui-fold-btn img').USimgNameChg({'src' : ['_off','_on'] }); } }; function closeEvent(){ $folderBox.find('.ui-fold-btn').removeClass('on'); if (option._closeEvent){ speed.complete = option._closeEvent; } $selectList.slideUp(speed); if (option._stateChange == 'image'){ $folderBox.find('.ui-fold-btn img').USimgNameChg({'src' : ['_on','_off'] }); } }; }); } }); /*소스 막기*/ document.onmousedown=right; document.onkeydown=keypressed; document.oncontextmenu=keypressed; function right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) { return false; } else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { return false; } return true; } function keypressed() { return false; } function processKey() { if( (event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) || (event.keyCode >= 112 && event.keyCode <= 123)) { event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; } } document.onkeydown = processKey; window.status = '**** 다양한 업종으로 변경가능합니다. http://postweb.co.kr ****';