/* * plugin:jquery.newsSticker.js * version:1.0(2011.04.07) * update:2010.12.20 * requires:jQuery v1.3.2 later * author:Manabu Kushimoto(http://web-park.org) */ $(function(){ $.fn.newsSticker = function(options){ var op=$.extend($.fn.newsSticker.defaults,options),$list=$("#"+op.list),$listChild=$list.children(),listChildLength=$listChild.length,$control=$("#"+op.control),$controlNext=$(".next",$control),$controlPrev=$(".prev",$control),i=0; function stickerNext(){ if(listChildLength==1){ }else{ if(i==(listChildLength-1)){ i=0; $list.animate({ top:i*op.height+"px" },op.speed); }else{ plus=++i*op.height; $list.animate({ top:-plus+"px" },op.speed); } } }; function stickerPrev(){ if(listChildLength==1){ }else{ if(i==0){ i=(listChildLength-1); $list.animate({ top:-(i*op.height)+"px" },op.speed); }else{ minus=--i*op.height; $list.animate({ top:-minus+"px" },op.speed); } } }; $controlNext.click(function(){ stickerNext(); return false; }); $controlPrev.click(function(){ stickerPrev(); return false; }); }; $.fn.newsSticker.defaults = { list:"stickerList", control:"stickerControl", speed:300, height:27 }; $("#newsSticker").newsSticker(); });