bar.min.js 2.78 KB
N2Require("SmartSliderWidgetBarVertical",[],[],function(i,t,e){"use strict";function s(t,e,s){this.slider=window[t],this.slider.started(i.proxy(this.start,this,t,e,s))}return s.prototype.start=function(t,e,s){if(this.slider.sliderElement.data("bar"))return!1;if(this.slider.sliderElement.data("bar",this),this.offset=0,this.tween=null,this.slider.isShuffled){for(var r=[],n=0;n<this.slider.realSlides.length;n++){var o=this.slider.realSlides[n];r.push(e[o.originalIndex])}e=r}this.originalBars=this.bars=e,this.bar=this.slider.sliderElement.find(".nextend-bar"),this.bar2=this.bar.find("> div"),this.innerBar=this.bar2.find("> div"),this.slider.sliderElement.on({slideCountChanged:i.proxy(this.onSlideCountChanged,this)}),this.slider.firstSlideReady.done(i.proxy(this.onFirstSlideSet,this)),s.animate?this.slider.sliderElement.on("mainAnimationStart",i.proxy(this.onSliderSwitchToAnimateStart,this)):this.slider.sliderElement.on("sliderSwitchTo",i.proxy(this.onSliderSwitchTo,this)),this.slider.sliderElement.on("SliderResize",i.proxy(this.onResize,this));var h=this.bar.width()/this.bar.parent().width();if(this.size=h*this.slider.responsive.responsiveDimensions.startSliderWidth,0==s.overlay){var a=!1;switch(s.area){case 5:a="Left";break;case 8:a="Right"}a&&(this.offset=parseFloat(this.bar.data("offset")),this.slider.responsive.addMargin(a,this))}var l="click";this.slider.hasTouch()&&(l="n2click"),this.bar.on("click",i.proxy(function(i){this.slider.sliderElement.find(".n2-ss-slide-active .n2-ss-layers-container").trigger(l)},this))},s.prototype.onFirstSlideSet=function(i){this.onSliderSwitchTo(null,i.index)},s.prototype.onSliderSwitchTo=function(i,t){this.innerBar.html(this.bars[t].html),this.setCursor(this.bars[t].hasLink)},s.prototype.onSliderSwitchToAnimateStart=function(){var t=i.Deferred();this.slider.sliderElement.on("mainAnimationComplete.n2Bar",i.proxy(this.onSliderSwitchToAnimateEnd,this,t)),this.tween&&this.tween.pause(),NextendTween.to(this.innerBar,.3,{opacity:0,onComplete:function(){t.resolve()}})},s.prototype.onSliderSwitchToAnimateEnd=function(t,e,s,r,n){this.slider.sliderElement.off(".n2Bar"),t.done(i.proxy(function(){var i=this.innerBar.clone();this.innerBar.remove(),this.innerBar=i.css("opacity",0).html(this.bars[n].html).appendTo(this.bar2),this.setCursor(this.bars[n].hasLink),this.tween=NextendTween.to(this.innerBar,.3,{opacity:1})},this))},s.prototype.setCursor=function(i){i?this.bar.css("cursor","pointer"):this.bar.css("cursor","inherit")},s.prototype.onResize=function(i,t){this.bar.width(parseInt(this.size*t.w))},s.prototype.isVisible=function(){return this.bar.is(":visible")},s.prototype.getSize=function(){return this.size+this.offset},s.prototype.onSlideCountChanged=function(i,t,e){this.bars=[];for(var s=0;s<this.originalBars.length;s++)s%e==0&&this.bars.push(this.originalBars[s])},s});