1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
!function(){"use strict";if("undefined"!=typeof jQuery){jQuery(".tp-caption[data-explodinglayersin]",".tp-caption[data-explodinglayersin]").each(function(){d.call(this)}),window.ExplodingLayersAddOn=function(o,e){if(o&&e){var i,A,P=o(window),a={padding:0,size:1,speed:0,density:1,power:0,duration:300};e.find(".tp-caption[data-explodinglayersin]",".tp-caption[data-explodinglayersin]").each(function(){-1===this.className.search("revaddonexplayer")&&d.call(this)}),e.on("revolution.slide.onloaded",function(){if(A=e[0].opt.responsiveLevels){for(Array.isArray(A)||(A=[A]);A.length<4;)A[A.length]=A[A.length-1];for(var t=0;t<4;t++)A[t]=parseInt(A[t],10)}e.find(".tp-caption[data-explodinglayersin]").each(function(){var t=this.getAttribute("data-explodinglayersin");t&&(t=JSON.parse(t))&&n.apply(this,["in",t])}),e.find(".tp-caption[data-explodinglayersout]").each(function(){var t=this.getAttribute("data-explodinglayersout");t&&(t=JSON.parse(t))&&n.apply(this,["out",t])}),P.on("resize",function(){clearTimeout(i),i=setTimeout(s,50)})}).on("revolution.slide.onbeforeswap revolution.slide.onafterswap",function(t,e){-1!==t.namespace.search("before")?e.nextslide&&e.nextslide.length&&r(e.nextslide):e.prevslide&&e.prevslide.length&&r(e.prevslide)}).on("revolution.slide.layeraction",function(t,e){var i,a,s=e.layer.data("revaddonexpeffect"),r=e.layer.hasClass("tp-static-layer"),n=r&&!e.layer.hasClass("revaddonexpstatic");s&&("enterstage"===e.eventtype||n?(r&&e.layer.addClass("revaddonexpstatic"),a=e.layer.data("revaddonexplayerin"),i=!1):"leavestage"===e.eventtype&&(a=e.layer.data("revaddonexplayerout"),i=!0),a&&(a.options=o.extend({},a.orig),s.o=a.options,function(t,e,i,a){var s,r,n=0,o=P.width();if(A)for(var h=A.length,d=0;d<h;d++)r=A[d],s!==r&&(o<r&&(n=d),s=r);for(var l in t)t.hasOwnProperty(l)&&"effect"!==l&&(e[l]=O(l,e[l],n));z("size",e,e.size),z("speed",e,e.speed),e.sync="on"===e.sync;var p,c,f=function(t){{if("transparent"===t.trim())return["#ffffff",!1];if(-1===t.search(/\[\{/))return-1!==t.search("#")?[t,!1]:-1!==t.search("rgba")?[t.replace(/\s/g,"").replace(/false/g,"1"),!1]:-1!==t.search("rgb")?[t.replace(/\s/g,""),!1]:/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)?[t,!1]:["#ffffff",!1];try{return[t=function(t){for(var e,i=t.colors,a=i.length,s=[],r=0;r<a;r++){var n=i[r];delete n.align,e?JSON.stringify(n)!==JSON.stringify(e)&&(s[s.length]=n):s[s.length]=n,e=n}return t.colors=s,t}(t=JSON.parse(t.replace(/\&/g,'"'))),!0]}catch(t){return["#ffffff",!1]}}}(e.color);if(f[1]){var u=(g=f)[1]?"radial"===(g=g[0]).type?function(t){for(var e,i,a=t.length,s="explodinglayers"+Math.floor(1e4*Math.random()),r='<defs><radialGradient id="'+s+'">',n=0;n<a;n++)e=t[n],i=parseInt(e.position,10),r+='<stop offset="'+i+'%" style="stop-color: rgb('+e.r+","+e.g+","+e.b+"); stop-opacity: "+e.a+'" />';return["url(#"+s+")",r+="</radialGradient></defs>"]}(g.colors):function(t,e){e=parseInt(e,10)/180*Math.PI;var i,a,s,r=(.5*(Math.floor(e/Math.PI*2)+2)+.25)*Math.PI,n=Math.cos(Math.abs(r-e))*Math.sqrt(2),o=n*Math.cos(e),h=n*Math.sin(e),d=[o<0?1:0,h<0?1:0,0<=o?o:o+1,0<=h?h:h+1],l=t.length,p="explodinglayers"+Math.floor(1e4*Math.random()),c='<defs><linearGradient id="'+p+'" x1="'+d[0]+'" y1="'+d[1]+'" x2="'+d[2]+'" y2="'+d[3]+'">';for(s=0;s<l;s++)i=t[s],a=parseInt(i.position,10),c+='<stop offset="'+a+'%" style="stop-color: rgb('+i.r+","+i.g+","+i.b+"); stop-opacity: "+i.a+'" />';return["url(#"+p+")",c+="</linearGradient></defs>"]}(g.colors,g.angle):g[0];p=u[0],c=u[1]}else p=f[0],c="";var g;var y,v,m='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">'+c;"circle"!==e.type?(y="<path ",v="></path>"):(y='<circle cx="12" cy="12" r="12" ',v=" />");"fill"===e.style?m+=y+'fill="'+p+'" d="'+e.type+'"'+v:m+=y+'fill="transparent" d="'+e.type+'" stroke="'+p+'" stroke-width="1"'+v;m+="</svg>";var x=new Image,w="data:image/svg+xml;base64,"+btoa(m),M=document.createElement("canvas"),b=M.getContext("2d");M.width=M.height=24,x.onload=function(){b.drawImage(this,0,0),e.type=b.canvas,i.run(a)},x.src=w}(a.orig,a.options,s,i)))})}function t(){r(o(this),!0)}function s(){e.find(".tp-revslider-slidesli").each(t)}function r(a,s){a.find(".tp-caption[data-explodinglayersin], .tp-caption[data-explodinglayersout]").each(function(){var t=o(this),e=t.data("revaddonexpeffect");if(e){var i=(s=s&&-1!==a.attr("class").search(/processing-revslide|active-revslide/))?e.disintegrating?"addClass":"removeClass":"addClass";e.reset(s),t.attr("data-explodinglayersin")&&t[i]("revaddonexplayerhide")}})}function n(t,e){for(var i in e)e.hasOwnProperty(i)&&(e[i.replace("_"+t,"")]=e[i],delete e[i]);var a=o(this);e.effect=a.data("revaddonexpeffect")||new l(this,e);var s={revaddonexpeffect:e.effect},r=o.extend({},e);s["revaddonexplayer"+t]={orig:r,options:e,direction:t},a.data(s)}function h(t,e){if(a.hasOwnProperty(t))e=Math.max(parseFloat(e),a[t]);else if("easing"===t){var i=e.split(".");e=2===i.length?punchgs[i[0]][i[1]]:punchgs.hasOwnProperty(e)?punchgs[e]:punchgs.Power3.easeOut}return e}function O(t,e,i){if(!e)return!1;if(0===i)return h(t,e[i]);for(var a=i,s=e[i];"inherit"===s;)s=-1<--a?e[a]:e[0];return h(t,s)}function z(t,e,i){if("on"===e["random"+t]){var a=Math.max(Math.round(.5*i),1),s=Math.round(2*i);e[t]=function(){return Math.floor(Math.random()*s)+a}}}},l.prototype={init:function(){this.particles=[],this.frame=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.canvas.className="revaddon-explayer-canvas",this.canvas.style="display:none;",this.wrapper=document.createElement("div"),this.wrapper.className="revaddon-explayer-wrapper",this.el.parentNode.insertBefore(this.wrapper,this.el),this.wrapper.appendChild(this.el),this.parentWrapper=document.createElement("div"),this.parentWrapper.className="revaddon-explayer",this.wrapper.parentNode.insertBefore(this.parentWrapper,this.wrapper),this.parentWrapper.appendChild(this.wrapper),this.parentWrapper.appendChild(this.canvas)},loop:function(){this.updateRevAddonExpBtn(),this.renderRevAddonExpBtn(),this.isAnimating()&&(this.frame=requestAnimationFrame(this.loop.bind(this)))},updateRevAddonExpBtn:function(){for(var t,e=0;e<this.particles.length;e++)(t=this.particles[e]).life>t.death?(!1===this.total&&(this.total=this.particles.length),this.particles.splice(e,1),this.o.sync&&this.updateTransform(this.particles.length)):(t.x+=t.speed,t.y=this.o.power*Math.sin(t.counter*t.increase),t.life++,t.counter+=this.disintegrating?1:-1);this.particles.length||(this.pause(),this.canvas.style.display="none")},renderRevAddonExpBtn:function(){var t;this.ctx.clearRect(0,0,this.width,this.height);for(var e=0;e<this.particles.length;e++)(t=this.particles[e]).life<t.death&&(this.ctx.translate(t.startX,t.startY),this.ctx.rotate(t.angle*Math.PI/180),this.ctx.globalAlpha=this.disintegrating?1-t.life/t.death:t.life/t.death,this.ctx.drawImage(this.o.type,Math.round(t.x),Math.round(t.y),Math.round(t.size),Math.round(t.size)),this.ctx.globalAlpha=1,this.ctx.rotate(-t.angle*Math.PI/180),this.ctx.translate(-t.startX,-t.startY))},play:function(){this.frame=requestAnimationFrame(this.loop.bind(this))},pause:function(){cancelAnimationFrame(this.frame),this.ctx.clearRect(0,0,this.width,this.height),this.frame=null},addParticle:function(t){var e,i=60*this.o.duration/1e3,a=s.fnc(this.o.speed)?this.o.speed():this.o.speed;this.particles.push({startX:t.x,startY:t.y,x:this.disintegrating?0:a*-i,y:0,angle:(e=360,Math.random()*e-e/2),counter:this.disintegrating?0:i,increase:2*Math.PI/100,life:0,death:this.disintegrating?i-20+40*Math.random():i,speed:a,size:s.fnc(this.o.size)?this.o.size():this.o.size})},addRevAddonExpBtn:function(t,e){var i=this.disintegrating?e-this.lastProgress:this.lastProgress-e;this.lastProgress=e;var a=this.o.padding,s=this.o.padding,r=(this.isHorizontal()?t.width:t.height)*e+i*(this.disintegrating?100:this.o.duration);this.isHorizontal()?a+="left"===this.o.direction?r:t.width-r:s+="top"===this.o.direction?r:t.height-r;var n=Math.floor(this.o.density*(100*i+1));if(0<n)for(;n--;)this.addParticle({x:a+(this.isHorizontal()?0:t.width*Math.random()),y:s+(this.isHorizontal()?t.height*Math.random():0)});this.isAnimating()||(this.canvas.style.display="block",this.play())},addTransforms:function(t){var e=this.isHorizontal()?"translateX":"translateY",i="left"===this.o.direction||"top"===this.o.direction?t:-t;this.wrapper.style[a]=e+"("+i+"%)",this.el.style[a]=e+"("+-i+"%)",this.changed||(this.el.className=this.el.className.replace("revaddonexplayerhide",""),this.wrapper.style.visibility="visible",this.changed=!0)},updateTransform:function(t){var e=t/this.total*100;this.addTransforms(e)},update:function(){var t;if(this.disintegrating)t=this.tween.value,this.addTransforms(t);else if(t=100-this.tween.value,!this.o.sync){var e=this;this.timers[this.timers.length]=setTimeout(function(){e.addTransforms(t)},this.o.duration)}this.addRevAddonExpBtn(this.rect,t/100)},run:function(t){this.reset(),this.disintegrating=t,this.lastProgress=t?0:1,this.rect=this.el.getBoundingClientRect(),this.width=this.canvas.width=this.o.width||this.rect.width+2*this.o.padding,this.height=this.canvas.height=this.o.height||this.rect.height+2*this.o.padding,this.changed=!1,this.timers=[],this.animate(this.update.bind(this))},setDisplay:function(t){this.canvas.style.display="none",this.wrapper.style.visibility=t?"visible":"hidden",this.wrapper.style[a]="none",this.el.style[a]="none"},reset:function(t){if(this.pause(),this.particles=[],this.total=!1,this.tween&&(punchgs.TweenLite.killTweensOf(this.tween),delete this.tween),this.timers){for(;this.timers.length;)clearTimeout(this.timers[0]),this.timers.shift();delete this.timers}if(t){var e=this;requestAnimationFrame(function(){e.setDisplay(!0)})}else this.setDisplay()},animate:function(t){var e=this;return this.tween={value:0},punchgs.TweenLite.to(this.tween,.001*this.o.duration,{value:100,ease:this.o.easing,onUpdate:t,onComplete:function(){e.disintegrating&&(e.wrapper.style.visibility="hidden")}})},isAnimating:function(){return!!this.frame},isHorizontal:function(){return"left"===this.o.direction||"right"===this.o.direction}};var a,s={arr:function(t){return Array.isArray(t)},str:function(t){return"string"==typeof t},fnc:function(t){return"function"==typeof t}},t="transform";jQuery(document).ready(function(){a=function(t,e){if(e in t.style)return getComputedStyle(t).getPropertyValue(e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())||"0"}(document.body,t)?t:"-webkit-"+t})}function d(){var t=jQuery(this),e=t.attr("data-frames"),i=e.split('{"frame":"hover"'),a=JSON.parse(e);if(i=1<i.length?',{"frame":"hover"'+i[1].replace("]",""):"",a&&a.length&&!(a.length<2)){var s=a[0],r=a[1],n='[{"delay":"'+(s=s.hasOwnProperty("delay")?s.delay:1e3)+'","speed":1000,"frame":"0","to":"o:1;","ease":"Power2.easeOut"},{"delay":"'+(r=r.hasOwnProperty("delay")?r.delay:1e3)+'","speed":1000,"frame":"999","ease":"Power2.easeOut"}'+i+"]";t.attr("data-explodinglayersin")&&t.addClass("revaddonexplayerhide"),t.addClass("revaddonexplayer").attr("data-frames",n).data("frames",JSON.parse(n))}}function l(t,e){this.el=t,this.o=e,this.init()}}(); |