Skip to content
This repository
Browse code

Updated the minified version of the library.

  • Loading branch information...
commit c108d1702cc8e4c87cb2c1d1ddaf94ca393dd859 1 parent c5024a0
Ryan Sandor Richards authored

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  gury.min.js
2  gury.min.js
... ...
@@ -1 +1 @@
1  
-window.$g=window.Gury=(function(g,k){function c(){for(var x=0;x<arguments.length;x++){var w=arguments[x];if(typeof w=="undefined"||w==null){return false;}}return arguments.length>0;}function l(w){return typeof w=="string";}function i(w){return typeof w=="object";}function b(w){return typeof w=="function";}function u(w){return i(w)||b(w);}function p(w){return i(w)&&c(w.getContext);}function r(w){return c(w.tagName)&&w.tagName=="IMG";}var e=k;function a(){return e!=null;}var f=true;function j(w){if(f){throw"Gury: "+w;}}var o=0;function q(){var x=this.table={};var w=0;function y(z){if(l(z)){return z;}if(!c(z._gury_hash)){z._gury_hash=o++;}return z._gury_hash;}this.set=function(z,B){if(c(B)){var A=y(z);x[A]=B;w++;}};this.has=function(z){var A=y(z);return c(x[A]);};this.get=function(z){var A=y(z);return x[A];};this.remove=function(z){if(c(z)){var A=y(z);delete x[A];w--;}};this.each=function(A){for(var z in x){A(x[z],z);}return this;};this.__defineGetter__("length",function(){return w;});}function t(x){var y=this.table=new q();var w=this.ordered=x?[]:false;this.__defineGetter__("length",function(){return y.length;});this.has=function(z){return y.has(z);};this.add=function(z){if(y.has(z)){return this;}if(w){w.push(z);}y.set(z,z);return this;};this.remove=function(A){if(!y.has(A)){return null;}else{if(w){for(var z=0;z<w.length;z++){if(w[z]==A){w.splice(z,1);break;}}}}y.remove(A);return A;};this.each=function(A){if(w){for(var z=0;z<w.length;z++){A.call(this,w[z],z);}}else{y.each(A);}return this;};this.clear=function(){this.each(function(A,z){this.remove(A);});return this;};this.sort=function(z){if(c(w)){w.sort(z);}return this;};this.first=function(){if(y.length<1||!c(w)){return null;}return w[0];};}function h(){this.name=name;this._children={};this._objects=new t();}h.prototype=(function(){var w=/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$/;return{hasChild:function(x){return i(this._children[x]);},addChild:function(x){return this._children[x]=new h(x);},getChild:function(x){return this._children[x];},getObjects:function(){return this._objects;},find:function(x){if(!x.match(w)){return null;}var B=this;var z=x.split(".");var y=z[z.length-1];for(var A=0;A<z.length;A++){if(!B.hasChild(z[A])){return null;}B=B.getChild(z[A]);}return B;},add:function(x,A){var z=x.split(".");var C=this;var y=z[z.length-1];for(var B=0;B<z.length;B++){if(C.hasChild(z[B])){C=C.getChild(z[B]);}else{C=C.addChild(z[B]);}}C._objects.add(A);return A;},clearObjects:function(){this._objects=new t();},_remove_object:function(y){this._objects.remove(y);for(var x in this._children){var z=this._children[x];z._remove_object(y);}},remove:function(y){var z=new t();if(l(y)){var x=this.find(y);if(!x){return z;}z=x.getObjects();x.clearObjects();}else{this._remove_object(y);z.add(y);}return z;}};})();var v=g.hm=(function(D,y){var w=document.createElement("canvas");var E=w.getContext("2d");if(D){w.style.position="absolute";w.style.top="10px";w.style.left="10px";w.style.background="white";document.body.appendChild(w);}var x,A;function z(F){var H=F.canvases.first();if(!c(H)){return false;}var G=H.width;var I=H.height;if(G!=x||I!=A){w.width=x=G;w.height=A=I;}E.clearRect(0,0,G,I);return true;}function B(F,G){if(b(G)){ob.call(F,E,F.canvas);}else{if(i(G)&&c(G.draw)){G.draw(E,F.canvas);}}}function C(N,L){if(E==null){return false;}var F=E.getImageData(0,0,x,A);var P=F.width;var K=F.height;var J=F.data;if(N<0||N>=P||L<0||L>=K){return false;}var M=P*4*L+N*4;var G=F.data[M];var I=F.data[M+1];var O=F.data[M+2];var H=F.data[M+3];return(G>0||I>0||O>0||H>0);}return{hit:function(G,I,F,K){var J;if(y){J=new Date().getTime();}var H=false;if(u(I)){if(!z(G)){return false;}B(G,I);H=C(F,K);}if(y&&console&&console.log){console.log("Hit detection completed in "+(new Date().getTime()-J)+"ms");}return H;}};})(false,false);var s=new q();function m(w){this.canvases=new t(true);this._objects=new t(true);this._tags=new h("__global");this._paused=false;this._loop_interval=null;this._clear_on_draw=true;this._events={};var x=0;this.nextZ=function(){return x++;};}m.prototype={get canvas(){return this.canvases.first();},get ctx(){var w=this.canvases.first();if(w){return w.getContext("2d");}return null;},register:function(w){if(p(w)){if(s.has(w)){s.get(w).unregister(w);}s.set(w,this);this.canvases.add(w);n.bind(this,w);}else{j("register() - Gury only supports registration of Canvas elements at this time.");}return this;},unregister:function(w){if(p(w)){s.remove(w);n.unbind(this,w);this.canvases.remove(w);}return this;},place:function(w){this.canvases.each(function(x){if(a()){e(w).append(x);}else{if(typeof w=="object"&&typeof w.addChild=="function"){w.addChild(x);}else{j("place() - Unable to place canvas tag (is jQuery loaded?)");}}});return this;},size:function(x,y){this.canvases.each(function(w){w.width=x;w.height=y;});return this;},background:function(w){this.canvases.each(function(x){x.style.background=w;});return this;},add:function(){var w=null,x;if(arguments.length<1){return this;}else{if(arguments.length<2){x=arguments[0];if(!u(x)){return this;}}else{w=arguments[0];x=arguments[1];if(!l(name)||!u(x)){return this;}}}if(w!=null){this._tags.add(w,x);}if(this._objects.has(x)){return this;}if(!c(x._gury)){x._gury={visible:true,paused:false,z:this.nextZ()};}this._objects.add(x);return this;},remove:function(x){if(c(x)){var w=this;var y=this._tags.remove(x);y.each(function(z){w._objects.remove(z);delete z._gury;});}return this;},clear:function(w){if(typeof w!="undefined"){this._clear_on_draw=w;return this;}this.canvases.each(function(y){var x=y.getContext("2d");x.clearRect(0,0,y.width,y.height);});return this;},update:function(){var w=this;w._objects.each(function(x){if(c(x.update)&&!x._gury.paused){x.update(w);}});return this;},draw:function(){if(this._clear_on_draw){this.clear();}var w=this;w._objects.each(function(x){if(!x._gury.visible||!u(x)){return;}w.canvases.each(function(y){if(typeof x=="function"){x.call(w,y.getContext("2d"),y);}else{if(typeof x=="object"&&typeof x.draw!="undefined"){x.draw(y.getContext("2d"),y);}}});});return this;},play:function(x){if(this._loop_interval!=null){return this;}this.draw();var w=this;this._loop_interval=setInterval(function(){if(!w._paused){w.update().draw();}},x);return this;},pause:function(){if(arguments.length>0){for(var x=0;x<arguments.length;x++){var w=arguments[x];if(l(w)){this.each(w,function(y){y._gury.paused=!y._gury.paused;});}else{if(c(w._gury)){w._gury.paused=!w._gury.paused;}}}return this;}else{this._paused=!this._paused;return this;}},stop:function(){if(this._loop_interval!=null){clearInterval(this._loop_interval);this._paused=false;}return this;},each:function(){var w,y;if(arguments.length<2&&b(arguments[0])){y=arguments[0];this._objects.each(y);}else{if(l(arguments[0])&&b(arguments[1])){w=arguments[0];y=arguments[1];var x=this._tags.find(w);if(x){x.getObjects().each(y);}}else{if(b(arguments[0])){y=arguments[0];this._objects.each(y);}else{if(b(arguments[1])){y=arguments[1];this._objects.each(y);}}}}return this;},hide:function(w){return this.each(w,function(y,x){y._gury.visible=false;});},show:function(w){return this.each(w,function(y,x){y._gury.visible=true;});},toggle:function(w){return this.each(w,function(y,x){y._gury.visible=!y._gury.visible;});}};var n=(function(){function y(B,E){var D=new t();if(l(E)){var C=B._tags.find(E);if(C!=null){D=C.getObjects();}}else{if(c(E)&&B._objects.has(E)){D.add(E);}}return D;}m.prototype.bind=function(E,D,F){if(c(E,D,F)){var B=this;var C=B._events;y(B,E).each(function(G){if(!c(C[D])){C[D]=new q();}if(!C[D].has(G)){C[D].set(G,{target:G,handlers:[]});}C[D].get(G).handlers.push(F);});}return this;};m.prototype.unbind=function(E,D,F){if(c(E,D)){var B=this;var C=B._events;y(B,E).each(function(H){if(!c(C[D])){return;}if(!C[D].has(H)){return;}if(c(F)){var G=C[D].get(H).handlers;for(var I=0;I<G.length;I++){if(G[I]==F){G.splice(I,1);break;}}}else{C[D].remove(H);}});}return this;};m.prototype.trigger=function(E,C,F){if(c(E,this._events[E],C)){if(this._events[E].has(C)){var B=this._events[E].get(C).handlers;for(var D=0;D<B.length;D++){B[D].call(C,F);}}}return this;};function x(B){return function(C,D){if(c(C)){if(c(D)){this.bind(C,B,D);}else{this.trigger(C,B);}}return this;};}m.prototype.click=x("click");m.prototype.mousedown=x("mousedown");m.prototype.mouseup=x("mouseup");m.prototype.mousemove=x("mousemove");m.prototype.mouseenter=x("mouseenter");m.prototype.mouseleave=x("mouseleave");function w(B,E){var D=0,C=0;if(B.offsetParent){while(B){D+=B.offsetLeft;C+=B.offsetTop;B=B.offsetParent;}}return{x:E.pageX-D,y:E.pageY-C};}function A(B,F,D,H){if(c(B._events[D])){var G=w(F.canvas,F);F.canvasX=G.x;F.canvasY=G.y;var E=false;var C=new t(true);B._events[D].each(function(I){C.add(I.target);});C.sort(function(J,I){if(J._gury.z<I._gury.z){return 1;}else{return -1;}}).each(function(I){if(!E&&v.hit(B,I,G.x,G.y)){E=true;B.trigger(D,I,F);if(H){H.call(I);}}});if(!E&&H){H.call(null);}}}var z=null;return{bind:function(B,C){C.onclick=function(D){D.canvas=this;A(B,D,"click");};C.onmousedown=function(D){D.canvas=this;A(B,D,"mousedown");};C.onmouseup=function(D){D.canvas=this;A(B,D,"mouseup");};C.onmousemove=function(D){D.canvas=this;A(B,D,"mousemove",function(){if(this!=z){if(c(z)){B.trigger("mouseleave",z,D);}B.trigger("mouseenter",this);z=this;}});};C.onmouseout=function(D){D.canvas=this;if(z!=null){B.trigger("mouseleave",z,D);z=null;}};},unbind:function(B,C){C.onclick=null;C.onmousedown=null;C.onmouseup=null;C.onmousemove=null;C.onmouseleave=null;}};})();function d(B,A){var x={};for(var y in x){if(!c(A[y])){A[y]=x[y];}}var w=new m(A);var z;if(i(B)&&c(B.selector,B.length)){B.each(function(D,C){w.register(C);});}else{if(l(B)){z=document.getElementById(B);if(!c(z)){j('Unable to find canvas with id="'+B+'"');}else{if(s.has(z)){return s.get(z);}}w.register(z);}else{if(i(B)){z=B;if(s.has(z)){return s.get(z);}w.register(z);}else{w.register(document.createElement("canvas"));}}}return w;}d.failWithException=function(w){if(!w){return f;}return f=w?true:false;};return d;})(window,window.jQuery);(function(a){if(typeof a=="undefined"||a==null){return;}a.fn.gury=function(b){return $g(this,b);};})(window.jQuery);
  1
