forked from arielsalminen/ResponsiveSlides.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
responsiveslides.min.js
7 lines (7 loc) · 3.89 KB
/
responsiveslides.min.js
1
2
3
4
5
6
7
/*! ResponsiveSlides.js v1.53
* http://responsiveslides.com
* http://viljamis.com
*
* Copyright (c) 2011-2012 @viljamis
* Available under the MIT license
*//*jslint browser: true, vars: true, plusplus: true, indent: 2 */(function(e,t,n){e.fn.responsiveSlides=function(r){var s=e.extend({auto:!0,speed:500,timeout:4e3,pager:!1,thumb:!1,thumbSrc:!1,nav:!1,random:!1,pause:!1,pauseControls:!0,prevText:"Previous",nextText:"Next",maxwidth:"",navContainer:"",manualControls:"",namespace:"rslides",before:function(){},after:function(){}},r);return this.each(function(){n++;var o=e(this),u,a,f,l,c,h,p=0,d=o.children(),v=d.size(),m=parseFloat(s.speed),g=parseFloat(s.timeout),y=parseFloat(s.maxwidth),b=s.namespace,w=b+n,E=b+"_nav "+w+"_nav",S=b+"_here",x=w+"_on",T=w+"_s",N=b+"_thumbs",C=b+"_thumb",k=e("<ul class='"+b+"_tabs "+w+"_tabs' />"),L={"float":"left",position:"relative",opacity:1,zIndex:2},A={"float":"none",position:"absolute",opacity:0,zIndex:1},O=function(){var e=document.body||document.documentElement,t=e.style,n="transition";if(typeof t[n]=="string")return!0;u=["Moz","Webkit","Khtml","O","ms"];n=n.charAt(0).toUpperCase()+n.substr(1);var r;for(r=0;r<u.length;r++)if(typeof t[u[r]+n]=="string")return!0;return!1}(),M=function(t){s.before();if(O){d.removeClass(x).css(A).eq(t).addClass(x).css(L);p=t;setTimeout(function(){s.after()},m)}else d.stop().fadeOut(m,function(){e(this).removeClass(x).css(A).css("opacity",1)}).eq(t).fadeIn(m,function(){e(this).addClass(x).css(L);s.after();p=t})};s.thumb&&k.addClass(N);if(s.random){d.sort(function(){return Math.round(Math.random())-.5});o.empty().append(d)}d.each(function(e){this.id=T+e});o.addClass(b+" "+w);r&&r.maxwidth&&o.css("max-width",y);d.hide().css(A).eq(0).addClass(x).css(L).show();O&&d.show().css({"-webkit-transition":"opacity "+m+"ms ease-in-out","-moz-transition":"opacity "+m+"ms ease-in-out","-o-transition":"opacity "+m+"ms ease-in-out",transition:"opacity "+m+"ms ease-in-out"});if(d.size()>1){if(g<m+100)return;if(s.pager&&!s.manualControls){var _=[];d.each(function(t){var n=t+1,r,i;if(s.thumb){s.thumbSrc&&(r=e(this).find("[data-"+s.thumbSrc+"]").filter(":first").data(s.thumbSrc));if(!s.thumbSrc||r===null)r=e(this).find("img").filter(":first").attr("src")}s.thumb==="img"?i='<img src="'+r+'">':s.thumb==="bg"?i="<span class="+C+' style="background-image : url('+r+')" />':i=n;_+="<li><a href='#' class='"+T+n+"'>"+i+"</a>"+"</li>"});k.append(_);r.navContainer?e(s.navContainer).append(k):o.after(k)}if(s.manualControls){k=e(s.manualControls);k.addClass(b+"_tabs "+w+"_tabs")}(s.pager||s.manualControls)&&k.find("li").each(function(t){e(this).addClass(T+(t+1))});if(s.pager||s.manualControls){h=k.find("a");a=function(e){h.closest("li").removeClass(S).eq(e).addClass(S)}}if(s.auto){f=function(){c=setInterval(function(){d.stop(!0,!0);var e=p+1<v?p+1:0;(s.pager||s.manualControls)&&a(e);M(e)},g)};f()}l=function(){if(s.auto){clearInterval(c);f()}};s.pause&&o.hover(function(){clearInterval(c)},function(){l()});if(s.pager||s.manualControls){h.bind("click",function(t){t.preventDefault();s.pauseControls||l();var n=h.index(this);if(p===n||e("."+x).queue("fx").length)return;a(n);M(n)}).eq(0).closest("li").addClass(S);s.pauseControls&&h.hover(function(){clearInterval(c)},function(){l()})}if(s.nav){var D="<a href='#' class='"+E+" prev'>"+s.prevText+"</a>"+"<a href='#' class='"+E+" next'>"+s.nextText+"</a>";r.navContainer?e(s.navContainer).append(D):o.after(D);var P=e("."+w+"_nav"),H=P.filter(".prev");P.bind("click",function(t){t.preventDefault();var n=e("."+x);if(n.queue("fx").length)return;var r=d.index(n),i=r-1,o=r+1<v?p+1:0;M(e(this)[0]===H[0]?i:o);(s.pager||s.manualControls)&&a(e(this)[0]===H[0]?i:o);s.pauseControls||l()});s.pauseControls&&P.hover(function(){clearInterval(c)},function(){l()})}}if(typeof document.body.style.maxWidth=="undefined"&&r.maxwidth){var B=function(){o.css("width","100%");o.width()>y&&o.css("width",y)};B();e(t).bind("resize",function(){B()})}})}})(jQuery,this,0);