var featurelist = function(fobj,options) { function feature_slide(nr) { if (typeof nr == "undefined") { nr = visible_idx + 1; nr = nr >= total_items ? 0 : nr; } tabs.removeclass(onclass).addclass(offclass).filter(":eq(" + nr + ")").removeclass(offclass).addclass(onclass); output.stop(true, true).filter(":visible").hide(); output.filter(":eq(" + nr + ")").fadein("slow",function() { visible_idx = nr; }); } fobj = (typeof(fobj) == 'string')?$(fobj):fobj; fobj = $(fobj).eq(0); if(!fobj || fobj.size() == 0) return; //轮询间隔,默认2s var options = options || {}; var visible_idx = options.startidx || 0; var onclass = options.onclass || "current"; var offclass = options.offclass || ""; var speed = options.speed || 10000; options.pause_on_act = options.pause_on_act || "click"; options.interval = options.interval || 50000; var tabs = fobj.find(".f_tabs .f_tab"); var output = fobj.find(".f_out"); var total_items = tabs.length; //初始设定 output.hide().eq( visible_idx ).fadein("slow"); tabs.eq( visible_idx ).addclass(onclass); if (options.interval > 0) { var timer = setinterval(function () { feature_slide(); }, options.interval); output.mouseenter(function() {clearinterval( timer );}).mouseleave(function() {clearinterval( timer );timer = setinterval(function () {feature_slide();}, options.interval);}); if (options.pause_on_act == "mouseover") { tabs.mouseenter(function() { clearinterval( timer ); var idx = tabs.index($(this)); feature_slide(idx); }).mouseleave(function() { clearinterval( timer ); timer = setinterval(function () { feature_slide(); }, options.interval); }); } else { tabs.click(function() { clearinterval( timer ); var idx = tabs.index($(this)); feature_slide(idx); }); } } }