+window.$g=window.Gury=(function(g,k){function c(){for(var x=0;x<arguments.length;x++){var w=arguments[x];if(typeof w=="undefined"||w==null){return false;}}return arguments.length>0;}function l(w){return typeof w=="string";}function i(w){return typeof w=="object";}function b(w){return typeof w=="function";}function u(w){return i(w)||b(w);}function p(w){return i(w)&&c(w.getContext);}function r(w){return c(w.tagName)&&w.tagName=="IMG";}var e=k;function a(){return e!=null;}var f=true;function j(w){if(f){throw"Gury: "+w;}}var o=0;function q(){var x=this.table={};var w=0;function y(z){if(l(z)){return z;}if(!c(z._gury_hash)){z._gury_hash=o++;}return z._gury_hash;}this.set=function(z,B){if(c(B)){var A=y(z);x[A]=B;w++;}};this.has=function(z){var A=y(z);return c(x[A]);};this.get=function(z){var A=y(z);return x[A];};this.remove=function(z){if(c(z)){var A=y(z);delete x[A];w--;}};this.each=function(A){for(var z in x){A(x[z],z);}return this;};this.__defineGetter__("length",function(){return w;});}function t(x){var y=this.table=new q();var w=this.ordered=x?[]:false;this.__defineGetter__("length",function(){return y.length;});this.has=function(z){return y.has(z);};this.add=function(z){if(y.has(z)){return this;}if(w){w.push(z);}y.set(z,z);return this;};this.remove=function(A){if(!y.has(A)){return null;}else{if(w){for(var z=0;z<w.length;z++){if(w[z]==A){w.splice(z,1);break;}}}}y.remove(A);return A;};this.each=function(A){if(w){for(var z=0;z<w.length;z++){A.call(this,w[z],z);}}else{y.each(A);}return this;};this.clear=function(){this.each(function(A,z){this.remove(A);});return this;};this.sort=function(z){if(c(w)){w.sort(z);}return this;};this.first=function(){if(y.length<1||!c(w)){return null;}return w[0];};}function h(){this.name=name;this._children={};this._objects=new t();}h.prototype=(function(){var w=/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*$/;return{hasChild:function(x){return i(this._children[x]);},addChild:function(x){return this._children[x]=new h(x);},getChild:function(x){return this._children[x];},getObjects:function(){return this._objects;},find:function(x){if(!x.match(w)){return null;}var B=this;var z=x.split(".");var y=z[z.length-1];for(var A=0;A<z.length;A++){if(!B.hasChild(z[A])){return null;}B=B.getChild(z[A]);}return B;},add:function(x,A){var z=x.split(".");var C=this;var y=z[z.length-1];for(var B=0;B<z.length;B++){if(C.hasChild(z[B])){C=C.getChild(z[B]);}else{C=C.addChild(z[B]);}}C._objects.add(A);return A;},clearObjects:function(){this._objects=new t();},_remove_object:function(y){this._objects.remove(y);for(var x in this._children){var z=this._children[x];z._remove_object(y);}},remove:function(y){var z=new t();if(l(y)){var x=this.find(y);if(!x){return z;}z=x.getObjects();x.clearObjects();}else{this._remove_object(y);z.add(y);}return z;}};})();var v=(function(D,y){var w=document.createElement("canvas");var E=w.getContext("2d");if(D){w.style.position="absolute";w.style.top="10px";w.style.left="10px";w.style.background="white";document.body.appendChild(w);}var x,A;function z(F){var H=F.canvas;if(!c(H)){return false;}var G=H.width;var I=H.height;if(G!=x||I!=A){w.width=x=G;w.height=A=I;}E.clearRect(0,0,G,I);return true;}function B(F,G){if(b(G)){ob.call(F,E,F.canvas);}else{if(i(G)&&c(G.draw)){G.draw(E,F.canvas);}}}function C(N,L){if(E==null){return false;}var F=E.getImageData(0,0,x,A);var P=F.width;var K=F.height;var J=F.data;if(N<0||N>=P||L<0||L>=K){return false;}var M=P*4*L+N*4;var G=F.data[M];var I=F.data[M+1];var O=F.data[M+2];var H=F.data[M+3];return(G>0||I>0||O>0||H>0);}return{hit:function(G,I,F,K){var J;if(y){J=new Date().getTime();}var H=false;if(u(I)){if(!z(G)){return false;}B(G,I);H=C(F,K);}if(y&&console&&console.log){console.log("Hit detection completed in "+(new Date().getTime()-J)+"ms");}return H;}};})(false,false);var s=new q();function m(w){this.canvas=null;this.ctx=null;this._objects=new t(true);this._tags=new h("__global");this._paused=false;this._loop_interval=null;this._clear_on_draw=true;this._events={};var x=0;this.nextZ=function(){return x++;};}m.prototype={register:function(w){if(p(w)){this.canvas=w;this.ctx=w.getContext("2d");if(s.has(w)){s.get(w).unregister(w);}s.set(w,this);n.bind(this,w);}else{j("register() - Gury only supports registration of Canvas elements at this time.");}return this;},unregister:function(w){if(p(w)){s.remove(w);n.unbind(this,w);this.canvas=null;this.ctx=null;}return this;},place:function(x){var w=this.canvas;if(a()){e(x).append(w);}else{if(typeof x=="object"&&typeof x.addChild=="function"){x.addChild(w);}else{j("place() - Unable to place canvas tag (is jQuery loaded?)");}}return this;},size:function(x,y){this.canvas.width=x;this.canvas.height=y;return this;},background:function(w){this.canvas.style.background=w;return this;},add:function(){var w=null,y;if(arguments.length<1){return this;}else{if(arguments.length<2){y=arguments[0];if(!u(y)){return this;}}else{w=arguments[0];y=arguments[1];if(!l(name)||!u(y)){return this;}}}if(w!=null){this._tags.add(w,y);}if(this._objects.has(y)){return this;}if(!c(y._gury)){y._gury={visible:true,paused:false,z:this.nextZ()};}this._objects.add(y);var z=["click","mousedown","mouseup","mousemove","mouseenter","mouseleave"];for(var A in z){var x=z[A];if(c(y[x])&&b(y[x])){this.bind(y,x,y[x]);}}return this;},remove:function(x){if(c(x)){var w=this;var y=this._tags.remove(x);y.each(function(z){w._objects.remove(z);delete z._gury;});}return this;},clear:function(w){if(typeof w!="undefined"){this._clear_on_draw=w;return this;}this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);return this;},update:function(){var w=this;w._objects.each(function(x){if(c(x.update)&&!x._gury.paused){x.update(w);}});return this;},draw:function(){if(this._clear_on_draw){this.clear();}var w=this;w._objects.each(function(x){if(!x._gury.visible||!u(x)){return;}if(typeof x=="function"){x.call(w,w.ctx,w.canvas);}else{if(typeof x=="object"&&typeof x.draw!="undefined"){x.draw(w.ctx,w.canvas);}}});return this;},play:function(x){if(this._loop_interval!=null){return this;}this.draw();var w=this;this._loop_interval=setInterval(function(){if(!w._paused){w.update().draw();}},x);return this;},pause:function(){if(arguments.length>0){for(var x=0;x<arguments.length;x++){var w=arguments[x];if(l(w)){this.each(w,function(y){y._gury.paused=!y._gury.paused;});}else{if(c(w._gury)){w._gury.paused=!w._gury.paused;}}}return this;}else{this._paused=!this._paused;return this;}},stop:function(){if(this._loop_interval!=null){clearInterval(this._loop_interval);this._paused=false;}return this;},each:function(){var w,y;if(arguments.length<2&&b(arguments[0])){y=arguments[0];this._objects.each(y);}else{if(l(arguments[0])&&b(arguments[1])){w=arguments[0];y=arguments[1];var x=this._tags.find(w);if(x){x.getObjects().each(y);}}else{if(b(arguments[0])){y=arguments[0];this._objects.each(y);}else{if(b(arguments[1])){y=arguments[1];this._objects.each(y);}}}}return this;},hide:function(w){return this.each(w,function(y,x){y._gury.visible=false;});},show:function(w){return this.each(w,function(y,x){y._gury.visible=true;});},toggle:function(w){return this.each(w,function(y,x){y._gury.visible=!y._gury.visible;});}};var n=(function(){function y(B,E){var D=new t();if(l(E)){var C=B._tags.find(E);if(C!=null){D=C.getObjects();}}else{if(c(E)&&B._objects.has(E)){D.add(E);}}return D;}m.prototype.bind=function(E,D,F){if(c(E,D,F)){var B=this;var C=B._events;y(B,E).each(function(G){if(!c(C[D])){C[D]=new q();}if(!C[D].has(G)){C[D].set(G,{target:G,handlers:[]});}C[D].get(G).handlers.push(F);});}return this;};m.prototype.unbind=function(E,D,F){if(c(E,D)){var B=this;var C=B._events;y(B,E).each(function(H){if(!c(C[D])){return;}if(!C[D].has(H)){return;}if(c(F)){var G=C[D].get(H).handlers;for(var I=0;I<G.length;I++){if(G[I]==F){G.splice(I,1);break;}}}else{C[D].remove(H);}});}return this;};m.prototype.trigger=function(E,C,F){if(c(E,this._events[E],C)){if(this._events[E].has(C)){var B=this._events[E].get(C).handlers;for(var D=0;D<B.length;D++){B[D].call(C,F);}}}return this;};function x(B){return function(C,D){if(c(C)){if(c(D)){this.bind(C,B,D);}else{this.trigger(C,B);}}return this;};}m.prototype.click=x("click");m.prototype.mousedown=x("mousedown");m.prototype.mouseup=x("mouseup");m.prototype.mousemove=x("mousemove");m.prototype.mouseenter=x("mouseenter");m.prototype.mouseleave=x("mouseleave");function w(B,E){var D=0,C=0;if(B.offsetParent){while(B){D+=B.offsetLeft;C+=B.offsetTop;B=B.offsetParent;}}return{x:E.pageX-D,y:E.pageY-C};}function A(B,F,D,H){if(c(B._events[D])){var G=w(F.canvas,F);F.canvasX=G.x;F.canvasY=G.y;var E=false;var C=new t(true);B._events[D].each(function(I){C.add(I.target);});C.sort(function(J,I){if(J._gury.z<I._gury.z){return 1;}else{return -1;}}).each(function(I){if(!E&&v.hit(B,I,G.x,G.y)){E=true;B.trigger(D,I,F);if(H){H.call(I);}}});if(!E&&H){H.call(null);}}}var z=null;return{bind:function(B,C){C.onclick=function(D){D.canvas=this;A(B,D,"click");};C.onmousedown=function(D){D.canvas=this;A(B,D,"mousedown");};C.onmouseup=function(D){D.canvas=this;A(B,D,"mouseup");};C.onmousemove=function(D){D.canvas=this;A(B,D,"mousemove",function(){if(this!=z){if(c(z)){B.trigger("mouseleave",z,D);}B.trigger("mouseenter",this);z=this;}});};C.onmouseout=function(D){D.canvas=this;if(z!=null){B.trigger("mouseleave",z,D);z=null;}};},unbind:function(B,C){C.onclick=null;C.onmousedown=null;C.onmouseup=null;C.onmousemove=null;C.onmouseleave=null;}};})();function d(B,A){var x={};for(var y in x){if(!c(A[y])){A[y]=x[y];}}var w=new m(A);var z;if(l(B)){z=document.getElementById(B);if(!c(z)){j('Unable to find canvas with id="'+B+'"');}else{if(s.has(z)){return s.get(z);}}w.register(z);}else{if(i(B)){z=B;if(s.has(z)){return s.get(z);}w.register(z);}else{w.register(document.createElement("canvas"));}}return w;}d.failWithException=function(w){if(!w){return f;}return f=w?true:false;};return d;})(window,window.jQuery);

0 notes on commit c108d17

Please sign in to comment.
Something went wrong with that request. Please try again.