; (function ($, window, document, undefined) { function scroll() { this.num = 0; this.obj = this; this.dome = null; this.dome_ul = null; this.dome_li_lent = null; this.full_wit = null; this.timer = null; this.next = null; this.pre = null; this.settings = { times: 2000, way_annimate: 'ease-out', }; } scroll.prototype.init = function (opt) { var this = this; var pos_left = null; this.options = $.extend({}, this.settings, opt) this.dome = this.options.dome; this.dome_ul = this.dome.find('ul'); this.dome_ul.append(this.dome_ul.find('li:first').clone()) this.dome_li_lent = this.dome_ul.find('li').length; for (var b = 0; b < this.dome_li_lent; b++) { this.dome.find('.foucdocs').append(''); } this.dome.find('.foucdocs span').eq(0).addclass('focus_on'); this.next = this.dome.find(this.options.next); this.pre = this.dome.find(this.options.pre); this.getwidth(); this.timer = setinterval(gos, this.options.times); $(window).resize(function () { this.getwidth(); }) this.dome.hover(function () { this.next.show(); this.pre.show(); clearinterval(this.timer); }, function () { this.next.hide(); this.pre.hide(); this.timer = setinterval(gos, this.options.times); }) function gos() { this.num++; if (this.num > (this.dome_li_lent - 1)) { this.num = 0; } this.dome.find('.foucdocs span').eq(this.num).addclass('focus_on').siblings('span').removeclass('focus_on') pos_left = (this.full_wit * this.num); this.dome_ul.stop().animate({left: -pos_left + 'px'}, this.options.way_annimate); } this.dome.find('.foucdocs span').mouseover(function () { this.num=$(this).index(); pos_left = (this.full_wit * this.num); this.dome_ul.stop().animate({left: -pos_left + 'px'}, this.options.way_annimate); $(this).addclass('focus_on').siblings('span').removeclass('focus_on'); }) this.next.click(function () { gos(); }) this.pre.click(function () { this.num--; if (this.num < 0) { this.num = this.dome_li_lent - 1; } this.dome.find('.foucdocs span').eq(this.num).addclass('focus_on').siblings('span').removeclass('focus_on') pos_left = (this.full_wit * this.num); this.dome_ul.stop().animate({left: -pos_left + 'px'}, this.options.way_annimate); }) } scroll.prototype.getwidth = function () { this.full_wit = $(window).width(); this.dome_ul.css({ width: this.full_wit * this.dome_li_lent + 'px', }) this.dome_ul.find('li').css({ width: this.full_wit + 'px', }) } window.scroll = function (opt) { var litscoll = new scroll(); litscoll.init(opt); } })(jquery, window, document);