{ "pandav:/index.js": { "cubeCode": "Cube('pandav:/com/slider/1.4.5',['pandav:/npm/bcore/0.0.18/event','pandav:/npm/jquery/2.1.4','pandav:/npm/lodash/4.6.1','pandav:/com/slider/1.4.5/template.html'],function(a,b,c){var d=c('pandav:/npm/bcore/0.0.18/event'),e=c('pandav:/npm/jquery/2.1.4'),f=c('pandav:/npm/lodash/4.6.1'),g=f.template(c('pandav:/com/slider/1.4.5/template.html')());return a.exports=d.extend(function(a,b){this.config={},this.container=e(a),this.apis=b.apis,this._data=null,this.currentIndex=0,this.count=0,this.canvasAnimate=null,this.init(b),this.isInit=!0},{init:function(a){var b=this;this.mergeConfig(a),this.updateStyle(),this.animateTime=new Date,this.container.css({cursor:'pointer'}),this.container.off().on('mouseenter',function(){b.clearAnimates()}).on('mouseleave',function(){b.isInit=!0,b.config.animate.isLoop&&b.initInterval()}).on('click',function(){b.eventEmit()})},eventEmit:function(){this._data.length&&this.emit('click-image',this._data[this.currentIndex])},render:function(a,b){function c(){l.count++,l.count>=k.length&&('opacity'===h.animate.direction&&f.find('.images-wrap li').eq(0).css('opacity',1),l.updateStyle(),l.config.animate.isLoop&&l.initInterval())}var d=this;a=this.data(a);var f=this.container,h=Object.assign(this.mergeConfig(b),{images:a}),i=g(h),j=e(i).children('.images-wrap').find('li');this.dots&&this.dots.off(),this.clearAnimates(),f.html(i),('horrible'===h.animate.direction||'vertical'===h.animate.direction)&&f.find('.images-wrap').append(j[0]).css({left:0,top:0}),e(this.container.find('.images-wrap').find('li')[0]).addClass('current-image');var k=this.config.images;this.count=0,this.dots=f.find('.dots-wrap').find('li');var l=this;j.each(function(a,b){var d=e(b).find('img')[0];d.complete?c():d.onload=c}),this.dots.on('click',function(){var a=e(d).index();a===d.currentIndex||d.turnTo({index:a})})},startLoop:function(a){if(a&&void 0!==this._data[a.index]&&a.index!==this.currentIndex){var b=0>a.index-1?0:a.index-1;this.setCurrentIndex(b)}this.clearAnimates(),this.runTimer()},stopLoop:function(){this.clearAnimates()},prev:function(){this.clearAnimates();var a=this.container.find('.images-wrap li').length;this.currentIndex=1>this.currentIndex?'horrible'===this.config.animate.direction||'vertical'===this.config.animate.direction?a-2:a-1:this.currentIndex-1,this.updateDot(),this.startAnimate()},next:function(){this.clearAnimates(),this.currentIndex++,this.updateDot(),this.startAnimate()},turnTo:function(a){if(a){var b=a.index;this.clearAnimates(),this.currentIndex=b,this.updateDot(),this.startAnimate()}},runTimer:function(){var a=this.config,b=a.animate.speed,c=a.animate.interval||16;this.currentIndex++,this.interval&&clearTimeout(this.interval),this.startAnimate(),this.updateDot(),this.interval=setTimeout(this.runTimer.bind(this),b+c||16)},initInterval:function(){var a=this;clearTimeout(this.firstTimeOut),clearTimeout(this.interval),this.isInit?this.firstTimeOut=setTimeout(function(){a.runTimer(),a.isInit=!1},this.config.animate.interval):this.runTimer()},setCurrentIndex:function(a){this.currentIndex=a},startAnimate:function(){var a=this.container,b=a.find('.images-wrap'),c=this.config.animate,d=c.direction,e=this.currentIndex,f=b.find('li'),g=f.length;return!(1>=g)&&void('opacity'===d?this.moveByOpacity(e,{imagesWrap:b,images:f}):'mosaic'===d?this.renderMosaic(f):('vertical'===d||'horrible'===d)&&this.moveByDirection(e))},moveByDirection:function(a){var b=this,c=this.container,d=c.find('.images-wrap'),f=d.find('li'),g=this.config,h=g.width,i=g.height,j=g.animate,k=f.length,l='horrible'==j.direction?{left:-this.currentIndex*h+'px'}:{top:-this.currentIndex*i+'px'};d.animate(l,j.speed,'linear',function(){a>k-2&&(b.setCurrentIndex(0),'horrible'==j.direction?d.css('left',0):d.css('top',0)),e(f[b.currentIndex]).addClass('current-image').siblings().removeClass('current-image')})},moveByOpacity:function(a,b){a>=b.images.length&&this.setCurrentIndex(0);var c=b.images.eq(this.currentIndex),d=this.container.find('.current-image'),e=this.config.animate;d.css({\"z-index\":2}),d.animate({opacity:0},e.speed),c.css({\"z-index\":1,opacity:1}).addClass('current-image').siblings().removeClass('current-image')},renderMosaic:function(a){var b=Math.min,c=Math.floor,d=window.requestAnimationFrame||window.webkitRequestAnimationFrame,e=window.cancelAnimationFrame||window.webkitCancelAnimationFrame,f=this.currentIndex,g=this.config,j=g.width,k=g.height,l=g.slideImage,m=g.images,n=g.animate;f>=m.length&&(f=0,this.setCurrentIndex(f));var o=this.container.find('.pieces'),p=n.cols>=j?j:n.cols,q=n.rows>=k?k:n.rows,r=n.speed,s=p*q,t=m[f].url?m[f].url:l.defaultImage,u=l.fillType,v=o.find('canvas')[0],x=v.getContext('2d'),y=a.eq(f),z=this.container.find('.current-image');a.css({zIndex:-1,opacity:0}),z.css({zIndex:0,opacity:1}),v.width=j,v.height=k,x.clearRect(0,0,j,k);for(var A=[],B=0;Bk?k:F,h=H*E/F;D.drawImage(C,0,0,E,F,(j-h)/2,(k-H)/2,H,h);break;default:D.drawImage(C,0,0,E,F,0,0,E,F)}var w=b(s,10),I=c(s/w),J=0,K=this;this.canvasAnimate=d(function(a){},v)},getImageAlignStyle:function(a){var b;return b='cover'===a?{width:'100%',height:'100%'}:'contain'===a?{maxHeight:'none',width:this.config.width+'px',height:'auto',position:'relative',top:'50%',transform:'translateY(-50%)'}:'center'===a?{maxHeight:this.config.height+'px',width:'auto',height:'auto',position:'absolute',left:'50%',top:'50%',transform:'translate(-50%, -50%)'}:{width:'auto',height:'auto'},{maxHeight:b.maxHeight?b.maxHeight:'',width:b.width,height:b.height,position:b.position?b.position:'',left:b.left?b.left:'',top:b.top?b.top:'',transform:b.transform?b.transform:''}},updateSlideImage:function(a){var b=this.container,c=b.find('.images-wrap'),d=c.find('img'),e=d.filter('.no-image');a?(a.defaultImage!==this.config.slideImage.defaultImage&&e.each(function(b,c){c.src=a.defaultImage}),this.config.slideImage=a):a=this.config.slideImage;var f=this.getImageAlignStyle(a.fillType);d.css(f)},updateDot:function(a){if(a?this.config.dot=a:a=this.config.dot,!!this.dots){var b=this.dots,c=b.length,d=this.currentIndex,e=d>=b.length?d-c:d;a.show?b.show():b.hide(),b.eq(e).css('background',a.current),b.not(b.eq(e)).css('background',a.color)}},updateDescription:function(a){a?this.config.description=a:a=this.config.description;var b=a.background,c=this.container,d=c.find('.description');if(!a.show)return void d.hide();var e='linear-gradient('+b.degree+'deg, '+b.startColor+', '+b.endColor+')';'single'==b.style&&(e=b.single),d.css({display:'table',left:a.left,top:a.top,width:a.width+'%',height:a.height+'%',background:e,\"text-align\":a.align,color:a.color,\"font-weight\":a.fontWeight})},resize:function(a,b){this.render(null,{width:a,height:b})},data:function(a){return a&&(this._data=a),this._data},mergeConfig:function(a){var b=this.container;return a?(this.config=f.defaultsDeep(a||{},this.config),Object.assign(this.config,{width:b.width(),height:b.height()}),this.config):this.config},updateStyle:function(){this.currentIndex||this.setCurrentIndex(0),this.updateDot(),this.updateDescription(),this.updateSlideImage();var a=this.config;this.container.css({\"font-size\":a.component.fontSize+'px',fontFamily:'\"'+a.component.fontFamily+'\"',color:a.color||'#fff'})},clearAnimates:function(){this.interval&&clearTimeout(this.interval),this.firstTimeOut&&clearTimeout(this.firstTimeOut),this.canvasAnimate&&cancelAnimationFrame(this.canvasAnimate);var a=this.container,b=a.find('.images-wrap');if(b.length){b.finish();var c=b.find('li');if(c.length&&c.finish(),'mosaic'===this.config.animate.direction){var d=a.find('.current-image');d.find('.images-wrap li').css({zIndex:-1,opacity:0}),d.css({zIndex:0,opacity:1})}}},destroy:function(){this.interval&&clearTimeout(this.interval),this.firstTimeOut&&clearTimeout(this.firstTimeOut),this.interval=null,this.animateTime=null,this.currentIndex=null,this.count=null,this.firstTimeOut=null,this._data=null,this.container.off(),this.container&&this.container.empty()}}),a.exports});", "requires": [ "pandav:/template.html.js" ], "buildLevel": 1, "outputDir": "/com/slider/1.4.5", "outputPath": "/com/slider/1.4.5/index.js", "fileName": "/index.js" }, "pandav:/template.html.js": { "cubeCode": "Cube('pandav:/com/slider/1.4.5/template.html',[],function(a){return a.exports=function(){return'
\\r\\n \\r\\n <% if(dot.show === true) { %>\\r\\n
    \\r\\n <% _.forEach(images, function(image, index) { %>\\r\\n
  1. \\r\\n <% }); %>\\r\\n
\\r\\n <%} %>\\r\\n
\\r\\n \\r\\n
\\r\\n
\\r\\n'},a.exports});", "requires": [], "buildLevel": 2, "outputDir": "/com/slider/1.4.5", "outputPath": "/com/slider/1.4.5/template.html.js", "fileName": "/template.html" } }