Project

General

Profile

1
(function(a){if(typeof module!=="undefined"&&typeof exports=="object"){if(typeof window!="undefined"){module.exports=a()}else{module.exports=a}}else{window.Carousel=a()}})(function(){var b=function(c,l){l=l||{};this.carousel=(typeof c==="object")?c:document.querySelector(c);this.options={};this.options.keyboard=l.keyboard==="true"?true:false;this.options.pause=l.pause?l.pause:"hover";this.duration=600;this.isIE=(new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)!=null)?parseFloat(RegExp.$1):false;this.options.duration=(this.isIE&&this.isIE<10)?0:(l.duration||this.duration);var k=this.carousel.querySelectorAll(".item"),j=k.length;this.controls=this.carousel.querySelectorAll(".carousel-control");this.prev=this.controls[0];this.next=this.controls[1];this.slides=[];for(var h=0;h<j;h++){this.slides.push(k[h])}this.indicator=this.carousel.querySelector(".carousel-indicators");this.indicators=this.carousel.querySelectorAll(".carousel-indicators li");this.total=this.slides.length;this.timer=null;this.direction=null;this.index=0;if(l.interval==="false"){this.options.interval=false}else{this.options.interval=parseInt(l.interval)||5000}this.init()};b.prototype={init:function(){if(this.options.interval!==false){this.cycle()}if(this.options&&this.options.pause==="hover"&&this.options.interval!==false){this.pause()}this.actions();this._addEventListeners()},cycle:function(c){var h=this;h.direction="left";h.timer=setInterval(function(){h.index++;if(h.index==h.slides.length){h.index=0}h._slideTo(h.index,c)},h.options.interval)},pause:function(){var i=this;var c=function(){if(i.options.interval!==false&&!/paused/.test(i.carousel.className)){i.carousel.className+=" paused";clearInterval(i.timer);i.timer=null}};var h=function(){if(i.options.interval!==false&&/paused/.test(i.carousel.className)){i.cycle();i.carousel.className=i.carousel.className.replace(" paused","")}};i.carousel.addEventListener("mouseenter",c,false);i.carousel.addEventListener("mouseleave",h,false);i.carousel.addEventListener("touchstart",c,false);i.carousel.addEventListener("touchend",h,false)},_slideTo:function(k,j){var l=this;var c=l._getActiveIndex();var h=l.direction;var i=h==="left"?"next":"prev";var m=null,n=null;if(("CustomEvent" in window)&&window.dispatchEvent){m=new CustomEvent("slid.bs.carousel");n=new CustomEvent("slide.bs.carousel")}if(m){l.carousel.dispatchEvent(m)}l._removeEventListeners();clearInterval(l.timer);l.timer=null;l._curentPage(l.indicators[k]);if(/slide/.test(this.carousel.className)&&!(this.isIE&&this.isIE<10)){l.slides[k].className+=(" "+i);l.slides[k].offsetWidth;l.slides[k].className+=(" "+h);l.slides[c].className+=(" "+h);setTimeout(function(){l._addEventListeners();l.slides[k].className+=" active";l.slides[c].className=l.slides[c].className.replace(" active","");l.slides[k].className=l.slides[k].className.replace(" "+i,"");l.slides[k].className=l.slides[k].className.replace(" "+h,"");l.slides[c].className=l.slides[c].className.replace(" "+h,"");if(l.options.interval!==false&&!/paused/.test(l.carousel.className)){clearInterval(l.timer);l.cycle()}if(n){l.carousel.dispatchEvent(n)}},l.options.duration+100)}else{l.slides[k].className+=" active";l.slides[k].offsetWidth;l.slides[c].className=l.slides[c].className.replace(" active","");setTimeout(function(){l._addEventListeners();if(l.options.interval!==false&&!/paused/.test(l.carousel.className)){clearInterval(l.timer);l.cycle()}if(n){l.carousel.dispatchEvent(n)}},l.options.duration+100)}},_addEventListeners:function(){var c=this;c.next&&c.next.addEventListener("click",c.controlsHandler,false);c.prev&&c.prev.addEventListener("click",c.controlsHandler,false);c.indicator&&c.indicator.addEventListener("click",c.indicatorHandler,false);if(c.options.keyboard===true){window.addEventListener("keydown",c.keyHandler,false)}},_removeEventListeners:function(){var c=this;c.next&&c.next.removeEventListener("click",c.controlsHandler,false);c.prev&&c.prev.removeEventListener("click",c.controlsHandler,false);c.indicator&&c.indicator.removeEventListener("click",c.indicatorHandler,false);if(c.options.keyboard===true){window.removeEventListener("keydown",c.keyHandler,false)}},_getActiveIndex:function(){return this.slides.indexOf(this.carousel.querySelector(".item.active"))},_curentPage:function(j){for(var h=0;h<this.indicators.length;++h){var c=this.indicators[h];c.className=""}if(j){j.className="active"}},actions:function(){var c=this;c.indicatorHandler=function(i){i.preventDefault();var k=i.target;var h=c._getActiveIndex();if(k&&!/active/.test(k.className)&&k.getAttribute("data-slide-to")){var j=parseInt(k.getAttribute("data-slide-to"),10);c.index=j;if(c.index==0){c.index=0}else{if(c.index==c.total-1){c.index=c.total-1}}if((h<c.index)||(h===c.total-1&&c.index===0)){c.direction="left"}else{if((h>c.index)||(h===0&&c.index===c.total-1)){c.direction="right"}}}else{return false}c._slideTo(c.index,i)},c.controlsHandler=function(h){var i=h.currentTarget||h.srcElement;h.preventDefault();if(i===c.next){c.index++;c.direction="left";if(c.index==c.total-1){c.index=c.total-1}else{if(c.index==c.total){c.index=0}}}else{if(i===c.prev){c.index--;c.direction="right";if(c.index==0){c.index=0}else{if(c.index<0){c.index=c.total-1}}}}c._slideTo(c.index,h)};c.keyHandler=function(h){switch(h.which){case 39:h.preventDefault();c.index++;c.direction="left";if(c.index==c.total-1){c.index=c.total-1}else{if(c.index==c.total){c.index=0}}break;case 37:h.preventDefault();c.index--;c.direction="right";if(c.index==0){c.index=0}else{if(c.index<0){c.index=c.total-1}}break;default:return}c._slideTo(c.index,h)}}};var d=document.querySelectorAll('[data-ride="carousel"]'),f=0,e=d.length;for(f;f<e;f++){var a=d[f],g={};g.interval=a.getAttribute("data-interval")&&a.getAttribute("data-interval");g.pause=a.getAttribute("data-pause")&&a.getAttribute("data-pause")||"hover";g.keyboard=a.getAttribute("data-keyboard")&&a.getAttribute("data-keyboard")||false;g.duration=a.getAttribute("data-duration")&&a.getAttribute("data-duration")||false;new b(a,g)}return b});
(4-4/11)