(function(b){function a(c,d){this._init(c,d)}a.prototype._init=function(c,d){([]).push.apply(this,array.prototype.slice.apply(c));this._options={auto:true,speed:20,sidectrl:true,"defaultview":0,interval:3000,activeclass:"active",bottomctrl:true,};var e=this;b.extend(true,this._options,d);b(this).each(function(g,j){var k=b(this),i=k.find(".js-silder-ctrl"),l=k.find(".silder-main");k.addclass("js-silder");if(l.length==0){var h=b('
');l=h.children(".silder-main");k.append(l);j.sildermain=l}else{j.sildermain=l;if(b(e).length>1){(function(m,n){settimeout(function(){m._calcsildermainwh(n)},550)})(e,k)}else{e._calcsildermainwh(k)}}if(i.length==0){i=b('');k.append(i)}j.silderctrl=i;j.index=e._options.defaultview||0;if(e._options.data&&b.isarray(e._options.data)){(k).addclass("js-silder");e._createsilderimg()}j.imgslen=j.sildermain.children(".silder-main-img").length;var f=k.find(".silder-main-img");f.each(function(m,n){if(m!=e._options.defaultview){b(n).css("left",f.eq(0).width())}})});this._createcontrollbtns();if(this._options.auto){this._autoplay()}b(this).each(function(f,g){e._setcontrollbtnclass(g.silderctrl.find(".silder-ctrl-con").eq(e._options.defaultview))});b(window).on("resize",function(){e._calcsildermainwh()})};a.prototype._calcsildermainwh=function(g,e,c){if(g&&g.length&&g.length>0){var f=g[0],h=f.sildermain,d=c||h.children(".silder-main-img").eq(0).find("img").height();console.log(h.children(".silder-main-img").eq(0).find("img").height()),h.height(d)}else{b(this).each(function(i,k){var l=k.sildermain,j=c||l.children(".silder-main-img").eq(0).find("img").height();l.height(j)})}};a.prototype._createsilderimg=function(){var c=this,d=this._options.data;b(c).each(function(f,g){var e=b(this),i=this.sildermain,h="";b.each(d,function(l,j){var k=j.alt?j.alt:"";sildermainimg=b(''),elea=null,img=b('');if(l==0){img.on("load",function(m){c._calcsildermainwh(b(this).width(),b(this).height())})}if(j.link){elea=b('');sildermainimg.append(elea.append(img))}else{sildermainimg.append(img)}i.append(sildermainimg)})})};a.prototype._createcontrollbtns=function(){var c=this;b(c).each(function(h,e){var k=b(this),f=this.sildermain,l=this.silderctrl,m=f.children(".silder-main-img").length,g=0,d="";if(c._options.sidectrl){d+='<'}if(c._options.bottomctrl){for(;g";d+=j}}if(c._options.sidectrl){d+='>'}l.append(b(d))});this._ctrlbtnbindevents()};a.prototype._ctrlbtnbindevents=function(){var c=this;b(c).each(function(d,e){this.silderctrl.children().on("click",function(){var f=b(e).width(),h=e.sildermain.children(".silder-main-img");if(b(this).hasclass("silder-ctrl-next")){c._play(b(e))}else{if(b(this).hasclass("silder-ctrl-prev")){a.animate(h[e.index],{"left":f},null,c._options.speed);e.index-=1;if(e.index<0){e.index=e.imgslen-1}h[e.index].style.left=-f+"px";a.animate(h[e.index],{"left":0},null,c._options.speed);c._setcontrollbtnclass(b(this).parent().find(".silder-ctrl-con").eq(e.index))}else{var g=b(this).children("span").html()*1-1;if(g>e.index){a.animate(h[e.index],{"left":-f},null,c._options.speed);h[g].style.left=f+"px"}else{if(gd.imgslen-1){d.index=0}h.eq(d.index)[0].style.left=e+"px";a.animate(h.eq(d.index)[0],{"left":0},null,this._options.speed);this._setcontrollbtnclass(d.silderctrl.find(".silder-ctrl-con").eq(d.index))};a.prototype._autoplay=function(){var e=this,d=b(e),c=isnan(e.interval*1)?3000:e.interval;if(e._options.auto){d.each(function(g,h){clearinterval(this.timer);var f=b(this);this.timer=setinterval(function(){e._play(f)},c);f.hover(function(){clearinterval(this.timer)},function(){clearinterval(this.timer);this.timer=setinterval(function(){e._play(f)},c)})})}};a.prototype._setcontrollbtnclass=function(d){var c=typeof this._options.activeclass!="string"?"active":this._options.activeclass;d.addclass(c).siblings(".silder-ctrl-con").removeclass(c)};a.animate=function(g,e,c,f){var d=this;clearinterval(g.timer);g.timer=setinterval(function(){var i=true;for(var h in e){var k=parseint(b(g).css(h)),j=(parseint(e[h])-k)/10;j=j>0?math.ceil(j):math.floor(j);if(k!=e[h]){i=false}if(h=="zindex"){g.style.zindex=e[h]}else{g.style[h]=k+j+"px"}}if(i){clearinterval(g.timer);if(c){c.call(window)}}},f||20)};b.silder=function(c,d){c=b(c);new a(c,d);return c};b.fn.silder=function(c){console.log(new a(this,c));
return this}})(jquery);