-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.slides.min.js
5 lines (5 loc) · 2.27 KB
/
jquery.slides.min.js
1
2
3
4
5
(function(b){b.fn.jscoin_slide=function(t){var c,q=b.extend({effect:"fade"},t),d=0,m,j,f,o,n,k,l=null,s=function(a){if(l==null)if(!(a==-1&&d==0))if(!(a==1&&d==m-1)){j=c.children("img:eq("+d+")");f=c.children("img:eq("+(d+a)+")");switch(q.effect){case "fade":j.fadeOut();f.fadeIn();break;case "flip":j.slideUp();f.slideDown();break;case "slide":f.css("left",a*n+"px").show();l=setInterval(function(){r(a)},1);break;case "slideUp":f.css("top",a*k+"px").show();l=setInterval(function(){r(a)},1)}d+=a;p()}},
r=function(a){var e=j.position(),g=f.position(),h,i;switch(q.effect){case "slide":if(e.left==-n*a){clearInterval(l);l=null}switch(a){case 1:h=Math.max(e.left-50*a,-n);i=Math.max(g.left-50*a,2);break;case -1:h=Math.min(e.left-50*a,n);i=Math.min(g.left-50*a,2)}j.css("left",h+"px");f.css("left",i+"px");break;case "slideUp":if(e.top==-k*a){clearInterval(l);l=null}switch(a){case 1:h=Math.max(e.top-20*a,-k);i=Math.max(g.top-20*a,2);break;case -1:h=Math.min(e.top-20*a,k);i=Math.min(g.top-20*a,2)}j.css("top",
h+"px");f.css("top",i+"px")}},p=function(){var a="",e=m.toString().length-(d+1).toString().length;a+=Array(e+1).join("0")+(d+1)+" / "+m;b(o).html(a)};return this.each(function(){c=b(this);m=c.children("img").size();c.children("img:gt(0)").hide();n=c.width();k=c.height();c.css("height",k+30+"px");var a=document.createElement("div");a.className="nav";a.style.marginTop=k+"px";c.append(a);var e=document.createElement("button");e.className="prev";b(e).html("◄");var g=document.createElement("button");
g.className="play";b(g).html("⁍");g=document.createElement("button");b(g).html("►");g.className="next";var h=document.createElement("button");h.className="first";b(h).html("∣◄");var i=document.createElement("button");b(i).html("►∣");i.className="last";o=document.createElement("span");o.className="counter";p();b(a).append(h).append(e).append(g).append(i).append(o);b(e).bind("click",function(){s(-1)});b(g).bind("click",function(){s(1)});b(h).bind("click",function(){if(d!=
0){j=c.children("img:eq("+d+")");f=c.children("img:first");j.hide();f.css("left","2px").css("top","2px").show();d=0;p()}});b(i).bind("click",function(){if(d!=m-1){j=c.children("img:eq("+d+")");f=c.children("img:last");j.hide();f.css("left","2px").css("top","2px").show();d=m-1;p()}})})}})(jQuery);