;(function($){ $.fn.powerSlider = function(options) { return this.each(function() { var defualts = { handle: "top", prevNext: true, Nav: true, myTitle: false, speed: 1000, delayTime: 5000, clickMode: "click", sliderNum: 1 }; var opts = $.extend({}, defualts, options), obj = $(this), index = 0, sliderBox = $(".sliderbox", obj), sliderLi = sliderBox.find("li"), sliderLiWidth = $(".sliderbox li:eq(0)").outerWidth(), liNum = sliderLi.length, len = (sliderLi.length) / (opts.sliderNum), len = Math.ceil(len), sliderNav = $(" .slidernav", obj), sliderText = $(" .slidertext", obj), prev = $(" .prev", obj), next = $(" .next", obj), sliderTimer, navHtml = '', textHtml = ''; for(var i = 0; i < len; i++) { } if(opts.handle == 'fadeTo') { if(opts.sliderNum<=1){ sliderLi.css({ "position": "absolute", "left": "0", "top": "0" }); }else{ sliderLi.each(function(i){ $(this).css({ "position":"absolute", "left":(i%opts.sliderNum)*(sliderLi.width()), "top":"0" }) }) } var nextLen = parseInt(opts.sliderNum -1); sliderBox.find("li:gt("+nextLen+")").hide(); } if(opts.Nav) { sliderNav.append(navHtml); } if(opts.sliderNum > 1) { sliderLi.css("float", "left"); } var slidertitle = sliderText.find("li"), sliderA = sliderNav.find("li"); slidertitle.eq(0).show(); sliderA.eq(0).addClass("current"), sliderLi.eq(0).addClass("current"); function showImg(i, index) { var sliderHeight = obj.height(), sliderWidth = obj.width(); slidertitle.hide().eq(index).show(); sliderA.removeClass("current").eq(index).addClass("current"), sliderLi.removeClass("current").eq(index).addClass("current"); if(opts.handle == 'top') { sliderBox.filter(":not(':animated')").animate({ "top": -sliderHeight * index }, opts.speed); } else if(opts.handle == 'left') { sliderLi.css("float", "left"); sliderBox.css("width", len * sliderWidth).filter(":not(':animated')").animate({ "left": -sliderWidth * index }, opts.speed); } else if(opts.handle == 'hide') { var j = index + 1; sliderLi.hide().slice(index * (opts.sliderNum), j * (opts.sliderNum)).show(); } else if(opts.handle == 'fadeTo') { sliderLi.slice(i*(opts.sliderNum),(i+1)*(opts.sliderNum)).fadeOut(opts.speed); sliderLi.slice(index*(opts.sliderNum),(index+1)*(opts.sliderNum)).filter(":not(':animated')").fadeIn(opts.speed); } else if(opts.handle == 'slideTo') { sliderLi.css("z-index", '1').filter(":not(':animated')").slideUp().slice(index*(opts.sliderNum),(index+1)*(opts.sliderNum)).css("z-index", "2").slideDown(opts.speed); } } sliderA.bind(opts.clickMode,function(){ index = $(this).index(); var i = sliderA.index($(".slidernav .current:eq(0)")); if(index != i) { showImg(i, index); } }).eq(0).trigger(opts.clickMode); if(len <= 1) { prev.hide(); next.hide(); } else { if(opts.prevNext) { prev.click(function() { var i = index; index -= 1; if(index == -1) { index = len - 1 }; showImg(i, index); }); next.click(function() { auto(); }); } } function auto() { var i = index; index = (index + 1) % len; showImg(i, index); } var settime; obj.hover(function(){ clearInterval(settime); },function(){ settime = setInterval(function(){ auto(); },opts.delayTime); }).trigger("mouseleave"); }); }; })(jQuery);