/* * **/ (function($){ function renovationslide(ele, options){ this.i = $(ele); this.n = this.i.find("li"); this.a = this.n.length; this.p = this.i.find('.pagation-box'); this.r = this.i.find('.btn_left'); this.g = this.i.find('.btn_right'); this.l = 0; for (var i = 0; i < this.a; i++) { this.p.append(''); } this.ps = this.p.find('.page'); this.t(); this.options = $.extend({ autoplay:true, speed:3000 }, options) //拓展 var _this = this; this.options.autoplay?this.timer = window.setinterval(function() { _this.l++, _this.l >= _this.a && (_this.l = 0), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }, _this.options.speed):null; this.r.bind("click", function() { _this.l--, 0 > _this.l && (_this.l = _this.a - 1), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }).bind('mousedown', function() { _this.options.autoplay?window.clearinterval(_this.timer):null; }).bind('mouseup', function() { _this.options.autoplay?_this.timer = window.setinterval(function() { _this.l++, _this.l >= _this.a && (_this.l = 0), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }, _this.options.speed):null; }) this.g.bind("click", function() { _this.l++, _this.l >= _this.a && (_this.l = 0), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }).bind('mousedown', function() { _this.options.autoplay?window.clearinterval(_this.timer):null; }).bind('mouseup', function() { _this.options.autoplay?_this.timer = window.setinterval(function() { _this.l++, _this.l >= _this.a && (_this.l = 0), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }, _this.options.speed):null; }) this.c(); } renovationslide.prototype = { //分页按钮点击轮播 c : function() { var _this = this; this.ps.bind('click', function() { var _t = $(this); _this.l = parseint(_t.data('index')); _this.t(); _t.addclass('active').siblings().removeclass('active'); }).bind('mousedown', function() { _this.options.autoplay?window.clearinterval(_this.timer):null; }).bind('mouseup', function() { _this.options.autoplay?_this.timer = window.setinterval(function() { _this.l++, _this.l >= _this.a && (_this.l = 0), _this.t(), _this.ps.eq(_this.l).addclass('active').siblings().removeclass('active') }, _this.options.speed):null; }) }, t : function() { var _this = this; var _e = []; for (var t = 0; 5 > t; t++) { switch (t) { case 0: var e = _this.l - 2; _e.push(e = e >= 0 ? e : e + _this.a); e = e >= 0 ? e : e + _this.a, _this.n.eq(e).attr("class", "slide_left_out"); break; case 1: var e = _this.l - 1; _e.push(e = e >= 0 ? e : e + _this.a); e = e >= 0 ? e : e + _this.a, _this.n.eq(e).attr("class", "slide_left"); break; case 2: _e.push(_this.l); _this.n.eq(_this.l).attr("class", "slide_show"); break; case 3: var e = _this.l + 1; _e.push(e = _this.a > e ? e : e - _this.a); e = _this.a > e ? e : e - _this.a, _this.n.eq(e).attr("class", "slide_right"); break; case 4: var e = _this.l + 2; _e.push(e = _this.a > e ? e : e - _this.a); if (this.a == 3) { //兼容图片数量最少为3 e = _this.a > e ? e : e - _this.a, _this.n.eq(e).attr("class", "slide_left"); } else { e = _this.a > e ? e : e - _this.a, _this.n.eq(e).attr("class", "slide_right_out"); } break; } } for (var i = 0; i < _this.a; i++) { if (_e.indexof(i) == -1) { _this.n.eq(i).removeclass('slide_show slide_left slide_right_out').addclass('slide_left_out'); } } } } $.fn.renovationslide = function(options){ this.each(function(i,ele){ new renovationslide(ele, options) }) return this; } })(jquery)