/********************************************************************************* Ç÷¯±×ÀÎ : jquery.dbNavi2DMove.js (ver 1.0) Á¦ÀÛÀÚ : Copyright ¨Ï 2012 by µðÀÚÀÎºí·¢(http://designblack.com) ¶óÀ̼¾½º : µµ¸ÞÀζóÀ̼¾½º ±âŸ : ±â¼ú¹®¼­, »ç¿ë¹ý ¹× ¶óÀ̼¾½º´Â ȨÆäÀÌÁö¸¦ Âü°íÇϼ¼¿ä ¹®¼­Á¤º¸´Â ¼öÁ¤Çϰųª »èÁ¦ ÇÒ ¼ö ¾ø½À´Ï´Ù *********************************************************************************/ ;(function($){ $.fn.dbNavi2DMove=function(options){ //¿É¼Ç°ª var opt={ pageNum:null, //ÆäÀÌÁöÀνÄ(¸ÞÀθ޴º) subNum:null, //ÆäÀÌÁöÀνÄ(¼­ºê¸Þ´º) motionType:'none', //¸ð¼ÇŸÀÔ(fade,slide,none) motionSpeed:150, //¸ð¼Ç¼Óµµ(¹Ð¸®ÃÊ) moveHeight:-21, //À̵¿³ôÀÌ°ª moveSpeed:200, //½ºÇǵå delayTime:100 //¸Þ´º ¾Æ¿ô µô·¹À̽ð£(¹Ð¸®ÃÊ) }; $.extend(opt,options); return this.each(function(){ var $this=$(this); var $mainList=$this.find('.dMain'); var $subList=$mainList.find('.dSub'); var listNum=$mainList.length; var fixMain=opt.pageNum-1; var fixSub=opt.subNum-1; var currentMain=fixMain; var currentSub=fixSub; var timerId; init(); function init(){ setCss(); setSwapInfo(); setMouseEvent(); setAnimation(); } //out,over dataÁ¤º¸´ã±â function setSwapInfo(){ //img var _img=$this.find('img'); for(var i=0;i<_img.length;i++){ var _mc=_img.eq(i); _mc.data('out_img',_mc.attr('src')); if(String(_mc.data('out_img')).search('_off')!=-1){ _mc.data('over_img',_mc.data('out_img').replace('_off','_on')); } } } //css function setCss(){ $mainList.find('>a').css({position:'relative'}) $mainList.find('>a>img').css({position:'relative'}); if($mainList.find('>a>img').css('top')=='auto'){ $mainList.data('startY',0); }else{ $mainList.data('startY',$mainList.find('>a>img').css('top')); } $mainList.find('ul').hide(); } //event function setMouseEvent(){ $this.bind('mouseenter',function(){ clearTimeout(timerId); }); $this.bind('mouseleave',function(){ timerId=setTimeout(setAnimation,opt.delayTime); }); $mainList.bind('mouseenter keyup',function(){ currentMain=$(this).index(); if(currentMain!=fixMain){ currentSub=null; } setAnimation(); }); $mainList.bind('mouseleave',function(){ if(currentMain!=fixMain){ currentSub=fixSub; } currentMain=fixMain; }); $subList.bind('mouseenter keyup',function(){ currentSub=$(this).index(); setAnimation(); }); $subList.bind('mouseleave',function(){ var _currentMain=$(this).parents('.dMain').index(); if(_currentMain==fixMain){ currentSub=fixSub; }else{ currentSub=null; } }); } function setAnimation(){ for(var i=0;ia>img').stop(true,true).animate({top:opt.moveHeight},opt.moveSpeed); switch(opt.motionType){ case 'fade': _mc.find('>ul').stop(true,true).fadeIn(opt.motionSpeed); break; case 'slide': _mc.find('>ul').stop(true,true).slideDown(opt.motionSpeed); break; default: _mc.find('>ul').show(); } //¼­ºê for(var k=0;k<_mc.find('.dSub').length;k++){ var _subA=_mc.find('.dSub').eq(k).find('a'); if(currentSub==k){ _subA.addClass('select'); var _subImg=_subA.find('img'); if(_subImg){ swapImg(_subImg,_subImg.data('over_img')); } }else{ _subA.removeClass('select'); var _subImg=_subA.find('img'); if(_subImg){ swapImg(_subImg,_subImg.data('out_img')); } } } }else{ _mc.find('>a>img').stop(true,true).animate({top:$mainList.data('startY')},opt.moveSpeed); switch(opt.motionType){ case 'fade': _mc.find('ul').stop(true,true).fadeOut(opt.motionSpeed/2); break; case 'slide': _mc.find('ul').stop(true,true).slideUp(opt.motionSpeed/2); break; default: _mc.find('ul').hide(); } } } } //on,off±³Ã¼ function swapImg(_mc,_arg){ if(_arg){ _mc.attr('src',_arg); } } }) } })(jQuery)