-
Notifications
You must be signed in to change notification settings - Fork 19
/
ie-bootstrap-carousel.min.js
1 lines (1 loc) · 3.54 KB
/
ie-bootstrap-carousel.min.js
1
!function(e){"use strict";e(function(){e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t){if(e.style[n]!==undefined){return t[n]}}}();return e&&{end:e}}()})}(window.jQuery);!function(e){"use strict";var t=function(t,n){this.$element=e(t);this.options=n;this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){if(!t)this.paused=false;this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval));return this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;if(this.sliding){return this.$element.one("slid",function(){s.to(t)})}if(i==t){return this.pause().cycle()}return this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){if(!t)this.paused=true;if(this.$element.find(".next, .prev").length&&e.support.transition.end){this.$element.trigger(e.support.transition.end);this.cycle()}clearInterval(this.interval);this.interval=null;return this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f;this.sliding=true;s&&this.pause();i=i.length?i:this.$element.find(".item")[u]();f=e.Event("slide",{relatedTarget:i[0]});if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t);i[0].offsetWidth;r.addClass(o);i.addClass(o);this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active");r.removeClass(["active",o].join(" "));a.sliding=false;setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t);i[0].offsetWidth;var l=r.css("transition-property"),c=r.css("transition-duration"),h={},p={};if(typeof l=="undefined"){var d=r.css("transition"),v=d.split(","),m=v.slice(-1)[0].split(" "),g=/ease|bezier|linear/i;for(var y=0;y<m.length;y++){if(g.test(m[y])){continue}else if(!isNaN(parseFloat(m[y]))&&typeof c=="undefined"){c=parseFloat(m[y])}else{l=m[y]}}}if(l=="opacity"){h[l]=0;p[l]=1;r.css({zIndex:2,opacity:1});i.css({zIndex:1,opacity:0})}else{h[l]=o=="left"?"-100%":"100%";p[l]=0}c=c*1e3;r.animate(h,c);i.animate(p,c,function(){i.removeClass(t).addClass("active").removeAttr("style");r.removeClass("active").removeAttr("style");a.sliding=false;setTimeout(function(){a.$element.trigger("slid")},0)})}s&&this.cycle();return this}};var n=e.fn.carousel;e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;if(!i)r.data("carousel",i=new t(this,s));if(typeof n=="number")i.to(n);else if(o)i[o]();else if(s.interval)i.cycle()})};e.fn.carousel.defaults={interval:5e3,pause:"hover"};e.fn.carousel.Constructor=t;e.fn.carousel.noConflict=function(){e.fn.carousel=n;return this};e(document).on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=e.extend({},i.data(),n.data());i.carousel(s);t.preventDefault()})}(window.jQuery)