/********************************** * tabso * copyright (c) yeso! * date: 2010-07-28 ˵���� * ӧ�ö������ϊ��ǩ��ť��ֱ�ӹ�Ԫ�أ��ҹ�Ԫ���ڲ����������ǰ�ťԪ�� * example: $( ".menus_wrap" ).tabso({ cntselect:".content_wrap",tabevent:"mouseover" }); * cntselect:���ݿ��ֱ�ӹ�Ԫ�ص� jq ѡ���� * tabevent:�����¼��� * tabstyle:�л���ʽ����ȡֵ��"normal" "fade" "move" "move-fade" "move-animate" * direction:�ƶ����򡣿�ȡֵ��"left" "top" ��tabstyleϊ"move"��"move-fade" "move-animate"ʱ��ч�� * animethod:��������������ч���������磺easing��֧�֣�tabstyleϊ"move-animate"ʱ��ч�� * anispeed:�����ٶ� * onstyle:�˵�ѡ����ʽ�� **********************************/ ;(function($){ $.fn.tabso=function( options ){ var opts=$.extend({},$.fn.tabso.defaults,options ); return this.each(function(i){ var _this=$(this); var $menus=_this.children( opts.menuchildsel ); var $container=$( opts.cntselect ).eq(i); if( !$container) return; if( opts.tabstyle=="move"||opts.tabstyle=="move-fade"||opts.tabstyle=="move-animate" ){ var step=0; if( opts.direction=="left"){ step=$container.children().children( opts.cntchildsel ).outerwidth(true); }else{ step=$container.children().children( opts.cntchildsel ).outerheight(true); } } if( opts.tabstyle=="move-animate" ){ var animateargu=new object(); } $menus[ opts.tabevent]( function(){ var index=$menus.index( $(this) ); $( this).addclass( opts.onstyle ) .siblings().removeclass( opts.onstyle ); switch( opts.tabstyle ){ case "fade": if( !($container.children( opts.cntchildsel ).eq( index ).is(":animated")) ){ $container.children( opts.cntchildsel ).eq( index ).siblings().css( "display", "none") .end().stop( true, true ).fadein( opts.anispeed ); } break; case "move": $container.children( opts.cntchildsel ).css(opts.direction,-step*index+"px"); break; case "move-fade": if( $container.children( opts.cntchildsel ).css(opts.direction)==-step*index+"px" ) break; $container.children( opts.cntchildsel ).stop(true).css("opacity",0).css(opts.direction,-step*index+"px").animate( {"opacity":1},opts.anispeed ); break; case "move-animate": animateargu[opts.direction]=-step*index+"px"; $container.children( opts.cntchildsel ).stop(true).animate( animateargu,opts.anispeed,opts.animethod ); break; default: $container.children( opts.cntchildsel ).eq( index ).css( "display", "block") .siblings().css( "display","none" ); } }); $menus.eq(0)[ opts.tabevent ](); }); }; $.fn.tabso.defaults={ cntselect : ".content_wrap", tabevent : "mouseover", tabstyle : "normal", direction : "top", animethod : "swing", anispeed : "fast", onstyle : "current", menuchildsel : "*", cntchildsel : "*" }; })(jquery);