-
Notifications
You must be signed in to change notification settings - Fork 0
/
bslider.jquery.min.js
1 lines (1 loc) · 4.85 KB
/
bslider.jquery.min.js
1
!function(t){t.fn.bSlider=function(e){var i=t.extend(!0,{speed:500,auto:!1,autoHeight:!0,itemMaxWidth:!1,controlsMaxWidth:!1,step:!1,onFinishStop:!1,left:!1,right:!1,stepCount:1,method:"slide",elements:{main:".bslider",window:".window",frame:".frame",item:".item",controls:".controls",left:".left",right:".right",bullet:".bullet",bulletHtml:'<span class="bullet"></span>',bullets:".bullets",rewind:".rewind",activeClass:"active"},onReady:function(){},onSlideBegin:function(){},onSlideComplete:function(){},onFinish:function(){}},e),s="bSlider",n=function(e,i){if("undefined"==typeof i)var i=e[1],e=e[0];var a=e.data()[s],l=a.settings;if("left"==i)if(a.active<l.stepCount)var o=a.count-l.stepCount;else var o=a.active-l.stepCount;else if("right"==i)if(a.active>=a.count-a.size)var o=0;else var o=a.active+l.stepCount;else var o=i;o=Math.ceil(o);var h=t(l.elements.item+":nth-child("+(o+1)+")",e);t(l.elements.bullets,e).length>0&&t(l.elements.bullet+":nth-child("+(o+1)+")",e).addClass(l.elements.activeClass).siblings().removeClass(l.elements.activeClass),l.onSlideBegin.call(this,e,l,o),animateCss={left:-1*o*a.step},"fade"==l.method?h.stop().fadeTo(l.speed,1,function(){if(l.onSlideComplete.call(this,e,l),a.settings.onFinishStop&&a.active+1==a.count&&l.onFinish.call(this,e,l),a.auto!==!1&&(!a.settings.onFinishStop||a.active+1!=a.count)){clearInterval(a.auto);var t=[e,"right"];a.auto=setTimeout(function(t){return function(){n(t)}}(t),l.auto)}}).siblings().stop().fadeTo(l.speed,0):a.frame.animate(animateCss,{duration:l.speed,queue:!1,complete:function(){if(l.onSlideComplete.call(this,e,l),a.settings.onFinishStop&&a.active+1==a.count&&l.onFinish.call(this,e,l),a.auto!==!1&&(!a.settings.onFinishStop||a.active+1!=a.count)){clearInterval(a.auto);var t=[e,"right"];a.auto=setTimeout(function(t){return function(){n(t)}}(t),l.auto)}}}),h.addClass(l.elements.activeClass).siblings().removeClass(l.elements.activeClass),l.autoHeight&&a.frame.animate({height:h.outerHeight(!0)},{duration:l.speed,queue:!1}),a.active=o,e.data(s,a)};return this.each(function(){var e=jQuery.extend(!0,{},i),a={};$this=t(this);var l=t(e.elements.bullets,$this),o=t(this);if(active=0==t(e.elements.item+"."+e.elements.activeClass,$this).length?0:t(e.elements.item+"."+e.elements.activeClass,$this).index(),e.left=e.left?t(e.left):t(e.elements.controls+" "+e.elements.left,t(this)),e.right=e.right?t(e.right):t(e.elements.controls+" "+e.elements.right,t(this)),e.controlsMaxWidth){var h=t(e.elements.controls,$this);h.width(parseInt($this.width())),h.addClass(s+"-controls-resize"),t(window).unbind("resize."+s+"-controls").bind("resize."+s+"-controls",function(){t("."+s+"-controls-resize").each(function(){var i=t(this).parents(e.elements.main);t(this).width(parseInt(i.width()))})}),h.show()}e.itemMaxWidth&&(t(e.elements.item,$this).width(parseInt($this.width())-parseInt(t(e.elements.item,$this).first().css("padding-left"))-parseInt(t(e.elements.item,$this).first().css("padding-right"))),$this.addClass(s+"-resize"),t(window).unbind("resize."+s).bind("resize."+s,function(){t("."+s+"-resize").each(function(){var i=t(this),n=i.data()[s],a=i.width(),l=parseInt(a)-parseInt(t(e.elements.item,i).first().css("padding-left"))-parseInt(t(e.elements.item,i).first().css("padding-right"));if(t(e.elements.item,i).width(l),"fade"==e.method?n.frame.width(l):n.frame.css({left:-1*n.active*a,width:n.count*a}),!n.settings.step)var o=t(e.elements.item,i).first().outerWidth(!0);n.step=o,n.width=a,i.data(s,n)})}));var r=0,d=t(e.elements.item,$this).each(function(){r+=t(this).outerWidth(!0);var i=t(this).attr("data-background");"undefined"!=typeof i&&i!==!1&&t(this).css("background-image","url("+t(this).attr("data-background")+")"),"fade"==e.method&&t(this).css({position:"absolute",left:"0",top:"0"}),l.append(e.elements.bulletHtml)}).length,c=t(e.elements.item+":nth-child("+(active+1)+")",$this),u=t(e.elements.frame,$this);if(e.step)var m=e.step;else var m=c.outerWidth(!0);var f=c.outerHeight(!0);if(t(e.elements.window,$this).length>0)var v=t(e.elements.window,$this).outerWidth(!0)/c.outerWidth(!0);else var v=$this.outerWidth(!0)/c.outerWidth(!0);if("fade"==e.method&&(r=c.outerWidth(!0)),u.css({left:-1*active*m,height:f,width:r}),c.addClass(e.elements.activeClass).siblings().removeClass(e.elements.activeClass),"fade"==e.method&&c.show().siblings().hide(),e.left.bind("click."+s,function(){n(o,"left")}),e.right.bind("click."+s,function(){n(o,"right")}),t(e.elements.bullet,l).bind("click."+s,function(){n(t(this).parents(e.elements.main),t(this).index())}),t(e.elements.rewind,$this).bind("click."+s,function(){n(t(this).parents(e.elements.main),0)}),t(e.elements.bullet+":nth-child("+(active+1)+")",$this).addClass(e.elements.activeClass),e.onReady.call(this,$this,e),e.auto){var p=[$this,"right"];a.auto=setTimeout(function(t){return function(){n(t)}}(p),e.auto)}else a.auto=!1;a.active=active,a.count=d,a.step=m,a.size=v,a.frame=u,a.settings=e,$this.data(s,a)})}}(jQuery);