diff --git a/jquery.isTransparent.min.js b/jquery.isTransparent.min.js index 66a2328..118fe68 100644 --- a/jquery.isTransparent.min.js +++ b/jquery.isTransparent.min.js @@ -1,4 +1,6 @@ /*! * jQuery isTransparent - v1.1 - 2013-10-15 * * Author: Wyatt Kirby * - * Licensed under the MIT license */(function(e,t,n,r){"use strict";function i(t,n){this.image=t;this.isTransparent=!1;this.options=e.extend(!0,{},e.fn.isTransparent.defaults,n);this.options.quality<0?this.options.quality=0:this.options.quality>10&&(this.options.quality=10);this.options.opacityThreshold<0?this.options.opacityThreshold=0:this.options.opacityThreshold>255&&(this.options.opacityThreshold=255);this.init()}e.fn.isTransparent=function(t){var n=!1;this.each(function(){if(!e.data(this,"plugin_isTransparent")){e.data(this,"plugin_isTransparent",!0);n=(new i(this,t)).isTransparent}});return n};i.prototype.init=function(){if(!e(this.image).is("img"))throw new Error("Element is not an image");var t=this.options.quality,n=new s(this.image),r=n.getImageData(),i=r.data,o=n.getPixelCount(),u=[];for(var a=0,f,l,c,h,p;a=this.options.opacityThreshold&&(l>250&&c>250&&h>250||u.push([l,c,h]))}n.removeCanvas();this.isTransparent=u.length?!1:!0};e.fn.isTransparent.defaults={opacityThreshold:125,quality:5};var s=function(e){this.canvas=n.createElement("canvas");this.context=this.canvas.getContext("2d");n.body.appendChild(this.canvas);this.width=this.canvas.width=e.width;this.height=this.canvas.height=e.height;this.context.drawImage(e,0,0,this.width,this.height)};s.prototype.getPixelCount=function(){return this.width*this.height};s.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)};s.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)}})(jQuery,window,document); \ No newline at end of file + * Licensed under the MIT license */ + + (function(e,t,n,r){"use strict";function i(t,n){this.image=t;this.isTransparent=!1;this.options=e.extend(!0,{},e.fn.isTransparent.defaults,n);this.options.quality<0?this.options.quality=0:this.options.quality>10&&(this.options.quality=10);this.options.opacityThreshold<0?this.options.opacityThreshold=0:this.options.opacityThreshold>255&&(this.options.opacityThreshold=255);this.init()}e.fn.isTransparent=function(t){var n=!1;this.each(function(){if(!e.data(this,"plugin_isTransparent")){e.data(this,"plugin_isTransparent",!0);n=(new i(this,t)).isTransparent}});return n};i.prototype.init=function(){if(!e(this.image).is("img"))throw new Error("Element is not an image");var t=this.options.quality,n=new s(this.image),r=n.getImageData(),i=r.data,o=n.getPixelCount(),u=[];for(var a=0,f,l,c,h,p;a=this.options.opacityThreshold&&(l>250&&c>250&&h>250||u.push([l,c,h]))}n.removeCanvas();this.isTransparent=u.length?!1:!0};e.fn.isTransparent.defaults={opacityThreshold:125,quality:5};var s=function(e){this.canvas=n.createElement("canvas");this.context=this.canvas.getContext("2d");n.body.appendChild(this.canvas);this.width=this.canvas.width=e.width;this.height=this.canvas.height=e.height;this.context.drawImage(e,0,0,this.width,this.height)};s.prototype.getPixelCount=function(){return this.width*this.height};s.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)};s.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)}})(jQuery,window,document); \ No newline at end of file