!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):t(n.$)}(this,function(n){"use strict";function u(n){return"%"==n[n.length-1]}function c(n){var t=n.split(" ");if(1!==t.length)return t.map(function(t){switch(n){case"center":return"50%";case"top":case"left":return"0";case"right":case"bottom":return"100%";default:return t}});switch(n){case"center":return["50%","50%"];case"top":return["50%","0"];case"bottom":return["50%","100%"];case"left":return["0","50%"];case"right":return["100%","50%"];default:return[n,"50%"]}}function e(n,i){function f(n,i){var r=t.createShader(n);if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("compile error: "+t.getShaderInfoLog(r));return r}var r={},e,u,o,s;if(r.id=t.createProgram(),t.attachShader(r.id,f(t.VERTEX_SHADER,n)),t.attachShader(r.id,f(t.FRAGMENT_SHADER,i)),t.linkProgram(r.id),!t.getProgramParameter(r.id,t.LINK_STATUS))throw new Error("link error: "+t.getProgramInfoLog(r.id));for(r.uniforms={},r.locations={},t.useProgram(r.id),t.enableVertexAttribArray(0),o=/uniform (\w+) (\w+)/g,s=n+i;null!=(e=o.exec(s));)u=e[2],r.locations[u]=t.getUniformLocation(r.id,u);return r}function f(n,i){t.activeTexture(t.TEXTURE0+(i||0));t.bindTexture(t.TEXTURE_2D,n)}function o(n){var t=/url\(["']?([^"']*)["']?\)/.exec(n);return null==t?null:t[1]}function l(n){return n.match(/^data:/)}var t,s=(n=n&&"default"in n?n.default:n)(window),r=function(){function e(t,i,r){var u="OES_texture_"+t,f=u+"_linear",e=f in n,o=[u];return e&&o.push(f),{type:i,arrayType:r,linearSupport:e,extensions:o}}var o=document.createElement("canvas"),n,i,u,s,f,r;if(!(t=o.getContext("webgl")||o.getContext("experimental-webgl"))||(n={},["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].forEach(function(i){var r=t.getExtension(i);r&&(n[i]=r)}),!n.OES_texture_float))return null;for(i=[],i.push(e("float",t.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(e("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null)),u=t.createTexture(),s=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,s),t.bindTexture(t.TEXTURE_2D,u),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),f=null,r=0;r.jquery-ripples { position: relative; z-index: 0; }<\/style>");i=function(i,u){function s(){h.destroyed||(h.step(),requestAnimationFrame(s))}var h=this,f,e,o;this.$el=n(i);this.interactive=u.interactive;this.resolution=u.resolution;this.textureDelta=new Float32Array([1/this.resolution,1/this.resolution]);this.perturbance=u.perturbance;this.dropRadius=u.dropRadius;this.crossOrigin=u.crossOrigin;this.imageUrl=u.imageUrl;f=document.createElement("canvas");f.width=this.$el.innerWidth();f.height=this.$el.innerHeight();this.canvas=f;this.$canvas=n(f);this.$canvas.css({position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1});this.$el.addClass("jquery-ripples").append(f);this.context=t=f.getContext("webgl")||f.getContext("experimental-webgl");r.extensions.forEach(function(n){t.getExtension(n)});this.updateSize=this.updateSize.bind(this);n(window).on("resize",this.updateSize);this.textures=[];this.framebuffers=[];this.bufferWriteIndex=0;this.bufferReadIndex=1;for(var c=r.arrayType,a=c?new c(this.resolution*this.resolution*4):null,l=0;l<2;l++)e=t.createTexture(),o=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,o),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r.linearSupport?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r.linearSupport?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.resolution,this.resolution,0,t.RGBA,r.type,a),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.textures.push(e),this.framebuffers.push(o);this.quad=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,this.quad);t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),t.STATIC_DRAW);this.initShaders();this.initTexture();this.setTransparentTexture();this.loadImage();t.clearColor(0,0,0,0);t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA);this.visible=!0;this.running=!0;this.inited=!0;this.destroyed=!1;this.setupPointerEvents();requestAnimationFrame(s)};i.DEFAULTS={imageUrl:null,resolution:256,dropRadius:20,perturbance:.03,interactive:!0,crossOrigin:""};i.prototype={setupPointerEvents:function(){function i(){return n.visible&&n.running&&n.interactive}function t(t,r){i()&&n.dropAtPointer(t,n.dropRadius*(r?1.5:1),r?.14:.01)}var n=this;this.$el.on("mousemove.ripples",function(n){t(n)}).on("touchmove.ripples touchstart.ripples",function(n){for(var r=n.originalEvent.changedTouches,i=0;i1?Array.prototype.slice.call(arguments,1):void 0;return this.each(function(){var f=n(this),r=f.data("ripples"),e=n.extend({},i.DEFAULTS,f.data(),"object"==typeof t&&t);(r||"string"!=typeof t)&&(r?"string"==typeof t&&i.prototype[t].apply(r,u):f.data("ripples",r=new i(this,e)))})};n.fn.ripples.Constructor=i;n.fn.ripples.noConflict=function(){return n.fn.ripples=h,this}})