/********************************** * 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锟斤拷支锟街o拷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);