forked from edtalmadge/Agile-Carousel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagile_carousel.a1.1.min.js
19 lines (19 loc) · 9.35 KB
/
agile_carousel.a1.1.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function(e){e.fn.agile_carousel=function(a){a=e.extend({timer:0,continuous_scrolling:!1,transition_type:"slide",transition_time:600,number_slides_visible:1,change_on_hover:"",control_set_1:"",control_set_2:"",control_set_3:"",control_set_4:"",control_set_5:""},a);return this.each(function(){function w(a){if(ba!==""){m="ac_click";var c=ba.split(",");e.inArray(a,c)!=-1&&(m="ac_hover")}return m}function ca(a){if(da===!1&&b<2){if(a==1){if(G>0)q.addClass("ac_disabled"),q.data("options").disabled=!0;if(H>
0)r.addClass("ac_disabled"),r.data("options").disabled=!0}else{if(G>0)q.removeClass("ac_disabled"),q.data("options").disabled=!1;if(H>0)r.removeClass("ac_disabled"),r.data("options").disabled=!1}if(a==d){if(I>0)s.addClass("ac_disabled"),s.data("options").disabled=!0;if(J>0)u.addClass("ac_disabled"),u.data("options").disabled=!0}else{if(I>0)s.removeClass("ac_disabled"),s.data("options").disabled=!1;if(J>0)u.removeClass("ac_disabled"),u.data("options").disabled=!1}}if(da===!1&&b>1){if(a<=b){if(G>0)q.addClass("ac_disabled"),
q.data("options").disabled=!0;if(H>0)r.addClass("ac_disabled"),r.data("options").disabled=!0}else{if(G>0)q.removeClass("ac_disabled"),q.data("options").disabled=!1;if(H>0)r.removeClass("ac_disabled"),r.data("options").disabled=!1}if(a>=d-b+R){if(I>0)s.addClass("ac_disabled"),s.data("options").disabled=!0;if(J>0)u.addClass("ac_disabled"),u.data("options").disabled=!0}else{if(I>0)s.removeClass("ac_disabled"),s.data("options").disabled=!1;if(J>0)u.removeClass("ac_disabled"),u.data("options").disabled=
!1}}}function S(a){g.find(".ac_selected").removeClass("ac_selected");g.find(".slide_number_"+a).addClass("ac_selected")}function z(a){K=e(a)[0];if(K.disabled!==!0){j=K.button_action;a=K.go_to;f!==!1&&(h=f);T=h-1;A=e(B).eq(T);b<2&&(j=="next"&&h<d?f=h+1:j=="next"&&h==d&&(f=1),j=="previous"&&h>1?f=h-1:j=="previous"&&h==1&&(f=d));if(b>1)if(j=="next"&&h<d-b+R?f=D[Math.ceil(h/b)]:j=="next"&&h>=d-b+R&&b>1&&(f=1),j=="previous"&&h>b&&b>1){var c=Math.floor(h/b);c-=1;f=D[c]}else j=="previous"&&h<=b&&b>1&&(f=
pa);j=="direct"&&(f=a);U=f-1;y=e(B).eq(U);S(f);ea>0&&V.html(f);if(U!=T){W=="slide"&&b>1&&E.stop().animate({left:(f*n-n)*-1+"px"},{duration:L});if(W=="slide"&&b==1){a="";if(j=="next"||f>h&&j=="direct")y.css({top:0,left:n}),a=n*-1;if(j=="previous"||f<h&&j=="direct")y.css({top:0,left:n*-1}),a=n;A.stop().animate({left:a+"px"},{duration:L,complete:qa});y.stop().animate({left:"0px"},{duration:L})}W=="fade"&&b==1&&(B.not(A,y).css({top:"-5000px",left:0,"z-index":0,opacity:0}),j&&(y.css({top:0,left:0,"z-index":20}),
A.css({"z-index":10,opacity:1})),y.stop().animate({opacity:1},{duration:L,complete:ra}))}}ca(f);S(f)}function X(){if(v.length>0)v.html("play"),v.data("options").paused=!0,v.addClass("play_button");clearInterval(F)}function fa(){z(Y)}var d=0,x="",M="",N="",O="",P="",ga="",ha="",ia="",ja="",ka="",la="",ma="",m="ac_click",K="",j="",h="",f=!1,T="",U="",A="",y="",da=a.continuous_scrolling,Q=a.carousel_outer_width,sa=a.carousel_outer_height,o=a.carousel_data,ba=a.change_on_hover,n=a.slide_width,na=a.slide_height,
p=a.control_set_1,Z=a.control_set_2,ta=a.control_set_3,ua=a.control_set_4,va=a.control_set_5,wa=a.no_control_set,oa=a.persistent_content,b=a.number_slides_visible,W=a.transition_type,L=a.transition_time,$=a.timer,C="",k="",l=k="",Y="",F="";e.each(o,function(){d++});for(var R=d%b,D=[],C="",i=0,c=0,c=0;c<d;c++)c===0&&(N+="<div class='group_numbered_buttons_container button_container'>"),k=Math.floor((c+1)/b)*b+1,k!==C&&k<=d&&(D[i]=k,N+="<div class='slide_number_"+k+" group_numbered_button slide_button "+
w("group_numbered_buttons")+'\' data-options=\'{"button_type":"group_numbered_button","button_action":"direct","go_to":'+k+', "trigger_type":"'+m+'","disabled": false}\'>'+(i+1)+"</div>",C=k,i++),c===d-1&&(N+="</div>");ga+='<span class=\'pause_button slide_button pause\' data-options=\'{"button_type":"pause_button","trigger_type": "none","disabled": false,"paused": false}\'>Pause</span>';ha+="<span class='previous_next_button previous_button slide_button "+w("previous_button")+'\' data-options=\'{"button_type":"previous_button","button_action":"previous","trigger_type": "'+
m+'","disabled": false}\'>Prev</span>';ia+="<span class='previous_next_button next_button slide_button "+w("next_button")+'\' data-options=\'{"button_type":"next_button","button_action":"next","trigger_type": "'+m+'","disabled": false}\'>Next</span>';ja+="<div class='hover_previous_next_button hover_previous_button slide_button "+w("hover_previous_button")+'\' data-options=\'{"button_type":"hover_previous_button","button_action":"previous","trigger_type": "'+m+"\",\"disabled\": false}'><span style='opacity: 0;' class='hover_previous_next_button_inner'>Prev</span></div>";
ka+="<div class='hover_previous_next_button hover_next_button slide_button "+w("hover_next_button")+'\' data-options=\'{"button_type":"hover_next_button","button_action":"next","trigger_type": "'+m+"\",\"disabled\": false}'><span style='opacity: 0;' class='hover_previous_next_button_inner'>Next</span></div>";la+="<span class='slide_count'>"+d+"</span>";ma+="<span class='current_slide_number'>1</span>";x+="<div class='agile_carousel' style='overflow: hidden; position: relative; width: "+Q+"px; height: "+
sa+"px;'>";var g=e(this),c=1,aa;for(aa in o)if(o.hasOwnProperty(aa))k=o[aa],C=k.content,Q=k.thumbnail_button,k=k.content_button,c===1&&(x+="<div class='slides' style='width: "+n*d+"px; height: "+na+"px;'>"),C&&(x+="<div class='slide_"+c+" slide' style='border: none; margin: 0; padding: 0; height: "+na+"px; width: "+n+"px;'>"+C+"</div>"),c===d&&(x+="</div>"),c==1&&(M+="<div class='numbered_buttons_container button_container'>"),M+="<div class='slide_number_"+c+" numbered_button slide_button "+w("numbered_buttons")+
'\' data-options=\'{"button_type":"numbered_button","button_action":"direct","go_to":'+c+', "trigger_type":"'+m+'","disabled": false}\'>'+c+"</div>",c==d&&(M+="</div>"),Q&&(c==1&&(O+="<div class='thumbnail_buttons_container button_container'>"),O+="<div class='slide_number_"+c+" thumbnail_button slide_button "+w("thumbnails")+'\' data-options=\'{"button_type":"thumbnail_button","button_action":"direct","go_to":'+c+',"trigger_type": "'+m+'","disabled": false}\'>'+Q+"</div>",c==d&&(O+="</div>")),
k&&(c==1&&(P+="<div class='content_buttons_container button_container'>"),P+="<div class='slide_number_"+c+" content_button_"+c+" content_button slide_button "+w("content_buttons")+'\' data-options=\'{"button_type":"content_button","button_action":"direct","go_to":'+c+',"trigger_type": "'+m+"\",\"disabled\": false}'><div class='content_button_inner'>"+k+"</div></div>",c==d&&(P+="</div>")),c++;o=function(a,c){var b="";if(a!==""){c&&(b+="<div class='control_set_"+c+" control_set'><div class='control_set_"+
c+"_inner control_set_inner'>");var d=a.split(",");for(i=0;i<d.length;i++)d[i]=="numbered_buttons"&&(b+=M),d[i]=="group_numbered_buttons"&&(b+=N),d[i]=="thumbnails"&&(b+=O),d[i]=="content_buttons"&&(b+=P),d[i]=="pause_button"&&(b+=ga),d[i]=="previous_button"&&(b+=ha),d[i]=="next_button"&&(b+=ia),d[i]=="hover_previous_button"&&(b+=ja),d[i]=="hover_next_button"&&(b+=ka),d[i]=="slide_count"&&(b+=la),d[i]=="current_slide_number"&&(b+=ma);c&&(b+="</div></div>");x+=b}};a.control_set_1&&o(p,1);a.control_set_2&&
o(Z,2);a.control_set_3&&o(ta,3);a.control_set_4&&o(ua,4);a.control_set_5&&o(va,5);a.no_control_set&&o(wa);oa&&(x+=oa);x+="</div>";g.html(x);var B=g.find(".slide"),E=g.find(".slides");g.find(".slide_button");p=g.find(".agile_carousel");g.find(".previous_button, .hover_previous_button");g.find(".next_button, .hover_next_button");var q=g.find(".previous_button"),G=q.length,r=g.find(".hover_previous_button"),H=r.length,s=g.find(".next_button"),I=s.length,u=g.find(".hover_next_button"),J=u.length,V=g.find(".current_slide_number"),
ea=V.length;b==1&&(B.eq(0).css({position:"absolute",top:0,left:0}),B.slice(1,d).css({position:"absolute",top:"-5000px",left:0}),E.css("width",n+"px"));if(b>1){p.css("width",b*n+"px");p=0;for(p=1;p<=d;p++)B.eq(p).css({position:"absolute",top:0,left:n*p+"px"})}var ra=function(){A.css({"z-index":10,top:-5E3})},qa=function(){A.css({position:"absolute",top:"-5000px",left:0})};ca(1);ea>0&&V.html(1);S(1);var h=1,pa=D[D.length-1],p=g.find(".ac_click"),Z=g.find(".ac_hover");$!==0&&(F=setInterval(fa,$));var v=
g.find(".pause_button");e(p).click(function(){X();if(g.find(":animated").length<1)z(e(this).data().options);else if(l=e(this),l.data("options").button_action!="next"&&l.data("options").button_action!="previous")t=setInterval(function(){E.find(":animated").length<1&&(z(l.data().options),clearInterval(l.data("options").timeout))},30),l.data("options").timeout=t});e(Z).hover(function(){X();E.find(":animated").length<1?z(e(this).data().options):(l=e(this),t=setInterval(function(){E.find(":animated").length<
1&&(z(l.data().options),clearInterval(l.data("options").timeout))},30),l.data("options").timeout=t)},function(){l=e(this);clearInterval(l.data("options").timeout)});Y={button_action:"next",button_type:"pause",disabled:!1,trigger_type:"ac_click"};v.click(function(){var a=e(this);a.data("options").paused===!0?(clearInterval(F),v.html("pause"),v.data("options").paused=!1,v.addClass("pause_button"),v.removeClass("play_button"),z(Y),F=setInterval(fa,$)):a.data("options").paused===!1&&(X(),clearInterval(F))});
e(".hover_previous_next_button").hover(function(){e(this).find(".hover_previous_next_button_inner").stop().fadeTo("fast",0.85)},function(){e(this).find(".hover_previous_next_button_inner").stop().fadeTo("fast",0)})})}})(jQuery);