Browse files

Added sample and snippets

  • Loading branch information...
1 parent af0a9f1 commit b574ca67412af3018dc47e6c9a3be7cfb85ef464 = committed Aug 9, 2012
View
13 requirejs/app/index.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>RequireJS Sample</title>
+</head>
+<body>
+ <div id="output"></div>
+ <canvas id="view" width="375" height="375"></canvas>
+
+ <script src="js/libs/require/require-1.0.7.js" data-main="js/main"></script>
+
+</body>
+</html>
View
102 requirejs/app/js/libs/easeljs-0.4.2.min.js
@@ -0,0 +1,102 @@
+/*
+* EaselJS
+* Visit http://createjs.com/ for documentation, updates and examples.
+*
+* Copyright (c) 2011 gskinner.com, inc.
+*
+* Distributed under the terms of the MIT license.
+* http://www.opensource.org/licenses/mit-license.html
+*
+* This notice shall be included in all copies or substantial portions of the Software.
+*/
+(function(g){var c=function(){throw"UID cannot be instantiated";};c._nextID=0;c.get=function(){return c._nextID++};g.UID=c})(createjs||(createjs={}));var createjs;(function(g){var c=function(){throw"Ticker cannot be instantiated.";};c.useRAF=null;c._listeners=null;c._pauseable=null;c._paused=false;c._inited=false;c._startTime=0;c._pausedTime=0;c._ticks=0;c._pausedTicks=0;c._interval=50;c._lastTime=0;c._times=null;c._tickTimes=null;c._rafActive=false;c._timeoutID=null;c.addListener=function(a,j){a!=null&&(c._inited||c.init(),c.removeListener(a),c._pauseable[c._listeners.length]=j==null?true:j,c._listeners.push(a))};c.init=function(){c._inited=true;c._times=
+[];c._tickTimes=[];c._pauseable=[];c._listeners=[];c._times.push(c._lastTime=c._startTime=c._getTime());c.setInterval(c._interval)};c.removeListener=function(a){c._listeners!=null&&(a=c._listeners.indexOf(a),a!=-1&&(c._listeners.splice(a,1),c._pauseable.splice(a,1)))};c.removeAllListeners=function(){c._listeners=[];c._pauseable=[]};c.setInterval=function(a){c._interval=a;c._inited&&c._setupTick()};c.getInterval=function(){return c._interval};c.setFPS=function(a){c.setInterval(1E3/a)};c.getFPS=function(){return 1E3/
+c._interval};c.getMeasuredFPS=function(a){if(c._times.length<2)return-1;a==null&&(a=c.getFPS()|0);a=Math.min(c._times.length-1,a);return 1E3/((c._times[0]-c._times[a])/a)};c.setPaused=function(a){c._paused=a};c.getPaused=function(){return c._paused};c.getTime=function(a){return c._getTime()-c._startTime-(a?c._pausedTime:0)};c.getTicks=function(a){return c._ticks-(a?c._pausedTicks:0)};c._handleAF=function(){c._rafActive=false;c._setupTick();c._getTime()-c._lastTime>=(c._interval-1)*0.97&&c._tick()};
+c._handleTimeout=function(){c.timeoutID=null;c._setupTick();c._tick()};c._setupTick=function(){if(!(c._rafActive||c.timeoutID!=null)){if(c.useRAF){var a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(a){a(c._handleAF);c._rafActive=true;return}}c.timeoutID=setTimeout(c._handleTimeout,c._interval)}};c._tick=function(){var a=c._getTime();c._ticks++;var j=a-c._lastTime,b=c._paused;b&&(c._pausedTicks++,
+c._pausedTime+=j);c._lastTime=a;for(var e=c._pauseable,d=c._listeners.slice(),f=d?d.length:0,h=0;h<f;h++){var l=d[h];l==null||b&&e[h]||(l.tick?l.tick(j,b):l instanceof Function&&l(j,b))}for(c._tickTimes.unshift(c._getTime()-a);c._tickTimes.length>100;)c._tickTimes.pop();for(c._times.unshift(a);c._times.length>100;)c._times.pop()};var b=window.performance&&(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow);c._getTime=function(){return b&&b.call(performance)||
+(new Date).getTime()};g.Ticker=c})(createjs||(createjs={}));(function(g){var c=function(a,j,b,e,c){this.initialize(a,j,b,e,c)},b=c.prototype;b.stageX=0;b.stageY=0;b.type=null;b.nativeEvent=null;b.onMouseMove=null;b.onMouseUp=null;b.target=null;b.pointerID=0;b.primary=false;b.initialize=function(a,j,b,e,c,f,h){this.type=a;this.stageX=j;this.stageY=b;this.target=e;this.nativeEvent=c;this.pointerID=f;this.primary=h};b.clone=function(){return new c(this.type,this.stageX,this.stageY,this.target,this.nativeEvent,this.pointerID,this.primary)};b.toString=function(){return"[MouseEvent (type="+
+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"};g.MouseEvent=c})(createjs||(createjs={}));(function(g){var c=function(a,j,b,c,d,f){this.initialize(a,j,b,c,d,f)},b=c.prototype;c.identity=null;c.DEG_TO_RAD=Math.PI/180;b.a=1;b.b=0;b.c=0;b.d=1;b.tx=0;b.ty=0;b.alpha=1;b.shadow=null;b.compositeOperation=null;b.initialize=function(a,j,b,c,d,f){if(a!=null)this.a=a;this.b=j||0;this.c=b||0;if(c!=null)this.d=c;this.tx=d||0;this.ty=f||0;return this};b.prepend=function(a,j,b,c,d,f){var h=this.tx;if(a!=1||j!=0||b!=0||c!=1){var l=this.a,k=this.c;this.a=l*a+this.b*b;this.b=l*j+this.b*c;this.c=k*a+this.d*
+b;this.d=k*j+this.d*c}this.tx=h*a+this.ty*b+d;this.ty=h*j+this.ty*c+f;return this};b.append=function(a,j,b,c,d,f){var h=this.a,l=this.b,k=this.c,i=this.d;this.a=a*h+j*k;this.b=a*l+j*i;this.c=b*h+c*k;this.d=b*l+c*i;this.tx=d*h+f*k+this.tx;this.ty=d*l+f*i+this.ty;return this};b.prependMatrix=function(a){this.prepend(a.a,a.b,a.c,a.d,a.tx,a.ty);this.prependProperties(a.alpha,a.shadow,a.compositeOperation);return this};b.appendMatrix=function(a){this.append(a.a,a.b,a.c,a.d,a.tx,a.ty);this.appendProperties(a.alpha,
+a.shadow,a.compositeOperation);return this};b.prependTransform=function(a,j,b,e,d,f,h,l,k){if(d%360)var i=d*c.DEG_TO_RAD,d=Math.cos(i),i=Math.sin(i);else d=1,i=0;if(l||k)this.tx-=l,this.ty-=k;f||h?(f*=c.DEG_TO_RAD,h*=c.DEG_TO_RAD,this.prepend(d*b,i*b,-i*e,d*e,0,0),this.prepend(Math.cos(h),Math.sin(h),-Math.sin(f),Math.cos(f),a,j)):this.prepend(d*b,i*b,-i*e,d*e,a,j);return this};b.appendTransform=function(a,j,b,e,d,f,h,l,k){if(d%360)var i=d*c.DEG_TO_RAD,d=Math.cos(i),i=Math.sin(i);else d=1,i=0;f||
+h?(f*=c.DEG_TO_RAD,h*=c.DEG_TO_RAD,this.append(Math.cos(h),Math.sin(h),-Math.sin(f),Math.cos(f),a,j),this.append(d*b,i*b,-i*e,d*e,0,0)):this.append(d*b,i*b,-i*e,d*e,a,j);if(l||k)this.tx-=l*this.a+k*this.c,this.ty-=l*this.b+k*this.d;return this};b.rotate=function(a){var j=Math.cos(a),a=Math.sin(a),b=this.a,c=this.c,d=this.tx;this.a=b*j-this.b*a;this.b=b*a+this.b*j;this.c=c*j-this.d*a;this.d=c*a+this.d*j;this.tx=d*j-this.ty*a;this.ty=d*a+this.ty*j;return this};b.skew=function(a,j){a*=c.DEG_TO_RAD;j*=
+c.DEG_TO_RAD;this.append(Math.cos(j),Math.sin(j),-Math.sin(a),Math.cos(a),0,0);return this};b.scale=function(a,j){this.a*=a;this.d*=j;this.tx*=a;this.ty*=j;return this};b.translate=function(a,j){this.tx+=a;this.ty+=j;return this};b.identity=function(){this.alpha=this.a=this.d=1;this.b=this.c=this.tx=this.ty=0;this.shadow=this.compositeOperation=null;return this};b.invert=function(){var a=this.a,j=this.b,b=this.c,c=this.d,d=this.tx,f=a*c-j*b;this.a=c/f;this.b=-j/f;this.c=-b/f;this.d=a/f;this.tx=(b*
+this.ty-c*d)/f;this.ty=-(a*this.ty-j*d)/f;return this};b.isIdentity=function(){return this.tx==0&&this.ty==0&&this.a==1&&this.b==0&&this.c==0&&this.d==1};b.decompose=function(a){a==null&&(a={});a.x=this.tx;a.y=this.ty;a.scaleX=Math.sqrt(this.a*this.a+this.b*this.b);a.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var j=Math.atan2(-this.c,this.d),b=Math.atan2(this.b,this.a);j==b?(a.rotation=b/c.DEG_TO_RAD,this.a<0&&this.d>=0&&(a.rotation+=a.rotation<=0?180:-180),a.skewX=a.skewY=0):(a.skewX=j/c.DEG_TO_RAD,
+a.skewY=b/c.DEG_TO_RAD);return a};b.reinitialize=function(a,j,b,c,d,f,h,l,k){this.initialize(a,j,b,c,d,f);this.alpha=h||1;this.shadow=l;this.compositeOperation=k;return this};b.appendProperties=function(a,j,b){this.alpha*=a;this.shadow=j||this.shadow;this.compositeOperation=b||this.compositeOperation;return this};b.prependProperties=function(a,j,b){this.alpha*=a;this.shadow=this.shadow||j;this.compositeOperation=this.compositeOperation||b;return this};b.clone=function(){var a=new c(this.a,this.b,
+this.c,this.d,this.tx,this.ty);a.shadow=this.shadow;a.alpha=this.alpha;a.compositeOperation=this.compositeOperation;return a};b.toString=function(){return"[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"};c.identity=new c(1,0,0,1,0,0);g.Matrix2D=c})(createjs||(createjs={}));(function(g){var c=function(a,j){this.initialize(a,j)},b=c.prototype;b.x=0;b.y=0;b.initialize=function(a,j){this.x=a==null?0:a;this.y=j==null?0:j};b.clone=function(){return new c(this.x,this.y)};b.toString=function(){return"[Point (x="+this.x+" y="+this.y+")]"};g.Point=c})(createjs||(createjs={}));(function(g){var c=function(a,j,b,c){this.initialize(a,j,b,c)},b=c.prototype;b.x=0;b.y=0;b.width=0;b.height=0;b.initialize=function(a,j,b,c){this.x=a==null?0:a;this.y=j==null?0:j;this.width=b==null?0:b;this.height=c==null?0:c};b.clone=function(){return new c(this.x,this.y,this.width,this.height)};b.toString=function(){return"[Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")]"};g.Rectangle=c})(createjs||(createjs={}));(function(g){var c=function(a,b,c,e){this.initialize(a,b,c,e)},b=c.prototype;c.identity=null;b.color=null;b.offsetX=0;b.offsetY=0;b.blur=0;b.initialize=function(a,b,c,e){this.color=a;this.offsetX=b;this.offsetY=c;this.blur=e};b.toString=function(){return"[Shadow]"};b.clone=function(){return new c(this.color,this.offsetX,this.offsetY,this.blur)};c.identity=new c("transparent",0,0,0);g.Shadow=c})(createjs||(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype;b.complete=true;b.onComplete=null;b._animations=null;b._frames=null;b._images=null;b._data=null;b._loadCount=0;b._frameHeight=0;b._frameWidth=0;b._numFrames=0;b._regX=0;b._regY=0;b.initialize=function(a){var b,c,e;if(a!=null){if(a.images&&(c=a.images.length)>0){e=this._images=[];for(b=0;b<c;b++){var d=a.images[b];if(typeof d=="string"){var f=d,d=new Image;d.src=f}e.push(d);if(!d.getContext&&!d.complete)this._loadCount++,this.complete=
+false,function(a){d.onload=function(){a._handleImageLoad()}}(this)}}if(a.frames!=null)if(a.frames instanceof Array){this._frames=[];e=a.frames;for(b=0,c=e.length;b<c;b++)f=e[b],this._frames.push({image:this._images[f[4]?f[4]:0],rect:new g.Rectangle(f[0],f[1],f[2],f[3]),regX:f[5]||0,regY:f[6]||0})}else c=a.frames,this._frameWidth=c.width,this._frameHeight=c.height,this._regX=c.regX||0,this._regY=c.regY||0,this._numFrames=c.count,this._loadCount==0&&this._calculateFrames();if((c=a.animations)!=null){this._animations=
+[];this._data={};for(var h in c){a={name:h};f=c[h];if(isNaN(f))if(f instanceof Array){a.frequency=f[3];a.next=f[2];e=a.frames=[];for(b=f[0];b<=f[1];b++)e.push(b)}else a.frequency=f.frequency,a.next=f.next,b=f.frames,e=a.frames=!isNaN(b)?[b]:b.slice(0);else e=a.frames=[f];a.next=e.length<2||a.next==false?null:a.next==null||a.next==true?h:a.next;if(!a.frequency)a.frequency=1;this._animations.push(h);this._data[h]=a}}}};b.getNumFrames=function(a){return a==null?this._frames?this._frames.length:this._numFrames:
+(a=this._data[a],a==null?0:a.frames.length)};b.getAnimations=function(){return this._animations.slice(0)};b.getAnimation=function(a){return this._data[a]};b.getFrame=function(a){return this.complete&&this._frames&&(frame=this._frames[a])?frame:null};b.toString=function(){return"[SpriteSheet]"};b.clone=function(){var a=new c;a.complete=this.complete;a._animations=this._animations;a._frames=this._frames;a._images=this._images;a._data=this._data;a._frameHeight=this._frameHeight;a._frameWidth=this._frameWidth;
+a._numFrames=this._numFrames;a._loadCount=this._loadCount;return a};b._handleImageLoad=function(){if(--this._loadCount==0)this._calculateFrames(),this.complete=true,this.onComplete&&this.onComplete()};b._calculateFrames=function(){if(!(this._frames||this._frameWidth==0)){this._frames=[];for(var a=0,b=this._frameWidth,c=this._frameHeight,e=0,d=this._images;e<d.length;e++){for(var f=d[e],h=(f.width+1)/b|0,l=(f.height+1)/c|0,l=this._numFrames>0?Math.min(this._numFrames-a,h*l):h*l,k=0;k<l;k++)this._frames.push({image:f,
+rect:new g.Rectangle(k%h*b,(k/h|0)*c,b,c),regX:this._regX,regY:this._regY});a+=l}this._numFrames=a}};g.SpriteSheet=c})(createjs||(createjs={}));(function(g){function c(a,b,c){this.f=a;this.params=b;this.path=c==null?true:c}c.prototype.exec=function(a){this.f.apply(a,this.params)};var b=function(){this.initialize()},a=b.prototype;b.getRGB=function(a,b,c,d){a!=null&&c==null&&(d=b,c=a&255,b=a>>8&255,a=a>>16&255);return d==null?"rgb("+a+","+b+","+c+")":"rgba("+a+","+b+","+c+","+d+")"};b.getHSL=function(a,b,c,d){return d==null?"hsl("+a%360+","+b+"%,"+c+"%)":"hsla("+a%360+","+b+"%,"+c+"%,"+d+")"};b.BASE_64={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,
+J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"+":62,"/":63};b.STROKE_CAPS_MAP=["butt","round","square"];b.STROKE_JOINTS_MAP=["miter","round","bevel"];b._ctx=document.createElement("canvas").getContext("2d");b.beginCmd=new c(b._ctx.beginPath,[],false);b.fillCmd=new c(b._ctx.fill,[],
+false);b.strokeCmd=new c(b._ctx.stroke,[],false);a._strokeInstructions=null;a._strokeStyleInstructions=null;a._fillInstructions=null;a._instructions=null;a._oldInstructions=null;a._activeInstructions=null;a._active=false;a._dirty=false;a.initialize=function(){this.clear();this._ctx=b._ctx};a.draw=function(a){this._dirty&&this._updateInstructions();for(var b=this._instructions,c=0,d=b.length;c<d;c++)b[c].exec(a)};a.drawAsPath=function(a){this._dirty&&this._updateInstructions();for(var b,c=this._instructions,
+d=0,f=c.length;d<f;d++)((b=c[d]).path||d==0)&&b.exec(a)};a.moveTo=function(a,b){this._activeInstructions.push(new c(this._ctx.moveTo,[a,b]));return this};a.lineTo=function(a,b){this._dirty=this._active=true;this._activeInstructions.push(new c(this._ctx.lineTo,[a,b]));return this};a.arcTo=function(a,b,e,d,f){this._dirty=this._active=true;this._activeInstructions.push(new c(this._ctx.arcTo,[a,b,e,d,f]));return this};a.arc=function(a,b,e,d,f,h){this._dirty=this._active=true;h==null&&(h=false);this._activeInstructions.push(new c(this._ctx.arc,
+[a,b,e,d,f,h]));return this};a.quadraticCurveTo=function(a,b,e,d){this._dirty=this._active=true;this._activeInstructions.push(new c(this._ctx.quadraticCurveTo,[a,b,e,d]));return this};a.bezierCurveTo=function(a,b,e,d,f,h){this._dirty=this._active=true;this._activeInstructions.push(new c(this._ctx.bezierCurveTo,[a,b,e,d,f,h]));return this};a.rect=function(a,b,e,d){this._dirty=this._active=true;this._activeInstructions.push(new c(this._ctx.rect,[a,b,e,d]));return this};a.closePath=function(){if(this._active)this._dirty=
+true,this._activeInstructions.push(new c(this._ctx.closePath,[]));return this};a.clear=function(){this._instructions=[];this._oldInstructions=[];this._activeInstructions=[];this._strokeStyleInstructions=this._strokeInstructions=this._fillInstructions=null;this._active=this._dirty=false;return this};a.beginFill=function(a){this._active&&this._newPath();this._fillInstructions=a?[new c(this._setProp,["fillStyle",a],false)]:null;return this};a.beginLinearGradientFill=function(a,b,e,d,f,h){this._active&&
+this._newPath();e=this._ctx.createLinearGradient(e,d,f,h);d=0;for(f=a.length;d<f;d++)e.addColorStop(b[d],a[d]);this._fillInstructions=[new c(this._setProp,["fillStyle",e],false)];return this};a.beginRadialGradientFill=function(a,b,e,d,f,h,l,k){this._active&&this._newPath();e=this._ctx.createRadialGradient(e,d,f,h,l,k);d=0;for(f=a.length;d<f;d++)e.addColorStop(b[d],a[d]);this._fillInstructions=[new c(this._setProp,["fillStyle",e],false)];return this};a.beginBitmapFill=function(a,b){this._active&&this._newPath();
+var e=this._ctx.createPattern(a,b||"");this._fillInstructions=[new c(this._setProp,["fillStyle",e],false)];return this};a.endFill=function(){return this.beginFill()};a.setStrokeStyle=function(a,n,e,d){this._active&&this._newPath();this._strokeStyleInstructions=[new c(this._setProp,["lineWidth",a==null?"1":a],false),new c(this._setProp,["lineCap",n==null?"butt":isNaN(n)?n:b.STROKE_CAPS_MAP[n]],false),new c(this._setProp,["lineJoin",e==null?"miter":isNaN(e)?e:b.STROKE_JOINTS_MAP[e]],false),new c(this._setProp,
+["miterLimit",d==null?"10":d],false)];return this};a.beginStroke=function(a){this._active&&this._newPath();this._strokeInstructions=a?[new c(this._setProp,["strokeStyle",a],false)]:null;return this};a.beginLinearGradientStroke=function(a,b,e,d,f,h){this._active&&this._newPath();e=this._ctx.createLinearGradient(e,d,f,h);d=0;for(f=a.length;d<f;d++)e.addColorStop(b[d],a[d]);this._strokeInstructions=[new c(this._setProp,["strokeStyle",e],false)];return this};a.beginRadialGradientStroke=function(a,b,e,
+d,f,h,l,k){this._active&&this._newPath();e=this._ctx.createRadialGradient(e,d,f,h,l,k);d=0;for(f=a.length;d<f;d++)e.addColorStop(b[d],a[d]);this._strokeInstructions=[new c(this._setProp,["strokeStyle",e],false)];return this};a.beginBitmapStroke=function(a,b){this._active&&this._newPath();var e=this._ctx.createPattern(a,b||"");this._strokeInstructions=[new c(this._setProp,["strokeStyle",e],false)];return this};a.endStroke=function(){this.beginStroke();return this};a.curveTo=a.quadraticCurveTo;a.drawRect=
+a.rect;a.drawRoundRect=function(a,b,c,d,f){this.drawRoundRectComplex(a,b,c,d,f,f,f,f);return this};a.drawRoundRectComplex=function(a,b,e,d,f,h,l,k){this._dirty=this._active=true;var i=Math.PI,g=this._ctx.arc,m=this._ctx.lineTo;this._activeInstructions.push(new c(this._ctx.moveTo,[a+f,b]),new c(m,[a+e-h,b]),h>=0?new c(g,[a+e-h,b+h,h,-i/2,0]):new c(g,[a+e,b,-h,i,i/2,true]),new c(m,[a+e,b+d-l]),k>=0?new c(g,[a+e-l,b+d-l,l,0,i/2]):new c(g,[a+e,b+d,-l,-i/2,i,true]),new c(m,[a+k,b+d]),k>=0?new c(g,[a+k,
+b+d-k,k,i/2,i]):new c(g,[a,b+d,-k,0,-i/2,true]),new c(m,[a,b+f]),f>=0?new c(g,[a+f,b+f,f,i,-i/2]):new c(g,[a,b,-f,i/2,0,true]));return this};a.drawCircle=function(a,b,c){this.arc(a,b,c,0,Math.PI*2);return this};a.drawEllipse=function(a,b,e,d){this._dirty=this._active=true;var f=e/2*0.5522848,h=d/2*0.5522848,l=a+e,k=b+d,e=a+e/2,d=b+d/2;this._activeInstructions.push(new c(this._ctx.moveTo,[a,d]),new c(this._ctx.bezierCurveTo,[a,d-h,e-f,b,e,b]),new c(this._ctx.bezierCurveTo,[e+f,b,l,d-h,l,d]),new c(this._ctx.bezierCurveTo,
+[l,d+h,e+f,k,e,k]),new c(this._ctx.bezierCurveTo,[e-f,k,a,d+h,a,d]));return this};a.drawPolyStar=function(a,b,e,d,f,h){this._dirty=this._active=true;f==null&&(f=0);f=1-f;h==null?h=0:h/=180/Math.PI;var l=Math.PI/d;this._activeInstructions.push(new c(this._ctx.moveTo,[a+Math.cos(h)*e,b+Math.sin(h)*e]));for(var k=0;k<d;k++)h+=l,f!=1&&this._activeInstructions.push(new c(this._ctx.lineTo,[a+Math.cos(h)*e*f,b+Math.sin(h)*e*f])),h+=l,this._activeInstructions.push(new c(this._ctx.lineTo,[a+Math.cos(h)*e,
+b+Math.sin(h)*e]));return this};a.decodePath=function(a){for(var c=[this.moveTo,this.lineTo,this.quadraticCurveTo,this.bezierCurveTo],e=[2,2,4,6],d=0,f=a.length,h=[],l=0,k=0,i=b.BASE_64;d<f;){var g=i[a.charAt(d)],m=g>>3,r=c[m];if(!r||g&3)throw"bad path data";var s=e[m];m||(l=k=0);h.length=0;d++;g=(g>>2&1)+2;for(m=0;m<s;m++){var p=i[a.charAt(d)],q=p>>5?-1:1,p=(p&31)<<6|i[a.charAt(d+1)];g==3&&(p=p<<6|i[a.charAt(d+2)]);p=q*p/10;m%2?l=p+=l:k=p+=k;h[m]=p;d+=g}r.apply(this,h)}return this};a.clone=function(){var a=
+new b;a._instructions=this._instructions.slice();a._activeInstructions=this._activeInstructions.slice();a._oldInstructions=this._oldInstructions.slice();if(this._fillInstructions)a._fillInstructions=this._fillInstructions.slice();if(this._strokeInstructions)a._strokeInstructions=this._strokeInstructions.slice();if(this._strokeStyleInstructions)a._strokeStyleInstructions=this._strokeStyleInstructions.slice();a._active=this._active;a._dirty=this._dirty;a.drawAsPath=this.drawAsPath;return a};a.toString=
+function(){return"[Graphics]"};a.mt=a.moveTo;a.lt=a.lineTo;a.at=a.arcTo;a.bt=a.bezierCurveTo;a.qt=a.quadraticCurveTo;a.a=a.arc;a.r=a.rect;a.cp=a.closePath;a.c=a.clear;a.f=a.beginFill;a.lf=a.beginLinearGradientFill;a.rf=a.beginRadialGradientFill;a.bf=a.beginBitmapFill;a.ef=a.endFill;a.ss=a.setStrokeStyle;a.s=a.beginStroke;a.ls=a.beginLinearGradientStroke;a.rs=a.beginRadialGradientStroke;a.bs=a.beginBitmapStroke;a.es=a.endStroke;a.dr=a.drawRect;a.rr=a.drawRoundRect;a.rc=a.drawRoundRectComplex;a.dc=
+a.drawCircle;a.de=a.drawEllipse;a.dp=a.drawPolyStar;a.p=a.decodePath;a._updateInstructions=function(){this._instructions=this._oldInstructions.slice();this._instructions.push(b.beginCmd);this._fillInstructions&&this._instructions.push.apply(this._instructions,this._fillInstructions);this._strokeInstructions&&(this._instructions.push.apply(this._instructions,this._strokeInstructions),this._strokeStyleInstructions&&this._instructions.push.apply(this._instructions,this._strokeStyleInstructions));this._instructions.push.apply(this._instructions,
+this._activeInstructions);this._fillInstructions&&this._instructions.push(b.fillCmd);this._strokeInstructions&&this._instructions.push(b.strokeCmd)};a._newPath=function(){this._dirty&&this._updateInstructions();this._oldInstructions=this._instructions;this._activeInstructions=[];this._active=this._dirty=false};a._setProp=function(a,b){this[a]=b};g.Graphics=b})(createjs||(createjs={}));(function(g){var c=function(){this.initialize()},b=c.prototype;c.suppressCrossDomainErrors=false;c._hitTestCanvas=document.createElement("canvas");c._hitTestCanvas.width=c._hitTestCanvas.height=1;c._hitTestContext=c._hitTestCanvas.getContext("2d");c._nextCacheID=1;b.alpha=1;b.cacheCanvas=null;b.id=-1;b.mouseEnabled=true;b.name=null;b.parent=null;b.regX=0;b.regY=0;b.rotation=0;b.scaleX=1;b.scaleY=1;b.skewX=0;b.skewY=0;b.shadow=null;b.visible=true;b.x=0;b.y=0;b.compositeOperation=null;b.snapToPixel=
+false;b.onPress=null;b.onClick=null;b.onDoubleClick=null;b.onMouseOver=null;b.onMouseOut=null;b.onTick=null;b.filters=null;b.cacheID=0;b.mask=null;b.hitArea=null;b._cacheOffsetX=0;b._cacheOffsetY=0;b._cacheDataURLID=0;b._cacheDataURL=null;b._matrix=null;b.initialize=function(){this.id=g.UID.get();this._matrix=new g.Matrix2D};b.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0};b.draw=function(a,b){if(b||!this.cacheCanvas)return false;a.drawImage(this.cacheCanvas,
+this._cacheOffsetX,this._cacheOffsetY);return true};b.updateContext=function(a){var b,c=this.mask;c&&c.graphics&&(b=c.getMatrix(c._matrix),a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty),c.graphics.drawAsPath(a),a.clip(),b.invert(),a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty));b=this._matrix.identity().appendTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.skewX,this.skewY,this.regX,this.regY);g.Stage._snapToPixelEnabled&&this.snapToPixel?a.transform(b.a,b.b,b.c,b.d,b.tx+0.5|0,b.ty+0.5|0):a.transform(b.a,
+b.b,b.c,b.d,b.tx,b.ty);a.globalAlpha*=this.alpha;if(this.compositeOperation)a.globalCompositeOperation=this.compositeOperation;this.shadow&&this._applyShadow(a,this.shadow)};b.cache=function(a,b,n,e){var d=this.cacheCanvas;if(d==null)d=this.cacheCanvas=document.createElement("canvas");var f=d.getContext("2d");d.width=n;d.height=e;f.setTransform(1,0,0,1,-a,-b);f.clearRect(a,b,d.width,d.height);this.draw(f,true,this._matrix.reinitialize(1,0,0,1,-a,-b));this._cacheOffsetX=a;this._cacheOffsetY=b;this._applyFilters();
+this.cacheID=c._nextCacheID++};b.updateCache=function(a){var b=this.cacheCanvas,n=this._cacheOffsetX,e=this._cacheOffsetY;if(b==null)throw"cache() must be called before updateCache()";var d=b.getContext("2d");d.setTransform(1,0,0,1,-n,-e);a?d.globalCompositeOperation=a:d.clearRect(n,e,b.width,b.height);this.draw(d,true);if(a)d.globalCompositeOperation="source-over";this._applyFilters();this.cacheID=c._nextCacheID++};b.uncache=function(){this._cacheDataURL=this.cacheCanvas=null;this.cacheID=this._cacheOffsetX=
+this._cacheOffsetY=0};b.getCacheDataURL=function(){if(!this.cacheCanvas)return null;if(this.cacheID!=this._cacheDataURLID)this._cacheDataURL=this.cacheCanvas.toDataURL();return this._cacheDataURL};b.getStage=function(){for(var a=this;a.parent;)a=a.parent;return a instanceof g.Stage?a:null};b.localToGlobal=function(a,b){var c=this.getConcatenatedMatrix(this._matrix);if(c==null)return null;c.append(1,0,0,1,a,b);return new g.Point(c.tx,c.ty)};b.globalToLocal=function(a,b){var c=this.getConcatenatedMatrix(this._matrix);
+if(c==null)return null;c.invert();c.append(1,0,0,1,a,b);return new g.Point(c.tx,c.ty)};b.localToLocal=function(a,b,c){a=this.localToGlobal(a,b);return c.globalToLocal(a.x,a.y)};b.setTransform=function(a,b,c,e,d,f,h,l,k){this.x=a||0;this.y=b||0;this.scaleX=c==null?1:c;this.scaleY=e==null?1:e;this.rotation=d||0;this.skewX=f||0;this.skewY=h||0;this.regX=l||0;this.regY=k||0};b.getMatrix=function(a){return(a?a.identity():new g.Matrix2D).appendTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,
+this.skewX,this.skewY,this.regX,this.regY).appendProperties(this.alpha,this.shadow,this.compositeOperation)};b.getConcatenatedMatrix=function(a){a?a.identity():a=new g.Matrix2D;for(var b=this;b!=null;)a.prependTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY).prependProperties(b.alpha,b.shadow,b.compositeOperation),b=b.parent;return a};b.hitTest=function(a,b){var n=c._hitTestContext,e=c._hitTestCanvas;n.setTransform(1,0,0,1,-a,-b);this.draw(n);n=this._testHit(n);e.width=
+0;e.width=1;return n};b.clone=function(){var a=new c;this.cloneProps(a);return a};b.toString=function(){return"[DisplayObject (name="+this.name+")]"};b.cloneProps=function(a){a.alpha=this.alpha;a.name=this.name;a.regX=this.regX;a.regY=this.regY;a.rotation=this.rotation;a.scaleX=this.scaleX;a.scaleY=this.scaleY;a.shadow=this.shadow;a.skewX=this.skewX;a.skewY=this.skewY;a.visible=this.visible;a.x=this.x;a.y=this.y;a.mouseEnabled=this.mouseEnabled;a.compositeOperation=this.compositeOperation;if(this.cacheCanvas)a.cacheCanvas=
+this.cacheCanvas.cloneNode(true),a.cacheCanvas.getContext("2d").putImageData(this.cacheCanvas.getContext("2d").getImageData(0,0,this.cacheCanvas.width,this.cacheCanvas.height),0,0)};b._applyShadow=function(a,b){b=b||Shadow.identity;a.shadowColor=b.color;a.shadowOffsetX=b.offsetX;a.shadowOffsetY=b.offsetY;a.shadowBlur=b.blur};b._tick=function(a){if(this.onTick)this.onTick(a)};b._testHit=function(a){try{var b=a.getImageData(0,0,1,1).data[3]>1}catch(n){if(!c.suppressCrossDomainErrors)throw"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.";
+}return b};b._applyFilters=function(){if(this.filters&&this.filters.length!=0&&this.cacheCanvas)for(var a=this.filters.length,b=this.cacheCanvas.getContext("2d"),c=this.cacheCanvas.width,e=this.cacheCanvas.height,d=0;d<a;d++)this.filters[d].applyFilter(b,0,0,c,e)};g.DisplayObject=c})(createjs||(createjs={}));(function(g){var c=function(){this.initialize()},b=c.prototype=new g.DisplayObject;b.children=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(){this.DisplayObject_initialize();this.children=[]};b.isVisible=function(){return this.visible&&this.alpha>0&&this.children.length&&this.scaleX!=0&&this.scaleY!=0};b.DisplayObject_draw=b.draw;b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return true;for(var c=this.children.slice(0),e=0,d=c.length;e<d;e++){var f=c[e];f.isVisible()&&
+(a.save(),f.updateContext(a),f.draw(a),a.restore())}return true};b.addChild=function(a){if(a==null)return a;var b=arguments.length;if(b>1){for(var c=0;c<b;c++)this.addChild(arguments[c]);return arguments[b-1]}a.parent&&a.parent.removeChild(a);a.parent=this;this.children.push(a);return a};b.addChildAt=function(a,b){var c=arguments.length,e=arguments[c-1];if(e<0||e>this.children.length)return arguments[c-2];if(c>2){for(var d=0;d<c-1;d++)this.addChildAt(arguments[d],e+d);return arguments[c-2]}a.parent&&
+a.parent.removeChild(a);a.parent=this;this.children.splice(b,0,a);return a};b.removeChild=function(a){var b=arguments.length;if(b>1){for(var c=true,e=0;e<b;e++)c=c&&this.removeChild(arguments[e]);return c}return this.removeChildAt(this.children.indexOf(a))};b.removeChildAt=function(a){var b=arguments.length;if(b>1){for(var c=[],e=0;e<b;e++)c[e]=arguments[e];c.sort(function(a,b){return b-a});for(var d=true,e=0;e<b;e++)d=d&&this.removeChildAt(c[e]);return d}if(a<0||a>this.children.length-1)return false;
+if(b=this.children[a])b.parent=null;this.children.splice(a,1);return true};b.removeAllChildren=function(){for(var a=this.children;a.length;)a.pop().parent=null};b.getChildAt=function(a){return this.children[a]};b.sortChildren=function(a){this.children.sort(a)};b.getChildIndex=function(a){return this.children.indexOf(a)};b.getNumChildren=function(){return this.children.length};b.swapChildrenAt=function(a,b){var c=this.children,e=c[a],d=c[b];e&&d&&(c[a]=d,c[b]=e)};b.swapChildren=function(a,b){for(var c=
+this.children,e,d,f=0,h=c.length;f<h;f++)if(c[f]==a&&(e=f),c[f]==b&&(d=f),e!=null&&d!=null)break;f!=h&&(c[e]=b,c[d]=a)};b.setChildIndex=function(a,b){var c=this.children,e=c.length;if(!(a.parent!=this||b<0||b>=e)){for(var d=0;d<e;d++)if(c[d]==a)break;d==e||d==b||(c.splice(d,1),b<d&&b--,c.splice(b,0,a))}};b.contains=function(a){for(;a;){if(a==this)return true;a=a.parent}return false};b.hitTest=function(a,b){return this.getObjectUnderPoint(a,b)!=null};b.getObjectsUnderPoint=function(a,b){var c=[],e=
+this.localToGlobal(a,b);this._getObjectsUnderPoint(e.x,e.y,c);return c};b.getObjectUnderPoint=function(a,b){var c=this.localToGlobal(a,b);return this._getObjectsUnderPoint(c.x,c.y)};b.clone=function(a){var b=new c;this.cloneProps(b);if(a)for(var n=b.children=[],e=0,d=this.children.length;e<d;e++){var f=this.children[e].clone(a);f.parent=b;n.push(f)}return b};b.toString=function(){return"[Container (name="+this.name+")]"};b._tick=function(a){for(var b=this.children.length-1;b>=0;b--){var c=this.children[b];
+c._tick&&c._tick(a)}if(this.onTick)this.onTick(a)};b._getObjectsUnderPoint=function(a,b,n,e){var d=createjs.DisplayObject._hitTestContext,f=createjs.DisplayObject._hitTestCanvas,h=this._matrix,l=e&1&&(this.onPress||this.onClick||this.onDoubleClick)||e&2&&(this.onMouseOver||this.onMouseOut);if(this.cacheCanvas&&l&&(this.getConcatenatedMatrix(h),d.setTransform(h.a,h.b,h.c,h.d,h.tx-a,h.ty-b),d.globalAlpha=h.alpha,this.draw(d),this._testHit(d)))return f.width=0,f.width=1,this;for(var k=this.children.length-
+1;k>=0;k--){var i=this.children[k];if(i.isVisible()&&i.mouseEnabled)if(i instanceof c)if(l){if(i=i._getObjectsUnderPoint(a,b))return this}else{if(i=i._getObjectsUnderPoint(a,b,n,e),!n&&i)return i}else if(!e||l||e&1&&(i.onPress||i.onClick||i.onDoubleClick)||e&2&&(i.onMouseOver||i.onMouseOut)){var g=i.hitArea;i.getConcatenatedMatrix(h);g&&(h.appendTransform(g.x+i.regX,g.y+i.regY,g.scaleX,g.scaleY,g.rotation,g.skewX,g.skewY,g.regX,g.regY),h.alpha*=g.alpha/i.alpha);d.globalAlpha=h.alpha;d.setTransform(h.a,
+h.b,h.c,h.d,h.tx-a,h.ty-b);(g||i).draw(d);if(this._testHit(d))if(f.width=0,f.width=1,l)return this;else if(n)n.push(i);else return i}}return null};g.Container=c})(createjs||(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype=new g.Container;c._snapToPixelEnabled=false;b.autoClear=true;b.canvas=null;b.mouseX=null;b.mouseY=null;b.onMouseMove=null;b.onMouseUp=null;b.onMouseDown=null;b.snapToPixelEnabled=false;b.mouseInBounds=false;b.tickOnUpdate=true;b._pointerData=null;b._pointerCount=0;b._primaryPointerID=null;b._mouseOverIntervalID=null;b.Container_initialize=b.initialize;b.initialize=function(a){this.Container_initialize();this.canvas=a instanceof HTMLCanvasElement?
+a:document.getElementById(a);this._pointerData={};this._enableMouseEvents(true)};b.update=function(a){if(this.canvas)this.autoClear&&this.clear(),c._snapToPixelEnabled=this.snapToPixelEnabled,this.tickOnUpdate&&this._tick(a),this.draw(this.canvas.getContext("2d"),false,this.getConcatenatedMatrix(this._matrix))};b.tick=b.update;b.clear=function(){if(this.canvas){var a=this.canvas.getContext("2d");a.setTransform(1,0,0,1,0,0);a.clearRect(0,0,this.canvas.width,this.canvas.height)}};b.toDataURL=function(a,
+b){b||(b="image/png");var c=this.canvas.getContext("2d"),e=this.canvas.width,d=this.canvas.height,f;if(a){f=c.getImageData(0,0,e,d);var h=c.globalCompositeOperation;c.globalCompositeOperation="destination-over";c.fillStyle=a;c.fillRect(0,0,e,d)}var g=this.canvas.toDataURL(b);if(a)c.clearRect(0,0,e,d),c.putImageData(f,0,0),c.globalCompositeOperation=h;return g};b.enableMouseOver=function(a){if(this._mouseOverIntervalID)clearInterval(this._mouseOverIntervalID),this._mouseOverIntervalID=null;if(a==null)a=
+20;else if(a<=0)return;var b=this;this._mouseOverIntervalID=setInterval(function(){b._testMouseOver()},1E3/Math.min(50,a))};b.clone=function(){var a=new c(null);this.cloneProps(a);return a};b.toString=function(){return"[Stage (name="+this.name+")]"};b._enableMouseEvents=function(){var a=this,b=window.addEventListener?window:document;b.addEventListener("mouseup",function(b){a._handleMouseUp(b)},false);b.addEventListener("mousemove",function(b){a._handleMouseMove(b)},false);b.addEventListener("dblclick",
+function(b){a._handleDoubleClick(b)},false);this.canvas&&this.canvas.addEventListener("mousedown",function(b){a._handleMouseDown(b)},false)};b._getPointerData=function(a){var b=this._pointerData[a];if(!b&&(b=this._pointerData[a]={},this._primaryPointerID==null))this._primaryPointerID=a;return b};b._handleMouseMove=function(a){if(!a)a=window.event;this._handlePointerMove(-1,a,a.pageX,a.pageY)};b._handlePointerMove=function(a,b,c,e){if(this.canvas){var d=this._getPointerData(a),f=d.inBounds;this._updatePointerPosition(a,
+c,e);if(f||d.inBounds){a=new g.MouseEvent("onMouseMove",d.x,d.y,this,b,a,a==this._primaryPointerID);if(this.onMouseMove)this.onMouseMove(a);if(d.event&&d.event.onMouseMove)d.event.onMouseMove(a)}}};b._updatePointerPosition=function(a,b,c){var e=this.canvas;do b-=e.offsetLeft,c-=e.offsetTop;while(e=e.offsetParent);e=this._getPointerData(a);if(e.inBounds=b>=0&&c>=0&&b<this.canvas.width&&c<this.canvas.height)e.x=b,e.y=c;if(a==this._primaryPointerID)this.mouseX=e.x,this.mouseY=e.y,this.mouseInBounds=
+e.inBounds};b._handleMouseUp=function(a){this._handlePointerUp(-1,a,false)};b._handlePointerUp=function(a,b,c){var e=this._getPointerData(a),d=new g.MouseEvent("onMouseUp",e.x,e.y,this,b,a,a==this._primaryPointerID);if(this.onMouseUp)this.onMouseUp(d);if(e.event&&e.event.onMouseUp)e.event.onMouseUp(d);if(e.target&&e.target.onClick&&this._getObjectsUnderPoint(e.x,e.y,null,true,this._mouseOverIntervalID?3:1)==e.target)e.target.onClick(new g.MouseEvent("onClick",e.x,e.y,e.target,b,a,a==this._primaryPointerID));
+if(c){if(a==this._primaryPointerID)this._primaryPointerID=null;delete this._pointerData[a]}else e.event=e.target=null};b._handleMouseDown=function(a){this._handlePointerDown(-1,a,false)};b._handlePointerDown=function(a,b,c,e){var d=this._getPointerData(a);e!=null&&this._updatePointerPosition(a,c,e);if(this.onMouseDown)this.onMouseDown(new g.MouseEvent("onMouseDown",d.x,d.y,this,b,a,a==this._primaryPointerID));if(c=this._getObjectsUnderPoint(d.x,d.y,null,this._mouseOverIntervalID?3:1)){if(c.onPress&&
+(a=new g.MouseEvent("onPress",d.x,d.y,c,b,a,a==this._primaryPointerID),c.onPress(a),a.onMouseMove||a.onMouseUp))d.event=a;d.target=c}};b._testMouseOver=function(){if(this._primaryPointerID==-1&&!(this.mouseX==this._mouseOverX&&this.mouseY==this._mouseOverY&&this.mouseInBounds)){var a=null;if(this.mouseInBounds)a=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,3),this._mouseOverX=this.mouseX,this._mouseOverY=this.mouseY;if(this._mouseOverTarget!=a){if(this._mouseOverTarget&&this._mouseOverTarget.onMouseOut)this._mouseOverTarget.onMouseOut(new g.MouseEvent("onMouseOut",
+this.mouseX,this.mouseY,this._mouseOverTarget));if(a&&a.onMouseOver)a.onMouseOver(new g.MouseEvent("onMouseOver",this.mouseX,this.mouseY,a));this._mouseOverTarget=a}}};b._handleDoubleClick=function(a){if(this.onDoubleClick)this.onDoubleClick(new g.MouseEvent("onDoubleClick",this.mouseX,this.mouseY,this,a,NaN,true));var b=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,this._mouseOverIntervalID?3:1);if(b&&b.onDoubleClick)b.onDoubleClick(new g.MouseEvent("onDoubleClick",this.mouseX,this.mouseY,
+b,a))};g.Stage=c})(createjs||(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype=new g.DisplayObject;b.image=null;b.snapToPixel=true;b.sourceRect=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(a){this.DisplayObject_initialize();typeof a=="string"?(this.image=new Image,this.image.src=a):this.image=a};b.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.image&&(this.image.complete||this.image.getContext||this.image.readyState>=2)};b.DisplayObject_draw=b.draw;
+b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return true;var c=this.sourceRect;c?a.drawImage(this.image,c.x,c.y,c.width,c.height,0,0,c.width,c.height):a.drawImage(this.image,0,0);return true};b.clone=function(){var a=new c(this.image);this.cloneProps(a);return a};b.toString=function(){return"[Bitmap (name="+this.name+")]"};g.Bitmap=c})(createjs||(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype=new g.DisplayObject;b.onAnimationEnd=null;b.currentFrame=-1;b.currentAnimation=null;b.paused=true;b.spriteSheet=null;b.snapToPixel=true;b.offset=0;b.currentAnimationFrame=0;b._advanceCount=0;b._animation=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(a){this.DisplayObject_initialize();this.spriteSheet=a};b.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.spriteSheet.complete&&
+this.currentFrame>=0};b.DisplayObject_draw=b.draw;b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return true;this._normalizeFrame();var c=this.spriteSheet.getFrame(this.currentFrame);if(c!=null){var e=c.rect;a.drawImage(c.image,e.x,e.y,e.width,e.height,-c.regX,-c.regY,e.width,e.height);return true}};b.play=function(){this.paused=false};b.stop=function(){this.paused=true};b.gotoAndPlay=function(a){this.paused=false;this._goto(a)};b.gotoAndStop=function(a){this.paused=true;this._goto(a)};b.advance=
+function(){this._animation?this.currentAnimationFrame++:this.currentFrame++;this._normalizeFrame()};b.clone=function(){var a=new c(this.spriteSheet);this.cloneProps(a);return a};b.toString=function(){return"[BitmapAnimation (name="+this.name+")]"};b._tick=function(a){var b=this._animation?this._animation.frequency:1;!this.paused&&(++this._advanceCount+this.offset)%b==0&&this.advance();if(this.onTick)this.onTick(a)};b._normalizeFrame=function(){var a=this._animation;if(a)if(this.currentAnimationFrame>=
+a.frames.length){if(a.next?this._goto(a.next):(this.paused=true,this.currentAnimationFrame=a.frames.length-1,this.currentFrame=a.frames[this.currentAnimationFrame]),this.onAnimationEnd)this.onAnimationEnd(this,a.name)}else this.currentFrame=a.frames[this.currentAnimationFrame];else if(this.currentFrame>=this.spriteSheet.getNumFrames()&&(this.currentFrame=0,this.onAnimationEnd))this.onAnimationEnd(this,null)};b.DisplayObject_cloneProps=b.cloneProps;b.cloneProps=function(a){this.DisplayObject_cloneProps(a);
+a.onAnimationEnd=this.onAnimationEnd;a.currentFrame=this.currentFrame;a.currentAnimation=this.currentAnimation;a.paused=this.paused;a.offset=this.offset;a._animation=this._animation;a.currentAnimationFrame=this.currentAnimationFrame};b._goto=function(a){if(isNaN(a)){var b=this.spriteSheet.getAnimation(a);if(b)this.currentAnimationFrame=0,this._animation=b,this.currentAnimation=a,this._normalizeFrame()}else this.currentAnimation=this._animation=null,this.currentFrame=a};g.BitmapAnimation=c})(createjs||
+(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype=new g.DisplayObject;b.graphics=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(a){this.DisplayObject_initialize();this.graphics=a?a:new g.Graphics};b.isVisible=function(){return this.visible&&this.alpha>0&&this.scaleX!=0&&this.scaleY!=0&&this.graphics};b.DisplayObject_draw=b.draw;b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return true;this.graphics.draw(a);return true};b.clone=function(a){a=new c(a&&this.graphics?
+this.graphics.clone():this.graphics);this.cloneProps(a);return a};b.toString=function(){return"[Shape (name="+this.name+")]"};g.Shape=c})(createjs||(createjs={}));(function(g){var c=function(a,b,c){this.initialize(a,b,c)},b=c.prototype=new g.DisplayObject;c._workingContext=document.createElement("canvas").getContext("2d");b.text="";b.font=null;b.color=null;b.textAlign=null;b.textBaseline=null;b.maxWidth=null;b.outline=false;b.lineHeight=0;b.lineWidth=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(a,b,c){this.DisplayObject_initialize();this.text=a;this.font=b;this.color=c?c:"#000"};b.isVisible=function(){return Boolean(this.visible&&this.alpha>
+0&&this.scaleX!=0&&this.scaleY!=0&&this.text!=null&&this.text!=="")};b.DisplayObject_draw=b.draw;b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return true;this.outline?a.strokeStyle=this.color:a.fillStyle=this.color;a.font=this.font;a.textAlign=this.textAlign||"start";a.textBaseline=this.textBaseline||"alphabetic";this._drawText(a);return true};b.getMeasuredWidth=function(){return this._getWorkingContext().measureText(this.text).width};b.getMeasuredLineHeight=function(){return this._getWorkingContext().measureText("M").width*
+1.2};b.getMeasuredHeight=function(){return this._drawText()*(this.lineHeight||this.getMeasuredLineHeight())};b.clone=function(){var a=new c(this.text,this.font,this.color);this.cloneProps(a);return a};b.toString=function(){return"[Text (text="+(this.text.length>20?this.text.substr(0,17)+"...":this.text)+")]"};b.DisplayObject_cloneProps=b.cloneProps;b.cloneProps=function(a){this.DisplayObject_cloneProps(a);a.textAlign=this.textAlign;a.textBaseline=this.textBaseline;a.maxWidth=this.maxWidth;a.outline=
+this.outline;a.lineHeight=this.lineHeight;a.lineWidth=this.lineWidth};b._getWorkingContext=function(){var a=c._workingContext;a.font=this.font;a.textAlign=this.textAlign||"start";a.textBaseline=this.textBaseline||"alphabetic";return a};b._drawText=function(a){var b=!!a;b||(a=this._getWorkingContext());for(var c=String(this.text).split(/(?:\r\n|\r|\n)/),e=this.lineHeight||this.getMeasuredLineHeight(),d=0,f=0,h=c.length;f<h;f++){var g=a.measureText(c[f]).width;if(this.lineWidth==null||g<this.lineWidth)b&&
+this._drawTextLine(a,c[f],d*e);else{for(var g=c[f].split(/(\s)/),k=g[0],i=1,o=g.length;i<o;i+=2)a.measureText(k+g[i]+g[i+1]).width>this.lineWidth?(b&&this._drawTextLine(a,k,d*e),d++,k=g[i+1]):k+=g[i]+g[i+1];b&&this._drawTextLine(a,k,d*e)}d++}return d};b._drawTextLine=function(a,b,c){this.outline?a.strokeText(b,0,c,this.maxWidth||65535):a.fillText(b,0,c,this.maxWidth||65535)};g.Text=c})(createjs||(createjs={}));(function(g){var c=function(){throw"SpriteSheetUtils cannot be instantiated";};c._workingCanvas=document.createElement("canvas");c._workingContext=c._workingCanvas.getContext("2d");c.addFlippedFrames=function(b,a,j,g){if(a||j||g){var e=0;a&&c._flip(b,++e,true,false);j&&c._flip(b,++e,false,true);g&&c._flip(b,++e,true,true)}};c.extractFrame=function(b,a){isNaN(a)&&(a=b.getAnimation(a).frames[0]);var j=b.getFrame(a);if(!j)return null;var g=j.rect,e=c._workingCanvas;e.width=g.width;e.height=g.height;
+c._workingContext.drawImage(j.image,g.x,g.y,g.width,g.height,0,0,g.width,g.height);j=new Image;j.src=e.toDataURL("image/png");return j};c._flip=function(b,a,j,g){for(var e=b._images,d=c._workingCanvas,f=c._workingContext,h=e.length/a,l=0;l<h;l++){var k=e[l];k.__tmp=l;d.width=k.width;d.height=k.height;f.setTransform(j?-1:1,0,0,g?-1:1,j?k.width:0,g?k.height:0);f.drawImage(k,0,0);var i=new Image;i.src=d.toDataURL("image/png");i.width=k.width;i.height=k.height;e.push(i)}f=b._frames;d=f.length/a;for(l=
+0;l<d;l++){var k=f[l],o=k.rect.clone(),i=e[k.image.__tmp+h*a],m={image:i,rect:o,regX:k.regX,regY:k.regY};if(j)o.x=i.width-o.x-o.width,m.regX=o.width-k.regX;if(g)o.y=i.height-o.y-o.height,m.regY=o.height-k.regY;f.push(m)}j="_"+(j?"h":"")+(g?"v":"");g=b._animations;b=b._data;e=g.length/a;for(l=0;l<e;l++){f=g[l];k=b[f];h={name:f+j,frequency:k.frequency,next:k.next,frames:[]};k.next&&(h.next+=j);f=k.frames;k=0;for(i=f.length;k<i;k++)h.frames.push(f[k]+d*a);b[h.name]=h;g.push(h.name)}};g.SpriteSheetUtils=
+c})(createjs||(createjs={}));(function(g){var c=function(){this.initialize()},b=c.prototype;c.ERR_DIMENSIONS="frame dimensions exceed max spritesheet dimensions";c.ERR_RUNNING="a build is already running";b.maxWidth=2048;b.maxHeight=2048;b.spriteSheet=null;b.scale=1;b._frames=null;b._animations=null;b._data=null;b._nextFrameIndex=0;b._index=0;b._callback=null;b._timeSlice=null;b._timerID=null;b._scale=1;b.initialize=function(){this._frames=[];this._animations={}};b.addFrame=function(a,b,g,e,d,f){if(this._data)throw c.ERR_RUNNING;
+b=b||a.bounds||a.nominalBounds;!b&&a.getBounds&&(b=a.getBounds());if(!b)return null;g=g||1;return this._frames.push({source:a,sourceRect:b,scale:g,funct:e,params:d,scope:f,index:this._frames.length,height:b.height*g})-1};b.addAnimation=function(a,b,g,e){if(this._data)throw c.ERR_RUNNING;this._animations[a]={frames:b,next:g,frequency:e}};b.addMovieClip=function(a,b,g){if(this._data)throw c.ERR_RUNNING;var e=a.frameBounds,b=b||a.bounds||a.nominalBounds;!b&&a.getBounds&&(b=a.getBounds());if(!b&&!e)return null;
+for(var d=a.timeline.duration,f=0;f<d;f++)this.addFrame(a,e&&e[f]?e[f]:b,g,function(a){var b=this.actionsEnabled;this.actionsEnabled=false;this.gotoAndStop(a);this.actionsEnabled=b},[f],a);var a=a.timeline._labels,h;for(h in a)this.addAnimation(h,a[h],true)};b.build=function(){if(this._data)throw c.ERR_RUNNING;this._callback=null;for(this._startBuild();this._drawNext(););this._endBuild();return this.spriteSheet};b.buildAsync=function(a,b){if(this._data)throw c.ERR_RUNNING;this._callback=a;this._startBuild();
+this._timeSlice=Math.max(0.01,Math.min(0.99,b||0.3))*50;var g=this;this._timerID=setTimeout(function(){g._run()},50-this._timeSlice)};b.stopAsync=function(){clearTimeout(this._timerID);this._data=null};b.clone=function(){throw"SpriteSheetBuilder cannot be cloned.";};b.toString=function(){return"[SpriteSheetBuilder]"};b._startBuild=function(){this.spriteSheet=null;this._index=0;this._scale=this.scale;var a=[];this._data={images:[],frames:a,animations:this._animations};var b=this._frames.slice();b.sort(function(a,
+b){return a.height<=b.height?-1:1});if(b[b.length-1].height>this.maxHeight)throw c.ERR_DIMENSIONS;for(var g=1,e=1,d=0;b.length;){var f=this._fillRow(b,g,d,a);if(f.w>e)e=f.w;g+=f.h+2;if(!f.h||!b.length){var h=document.createElement("canvas");h.width=this._getSize(e,this.maxWidth);h.height=this._getSize(g,this.maxHeight);this._data.images[d]=h;f.h||(e=g=1,d++)}}};b._getSize=function(a,b){for(var c=4;Math.pow(2,++c)<a;);return Math.min(b,Math.pow(2,c))};b._fillRow=function(a,b,n,e){for(var d=this.maxWidth,
+f=this.maxHeight-b,h=1,l=0,k=a.length-1;k>=0;k--){var i=a[k],o=this._scale*i.scale,m=i.sourceRect,r=i.source,s=Math.floor(o*m.x-1),p=Math.floor(o*m.y-1),q=Math.ceil(o*m.height),m=Math.ceil(o*m.width);if(m>d)throw c.ERR_DIMENSIONS;if(!(q>f||h+m>d))i.img=n,i.rect=new g.Rectangle(h,b,m,q),l=l||q,a.splice(k,1),e[i.index]=[h-1,b-1,m+2,q+2,n,Math.round(-s+o*r.regX),Math.round(-p+o*r.regY)],h+=m+2}return{w:h,h:l}};b._endBuild=function(){this.spriteSheet=new g.SpriteSheet(this._data);this._data=null;this._callback&&
+this._callback(this)};b._run=function(){for(var a=(new Date).getTime()+this._timeSlice,b=false;a>(new Date).getTime();)if(!this._drawNext()){b=true;break}if(b)this._endBuild();else{var c=this;this._timerID=setTimeout(function(){c._run()},50-this._timeSlice)}};b._drawNext=function(){var a=this._frames[this._index],b=a.scale*this._scale,c=a.rect,e=a.sourceRect,d=this._data.images[a.img].getContext("2d");a.funct&&a.funct.apply(a.scope,a.params);d.save();d.beginPath();d.rect(c.x-1,c.y-1,c.width+2,c.height+
+2);d.clip();d.translate(c.x-e.x*b+0.5|0,c.y-e.y*b+0.5|0);d.scale(b,b);a.source.draw(d);d.restore();return++this._index<this._frames.length};g.SpriteSheetBuilder=c})(createjs||(createjs={}));(function(g){var c=function(a){this.initialize(a)},b=c.prototype=new g.DisplayObject;b.htmlElement=null;b._style=null;b.DisplayObject_initialize=b.initialize;b.initialize=function(a){typeof a=="string"&&(a=document.getElementById(a));this.DisplayObject_initialize();this.mouseEnabled=false;if(this.htmlElement=a)this._style=a.style,this._style.position="absolute",this._style.transformOrigin=this._style.webkitTransformOrigin=this._style.msTransformOrigin=this._style.MozTransformOrigin="0% 0%"};b.isVisible=
+function(){return this.htmlElement!=null};b.draw=function(){if(this.htmlElement!=null){var a=this.getConcatenatedMatrix(this._matrix),b=this.htmlElement;b.style.opacity=""+a.alpha;b.style.visibility=this.visible?"visible":"hidden";b.style.transform=b.style.webkitTransform=b.style.oTransform=b.style.msTransform=["matrix("+a.a,a.b,a.c,a.d,a.tx+0.5|0,(a.ty+0.5|0)+")"].join(",");b.style.MozTransform=["matrix("+a.a,a.b,a.c,a.d,(a.tx+0.5|0)+"px",(a.ty+0.5|0)+"px)"].join(",");return true}};b.cache=function(){};
+b.uncache=function(){};b.updateCache=function(){};b.hitTest=function(){};b.localToGlobal=function(){};b.globalToLocal=function(){};b.localToLocal=function(){};b.clone=function(){var a=new c;this.cloneProps(a);return a};b.toString=function(){return"[DOMElement (name="+this.name+")]"};b._tick=function(a){if(this.htmlElement!=null&&(this.htmlElement.style.visibility="hidden",this.onTick))this.onTick(a)};g.DOMElement=c})(createjs||(createjs={}));(function(g){var c=function(){this.initialize()},b=c.prototype;b.initialize=function(){};b.getBounds=function(){return new g.Rectangle(0,0,0,0)};b.applyFilter=function(){};b.toString=function(){return"[Filter]"};b.clone=function(){return new c};g.Filter=c})(createjs||(createjs={}));(function(g){var c=function(){throw"Touch cannot be instantiated";};c.isSupported=function(){return"ontouchstart"in window||window.navigator.msPointerEnabled};c.enable=function(b,a,g){if(!b||!b.canvas||!c.isSupported())return false;b.__touch={pointers:{},multitouch:!a,preventDefault:!g,count:0};"ontouchstart"in window?c._IOS_enable(b):window.navigator.msPointerEnabled&&c._IE_enable(b);return true};c._IOS_enable=function(b){var a=b.canvas;a.addEventListener("touchstart",function(a){c._IOS_handleEvent(b,
+a)},false);a.addEventListener("touchmove",function(a){c._IOS_handleEvent(b,a)},false);a.addEventListener("touchend",function(a){c._IOS_handleEvent(b,a)},false);a.addEventListener("touchcancel",function(a){c._IOS_handleEvent(b,a)},false)};c._IOS_handleEvent=function(b,a){b.__touch.preventDefault&&a.preventDefault&&a.preventDefault();for(var c=a.changedTouches,g=a.type,e=0,d=c.length;e<d;e++){var f=c[e],h=f.identifier;f.target==b.canvas&&(g=="touchstart"?this._handleStart(b,h,a,f.pageX,f.pageY):g==
+"touchmove"?this._handleMove(b,h,a,f.pageX,f.pageY):(g=="touchend"||g=="touchcancel")&&this._handleEnd(b,h,a))}};c._IE_enable=function(b){var a=b.canvas;a.addEventListener("MSPointerDown",function(a){c._IE_handleEvent(b,a)},false);window.addEventListener("MSPointerMove",function(a){c._IE_handleEvent(b,a)},false);window.addEventListener("MSPointerUp",function(a){c._IE_handleEvent(b,a)},false);window.addEventListener("MSPointerCancel",function(a){c._IE_handleEvent(b,a)},false);if(b.__touch.preventDefault)a.style.msTouchAction=
+"none";b.__touch.activeIDs={}};c._IE_handleEvent=function(b,a){b.__touch.preventDefault&&a.preventDefault&&a.preventDefault();var c=a.type,g=a.pointerId,e=b.__touch.activeIDs;if(c=="MSPointerDown")a.srcElement==b.canvas&&(e[g]=true,this._handleStart(b,g,a,a.pageX,a.pageY));else if(e[g])if(c=="MSPointerMove")this._handleMove(b,g,a,a.pageX,a.pageY);else if(c=="MSPointerUp"||c=="MSPointerCancel")delete e[g],this._handleEnd(b,g,a)};c._handleStart=function(b,a,c,g,e){var d=b.__touch;if(d.multitouch||!d.count){var f=
+d.pointers;f[a]||(f[a]=true,d.count++,b._handlePointerDown(a,c,g,e))}};c._handleMove=function(b,a,c,g,e){b.__touch.pointers[a]&&b._handlePointerMove(a,c,g,e)};c._handleEnd=function(b,a,c){var g=b.__touch,e=g.pointers;e[a]&&(g.count--,b._handlePointerUp(a,c,true),delete e[a])};g.Touch=c})(createjs||(createjs={}));
View
9,404 requirejs/app/js/libs/jquery-1.7.2.js
9,404 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2,053 requirejs/app/js/libs/require/require-1.0.7.js
@@ -0,0 +1,2053 @@
+/** vim: et:ts=4:sw=4:sts=4
+ * @license RequireJS 1.0.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+/*jslint strict: false, plusplus: false, sub: true */
+/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
+
+var requirejs, require, define;
+(function () {
+ //Change this version number for each release.
+ var version = "1.0.7",
+ commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
+ cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
+ currDirRegExp = /^\.\//,
+ jsSuffixRegExp = /\.js$/,
+ ostring = Object.prototype.toString,
+ ap = Array.prototype,
+ aps = ap.slice,
+ apsp = ap.splice,
+ isBrowser = !!(typeof window !== "undefined" && navigator && document),
+ isWebWorker = !isBrowser && typeof importScripts !== "undefined",
+ //PS3 indicates loaded and complete, but need to wait for complete
+ //specifically. Sequence is "loading", "loaded", execution,
+ // then "complete". The UA check is unfortunate, but not sure how
+ //to feature test w/o causing perf issues.
+ readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
+ /^complete$/ : /^(complete|loaded)$/,
+ defContextName = "_",
+ //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
+ isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]",
+ empty = {},
+ contexts = {},
+ globalDefQueue = [],
+ interactiveScript = null,
+ checkLoadedDepth = 0,
+ useInteractive = false,
+ reservedDependencies = {
+ require: true,
+ module: true,
+ exports: true
+ },
+ req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script,
+ src, subPath, mainScript, dataMain, globalI, ctx, jQueryCheck, checkLoadedTimeoutId;
+
+ function isFunction(it) {
+ return ostring.call(it) === "[object Function]";
+ }
+
+ function isArray(it) {
+ return ostring.call(it) === "[object Array]";
+ }
+
+ /**
+ * Simple function to mix in properties from source into target,
+ * but only if target does not already have a property of the same name.
+ * This is not robust in IE for transferring methods that match
+ * Object.prototype names, but the uses of mixin here seem unlikely to
+ * trigger a problem related to that.
+ */
+ function mixin(target, source, force) {
+ for (var prop in source) {
+ if (!(prop in empty) && (!(prop in target) || force)) {
+ target[prop] = source[prop];
+ }
+ }
+ return req;
+ }
+
+ /**
+ * Constructs an error with a pointer to an URL with more information.
+ * @param {String} id the error ID that maps to an ID on a web page.
+ * @param {String} message human readable error.
+ * @param {Error} [err] the original error, if there is one.
+ *
+ * @returns {Error}
+ */
+ function makeError(id, msg, err) {
+ var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
+ if (err) {
+ e.originalError = err;
+ }
+ return e;
+ }
+
+ /**
+ * Used to set up package paths from a packagePaths or packages config object.
+ * @param {Object} pkgs the object to store the new package config
+ * @param {Array} currentPackages an array of packages to configure
+ * @param {String} [dir] a prefix dir to use.
+ */
+ function configurePackageDir(pkgs, currentPackages, dir) {
+ var i, location, pkgObj;
+
+ for (i = 0; (pkgObj = currentPackages[i]); i++) {
+ pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
+ location = pkgObj.location;
+
+ //Add dir to the path, but avoid paths that start with a slash
+ //or have a colon (indicates a protocol)
+ if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
+ location = dir + "/" + (location || pkgObj.name);
+ }
+
+ //Create a brand new object on pkgs, since currentPackages can
+ //be passed in again, and config.pkgs is the internal transformed
+ //state for all package configs.
+ pkgs[pkgObj.name] = {
+ name: pkgObj.name,
+ location: location || pkgObj.name,
+ //Remove leading dot in main, so main paths are normalized,
+ //and remove any trailing .js, since different package
+ //envs have different conventions: some use a module name,
+ //some use a file name.
+ main: (pkgObj.main || "main")
+ .replace(currDirRegExp, '')
+ .replace(jsSuffixRegExp, '')
+ };
+ }
+ }
+
+ /**
+ * jQuery 1.4.3-1.5.x use a readyWait/ready() pairing to hold DOM
+ * ready callbacks, but jQuery 1.6 supports a holdReady() API instead.
+ * At some point remove the readyWait/ready() support and just stick
+ * with using holdReady.
+ */
+ function jQueryHoldReady($, shouldHold) {
+ if ($.holdReady) {
+ $.holdReady(shouldHold);
+ } else if (shouldHold) {
+ $.readyWait += 1;
+ } else {
+ $.ready(true);
+ }
+ }
+
+ if (typeof define !== "undefined") {
+ //If a define is already in play via another AMD loader,
+ //do not overwrite.
+ return;
+ }
+
+ if (typeof requirejs !== "undefined") {
+ if (isFunction(requirejs)) {
+ //Do not overwrite and existing requirejs instance.
+ return;
+ } else {
+ cfg = requirejs;
+ requirejs = undefined;
+ }
+ }
+
+ //Allow for a require config object
+ if (typeof require !== "undefined" && !isFunction(require)) {
+ //assume it is a config object.
+ cfg = require;
+ require = undefined;
+ }
+
+ /**
+ * Creates a new context for use in require and define calls.
+ * Handle most of the heavy lifting. Do not want to use an object
+ * with prototype here to avoid using "this" in require, in case it
+ * needs to be used in more super secure envs that do not want this.
+ * Also there should not be that many contexts in the page. Usually just
+ * one for the default context, but could be extra for multiversion cases
+ * or if a package needs a special context for a dependency that conflicts
+ * with the standard context.
+ */
+ function newContext(contextName) {
+ var context, resume,
+ config = {
+ waitSeconds: 7,
+ baseUrl: "./",
+ paths: {},
+ pkgs: {},
+ catchError: {}
+ },
+ defQueue = [],
+ specified = {
+ "require": true,
+ "exports": true,
+ "module": true
+ },
+ urlMap = {},
+ defined = {},
+ loaded = {},
+ waiting = {},
+ waitAry = [],
+ urlFetched = {},
+ managerCounter = 0,
+ managerCallbacks = {},
+ plugins = {},
+ //Used to indicate which modules in a build scenario
+ //need to be full executed.
+ needFullExec = {},
+ fullExec = {},
+ resumeDepth = 0;
+
+ /**
+ * Trims the . and .. from an array of path segments.
+ * It will keep a leading path segment if a .. will become
+ * the first path segment, to help with module name lookups,
+ * which act like paths, but can be remapped. But the end result,
+ * all paths that use this function should look normalized.
+ * NOTE: this method MODIFIES the input array.
+ * @param {Array} ary the array of path segments.
+ */
+ function trimDots(ary) {
+ var i, part;
+ for (i = 0; (part = ary[i]); i++) {
+ if (part === ".") {
+ ary.splice(i, 1);
+ i -= 1;
+ } else if (part === "..") {
+ if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
+ //End of the line. Keep at least one non-dot
+ //path segment at the front so it can be mapped
+ //correctly to disk. Otherwise, there is likely
+ //no path mapping for a path starting with '..'.
+ //This can still fail, but catches the most reasonable
+ //uses of ..
+ break;
+ } else if (i > 0) {
+ ary.splice(i - 1, 2);
+ i -= 2;
+ }
+ }
+ }
+ }
+
+ /**
+ * Given a relative module name, like ./something, normalize it to
+ * a real name that can be mapped to a path.
+ * @param {String} name the relative name
+ * @param {String} baseName a real name that the name arg is relative
+ * to.
+ * @returns {String} normalized name
+ */
+ function normalize(name, baseName) {
+ var pkgName, pkgConfig;
+
+ //Adjust any relative paths.
+ if (name && name.charAt(0) === ".") {
+ //If have a base name, try to normalize against it,
+ //otherwise, assume it is a top-level require that will
+ //be relative to baseUrl in the end.
+ if (baseName) {
+ if (config.pkgs[baseName]) {
+ //If the baseName is a package name, then just treat it as one
+ //name to concat the name with.
+ baseName = [baseName];
+ } else {
+ //Convert baseName to array, and lop off the last part,
+ //so that . matches that "directory" and not name of the baseName's
+ //module. For instance, baseName of "one/two/three", maps to
+ //"one/two/three.js", but we want the directory, "one/two" for
+ //this normalization.
+ baseName = baseName.split("/");
+ baseName = baseName.slice(0, baseName.length - 1);
+ }
+
+ name = baseName.concat(name.split("/"));
+ trimDots(name);
+
+ //Some use of packages may use a . path to reference the
+ //"main" module name, so normalize for that.
+ pkgConfig = config.pkgs[(pkgName = name[0])];
+ name = name.join("/");
+ if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
+ name = pkgName;
+ }
+ } else if (name.indexOf("./") === 0) {
+ // No baseName, so this is ID is resolved relative
+ // to baseUrl, pull off the leading dot.
+ name = name.substring(2);
+ }
+ }
+ return name;
+ }
+
+ /**
+ * Creates a module mapping that includes plugin prefix, module
+ * name, and path. If parentModuleMap is provided it will
+ * also normalize the name via require.normalize()
+ *
+ * @param {String} name the module name
+ * @param {String} [parentModuleMap] parent module map
+ * for the module name, used to resolve relative names.
+ *
+ * @returns {Object}
+ */
+ function makeModuleMap(name, parentModuleMap) {
+ var index = name ? name.indexOf("!") : -1,
+ prefix = null,
+ parentName = parentModuleMap ? parentModuleMap.name : null,
+ originalName = name,
+ normalizedName, url, pluginModule;
+
+ if (index !== -1) {
+ prefix = name.substring(0, index);
+ name = name.substring(index + 1, name.length);
+ }
+
+ if (prefix) {
+ prefix = normalize(prefix, parentName);
+ }
+
+ //Account for relative paths if there is a base name.
+ if (name) {
+ if (prefix) {
+ pluginModule = defined[prefix];
+ if (pluginModule && pluginModule.normalize) {
+ //Plugin is loaded, use its normalize method.
+ normalizedName = pluginModule.normalize(name, function (name) {
+ return normalize(name, parentName);
+ });
+ } else {
+ normalizedName = normalize(name, parentName);
+ }
+ } else {
+ //A regular module.
+ normalizedName = normalize(name, parentName);
+
+ url = urlMap[normalizedName];
+ if (!url) {
+ //Calculate url for the module, if it has a name.
+ //Use name here since nameToUrl also calls normalize,
+ //and for relative names that are outside the baseUrl
+ //this causes havoc. Was thinking of just removing
+ //parentModuleMap to avoid extra normalization, but
+ //normalize() still does a dot removal because of
+ //issue #142, so just pass in name here and redo
+ //the normalization. Paths outside baseUrl are just
+ //messy to support.
+ url = context.nameToUrl(name, null, parentModuleMap);
+
+ //Store the URL mapping for later.
+ urlMap[normalizedName] = url;
+ }
+ }
+ }
+
+ return {
+ prefix: prefix,
+ name: normalizedName,
+ parentMap: parentModuleMap,
+ url: url,
+ originalName: originalName,
+ fullName: prefix ? prefix + "!" + (normalizedName || '') : normalizedName
+ };
+ }
+
+ /**
+ * Determine if priority loading is done. If so clear the priorityWait
+ */
+ function isPriorityDone() {
+ var priorityDone = true,
+ priorityWait = config.priorityWait,
+ priorityName, i;
+ if (priorityWait) {
+ for (i = 0; (priorityName = priorityWait[i]); i++) {
+ if (!loaded[priorityName]) {
+ priorityDone = false;
+ break;
+ }
+ }
+ if (priorityDone) {
+ delete config.priorityWait;
+ }
+ }
+ return priorityDone;
+ }
+
+ function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) {
+ return function () {
+ //A version of a require function that passes a moduleName
+ //value for items that may need to
+ //look up paths relative to the moduleName
+ var args = aps.call(arguments, 0), lastArg;
+ if (enableBuildCallback &&
+ isFunction((lastArg = args[args.length - 1]))) {
+ lastArg.__requireJsBuild = true;
+ }
+ args.push(relModuleMap);
+ return func.apply(null, args);
+ };
+ }
+
+ /**
+ * Helper function that creates a require function object to give to
+ * modules that ask for it as a dependency. It needs to be specific
+ * per module because of the implication of path mappings that may
+ * need to be relative to the module name.
+ */
+ function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
+ var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
+
+ mixin(modRequire, {
+ nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
+ toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
+ defined: makeContextModuleFunc(context.requireDefined, relModuleMap),
+ specified: makeContextModuleFunc(context.requireSpecified, relModuleMap),
+ isBrowser: req.isBrowser
+ });
+ return modRequire;
+ }
+
+ /*
+ * Queues a dependency for checking after the loader is out of a
+ * "paused" state, for example while a script file is being loaded
+ * in the browser, where it may have many modules defined in it.
+ */
+ function queueDependency(manager) {
+ context.paused.push(manager);
+ }
+
+ function execManager(manager) {
+ var i, ret, err, errFile, errModuleTree,
+ cb = manager.callback,
+ map = manager.map,
+ fullName = map.fullName,
+ args = manager.deps,
+ listeners = manager.listeners,
+ cjsModule;
+
+ //Call the callback to define the module, if necessary.
+ if (cb && isFunction(cb)) {
+ if (config.catchError.define) {
+ try {
+ ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
+ } catch (e) {
+ err = e;
+ }
+ } else {
+ ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
+ }
+
+ if (fullName) {
+ //If setting exports via "module" is in play,
+ //favor that over return value and exports. After that,
+ //favor a non-undefined return value over exports use.
+ cjsModule = manager.cjsModule;
+ if (cjsModule &&
+ cjsModule.exports !== undefined &&
+ //Make sure it is not already the exports value
+ cjsModule.exports !== defined[fullName]) {
+ ret = defined[fullName] = manager.cjsModule.exports;
+ } else if (ret === undefined && manager.usingExports) {
+ //exports already set the defined value.
+ ret = defined[fullName];
+ } else {
+ //Use the return value from the function.
+ defined[fullName] = ret;
+ //If this module needed full execution in a build
+ //environment, mark that now.
+ if (needFullExec[fullName]) {
+ fullExec[fullName] = true;
+ }
+ }
+ }
+ } else if (fullName) {
+ //May just be an object definition for the module. Only
+ //worry about defining if have a module name.
+ ret = defined[fullName] = cb;
+
+ //If this module needed full execution in a build
+ //environment, mark that now.
+ if (needFullExec[fullName]) {
+ fullExec[fullName] = true;
+ }
+ }
+
+ //Clean up waiting. Do this before error calls, and before
+ //calling back listeners, so that bookkeeping is correct
+ //in the event of an error and error is reported in correct order,
+ //since the listeners will likely have errors if the
+ //onError function does not throw.
+ if (waiting[manager.id]) {
+ delete waiting[manager.id];
+ manager.isDone = true;
+ context.waitCount -= 1;
+ if (context.waitCount === 0) {
+ //Clear the wait array used for cycles.
+ waitAry = [];
+ }
+ }
+
+ //Do not need to track manager callback now that it is defined.
+ delete managerCallbacks[fullName];
+
+ //Allow instrumentation like the optimizer to know the order
+ //of modules executed and their dependencies.
+ if (req.onResourceLoad && !manager.placeholder) {
+ req.onResourceLoad(context, map, manager.depArray);
+ }
+
+ if (err) {
+ errFile = (fullName ? makeModuleMap(fullName).url : '') ||
+ err.fileName || err.sourceURL;
+ errModuleTree = err.moduleTree;
+ err = makeError('defineerror', 'Error evaluating ' +
+ 'module "' + fullName + '" at location "' +
+ errFile + '":\n' +
+ err + '\nfileName:' + errFile +
+ '\nlineNumber: ' + (err.lineNumber || err.line), err);
+ err.moduleName = fullName;
+ err.moduleTree = errModuleTree;
+ return req.onError(err);
+ }
+
+ //Let listeners know of this manager's value.
+ for (i = 0; (cb = listeners[i]); i++) {
+ cb(ret);
+ }
+
+ return undefined;
+ }
+
+ /**
+ * Helper that creates a callack function that is called when a dependency
+ * is ready, and sets the i-th dependency for the manager as the
+ * value passed to the callback generated by this function.
+ */
+ function makeArgCallback(manager, i) {
+ return function (value) {
+ //Only do the work if it has not been done
+ //already for a dependency. Cycle breaking
+ //logic in forceExec could mean this function
+ //is called more than once for a given dependency.
+ if (!manager.depDone[i]) {
+ manager.depDone[i] = true;
+ manager.deps[i] = value;
+ manager.depCount -= 1;
+ if (!manager.depCount) {
+ //All done, execute!
+ execManager(manager);
+ }
+ }
+ };
+ }
+
+ function callPlugin(pluginName, depManager) {
+ var map = depManager.map,
+ fullName = map.fullName,
+ name = map.name,
+ plugin = plugins[pluginName] ||
+ (plugins[pluginName] = defined[pluginName]),
+ load;
+
+ //No need to continue if the manager is already
+ //in the process of loading.
+ if (depManager.loading) {
+ return;
+ }
+ depManager.loading = true;
+
+ load = function (ret) {
+ depManager.callback = function () {
+ return ret;
+ };
+ execManager(depManager);
+
+ loaded[depManager.id] = true;
+
+ //The loading of this plugin
+ //might have placed other things
+ //in the paused queue. In particular,
+ //a loader plugin that depends on
+ //a different plugin loaded resource.
+ resume();
+ };
+
+ //Allow plugins to load other code without having to know the
+ //context or how to "complete" the load.
+ load.fromText = function (moduleName, text) {
+ /*jslint evil: true */
+ var hasInteractive = useInteractive;
+
+ //Indicate a the module is in process of loading.
+ loaded[moduleName] = false;
+ context.scriptCount += 1;
+
+ //Indicate this is not a "real" module, so do not track it
+ //for builds, it does not map to a real file.
+ context.fake[moduleName] = true;
+
+ //Turn off interactive script matching for IE for any define
+ //calls in the text, then turn it back on at the end.
+ if (hasInteractive) {
+ useInteractive = false;
+ }
+
+ req.exec(text);
+
+ if (hasInteractive) {
+ useInteractive = true;
+ }
+
+ //Support anonymous modules.
+ context.completeLoad(moduleName);
+ };
+
+ //No need to continue if the plugin value has already been
+ //defined by a build.
+ if (fullName in defined) {
+ load(defined[fullName]);
+ } else {
+ //Use parentName here since the plugin's name is not reliable,
+ //could be some weird string with no path that actually wants to
+ //reference the parentName's path.
+ plugin.load(name, makeRequire(map.parentMap, true, function (deps, cb) {
+ var moduleDeps = [],
+ i, dep, depMap;
+ //Convert deps to full names and hold on to them
+ //for reference later, when figuring out if they
+ //are blocked by a circular dependency.
+ for (i = 0; (dep = deps[i]); i++) {
+ depMap = makeModuleMap(dep, map.parentMap);
+ deps[i] = depMap.fullName;
+ if (!depMap.prefix) {
+ moduleDeps.push(deps[i]);
+ }
+ }
+ depManager.moduleDeps = (depManager.moduleDeps || []).concat(moduleDeps);
+ return context.require(deps, cb);
+ }), load, config);
+ }
+ }
+
+ /**
+ * Adds the manager to the waiting queue. Only fully
+ * resolved items should be in the waiting queue.
+ */
+ function addWait(manager) {
+ if (!waiting[manager.id]) {
+ waiting[manager.id] = manager;
+ waitAry.push(manager);
+ context.waitCount += 1;
+ }
+ }
+
+ /**
+ * Function added to every manager object. Created out here
+ * to avoid new function creation for each manager instance.
+ */
+ function managerAdd(cb) {
+ this.listeners.push(cb);
+ }
+
+ function getManager(map, shouldQueue) {
+ var fullName = map.fullName,
+ prefix = map.prefix,
+ plugin = prefix ? plugins[prefix] ||
+ (plugins[prefix] = defined[prefix]) : null,
+ manager, created, pluginManager, prefixMap;
+
+ if (fullName) {
+ manager = managerCallbacks[fullName];
+ }
+
+ if (!manager) {
+ created = true;
+ manager = {
+ //ID is just the full name, but if it is a plugin resource
+ //for a plugin that has not been loaded,
+ //then add an ID counter to it.
+ id: (prefix && !plugin ?
+ (managerCounter++) + '__p@:' : '') +
+ (fullName || '__r@' + (managerCounter++)),
+ map: map,
+ depCount: 0,
+ depDone: [],
+ depCallbacks: [],
+ deps: [],
+ listeners: [],
+ add: managerAdd
+ };
+
+ specified[manager.id] = true;
+
+ //Only track the manager/reuse it if this is a non-plugin
+ //resource. Also only track plugin resources once
+ //the plugin has been loaded, and so the fullName is the
+ //true normalized value.
+ if (fullName && (!prefix || plugins[prefix])) {
+ managerCallbacks[fullName] = manager;
+ }
+ }
+
+ //If there is a plugin needed, but it is not loaded,
+ //first load the plugin, then continue on.
+ if (prefix && !plugin) {
+ prefixMap = makeModuleMap(prefix);
+
+ //Clear out defined and urlFetched if the plugin was previously
+ //loaded/defined, but not as full module (as in a build
+ //situation). However, only do this work if the plugin is in
+ //defined but does not have a module export value.
+ if (prefix in defined && !defined[prefix]) {
+ delete defined[prefix];
+ delete urlFetched[prefixMap.url];
+ }
+
+ pluginManager = getManager(prefixMap, true);
+ pluginManager.add(function (plugin) {
+ //Create a new manager for the normalized
+ //resource ID and have it call this manager when
+ //done.
+ var newMap = makeModuleMap(map.originalName, map.parentMap),
+ normalizedManager = getManager(newMap, true);
+
+ //Indicate this manager is a placeholder for the real,
+ //normalized thing. Important for when trying to map
+ //modules and dependencies, for instance, in a build.
+ manager.placeholder = true;
+
+ normalizedManager.add(function (resource) {
+ manager.callback = function () {
+ return resource;
+ };
+ execManager(manager);
+ });
+ });
+ } else if (created && shouldQueue) {
+ //Indicate the resource is not loaded yet if it is to be
+ //queued.
+ loaded[manager.id] = false;
+ queueDependency(manager);
+ addWait(manager);
+ }
+
+ return manager;
+ }
+
+ function main(inName, depArray, callback, relModuleMap) {
+ var moduleMap = makeModuleMap(inName, relModuleMap),
+ name = moduleMap.name,
+ fullName = moduleMap.fullName,
+ manager = getManager(moduleMap),
+ id = manager.id,
+ deps = manager.deps,
+ i, depArg, depName, depPrefix, cjsMod;
+
+ if (fullName) {
+ //If module already defined for context, or already loaded,
+ //then leave. Also leave if jQuery is registering but it does
+ //not match the desired version number in the config.
+ if (fullName in defined || loaded[id] === true ||
+ (fullName === "jquery" && config.jQuery &&
+ config.jQuery !== callback().fn.jquery)) {
+ return;
+ }
+
+ //Set specified/loaded here for modules that are also loaded
+ //as part of a layer, where onScriptLoad is not fired
+ //for those cases. Do this after the inline define and
+ //dependency tracing is done.
+ specified[id] = true;
+ loaded[id] = true;
+
+ //If module is jQuery set up delaying its dom ready listeners.
+ if (fullName === "jquery" && callback) {
+ jQueryCheck(callback());
+ }
+ }
+
+ //Attach real depArray and callback to the manager. Do this
+ //only if the module has not been defined already, so do this after
+ //the fullName checks above. IE can call main() more than once
+ //for a module.
+ manager.depArray = depArray;
+ manager.callback = callback;
+
+ //Add the dependencies to the deps field, and register for callbacks
+ //on the dependencies.
+ for (i = 0; i < depArray.length; i++) {
+ depArg = depArray[i];
+ //There could be cases like in IE, where a trailing comma will
+ //introduce a null dependency, so only treat a real dependency
+ //value as a dependency.
+ if (depArg) {
+ //Split the dependency name into plugin and name parts
+ depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap));
+ depName = depArg.fullName;
+ depPrefix = depArg.prefix;
+
+ //Fix the name in depArray to be just the name, since
+ //that is how it will be called back later.
+ depArray[i] = depName;
+
+ //Fast path CommonJS standard dependencies.
+ if (depName === "require") {
+ deps[i] = makeRequire(moduleMap);
+ } else if (depName === "exports") {
+ //CommonJS module spec 1.1
+ deps[i] = defined[fullName] = {};
+ manager.usingExports = true;
+ } else if (depName === "module") {
+ //CommonJS module spec 1.1
+ manager.cjsModule = cjsMod = deps[i] = {
+ id: name,
+ uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined,
+ exports: defined[fullName]
+ };
+ } else if (depName in defined && !(depName in waiting) &&
+ (!(fullName in needFullExec) ||
+ (fullName in needFullExec && fullExec[depName]))) {
+ //Module already defined, and not in a build situation
+ //where the module is a something that needs full
+ //execution and this dependency has not been fully
+ //executed. See r.js's requirePatch.js for more info
+ //on fullExec.
+ deps[i] = defined[depName];
+ } else {
+ //Mark this dependency as needing full exec if
+ //the current module needs full exec.
+ if (fullName in needFullExec) {
+ needFullExec[depName] = true;
+ //Reset state so fully executed code will get
+ //picked up correctly.
+ delete defined[depName];
+ urlFetched[depArg.url] = false;
+ }
+
+ //Either a resource that is not loaded yet, or a plugin
+ //resource for either a plugin that has not
+ //loaded yet.
+ manager.depCount += 1;
+ manager.depCallbacks[i] = makeArgCallback(manager, i);
+ getManager(depArg, true).add(manager.depCallbacks[i]);
+ }
+ }
+ }
+
+ //Do not bother tracking the manager if it is all done.
+ if (!manager.depCount) {
+ //All done, execute!
+ execManager(manager);
+ } else {
+ addWait(manager);
+ }
+ }
+
+ /**
+ * Convenience method to call main for a define call that was put on
+ * hold in the defQueue.
+ */
+ function callDefMain(args) {
+ main.apply(null, args);
+ }
+
+ /**
+ * jQuery 1.4.3+ supports ways to hold off calling
+ * calling jQuery ready callbacks until all scripts are loaded. Be sure
+ * to track it if the capability exists.. Also, since jQuery 1.4.3 does
+ * not register as a module, need to do some global inference checking.
+ * Even if it does register as a module, not guaranteed to be the precise
+ * name of the global. If a jQuery is tracked for this context, then go
+ * ahead and register it as a module too, if not already in process.
+ */
+ jQueryCheck = function (jqCandidate) {
+ if (!context.jQuery) {
+ var $ = jqCandidate || (typeof jQuery !== "undefined" ? jQuery : null);
+
+ if ($) {
+ //If a specific version of jQuery is wanted, make sure to only
+ //use this jQuery if it matches.
+ if (config.jQuery && $.fn.jquery !== config.jQuery) {
+ return;
+ }
+
+ if ("holdReady" in $ || "readyWait" in $) {
+ context.jQuery = $;
+
+ //Manually create a "jquery" module entry if not one already
+ //or in process. Note this could trigger an attempt at
+ //a second jQuery registration, but does no harm since
+ //the first one wins, and it is the same value anyway.
+ callDefMain(["jquery", [], function () {
+ return jQuery;
+ }]);
+
+ //Ask jQuery to hold DOM ready callbacks.
+ if (context.scriptCount) {
+ jQueryHoldReady($, true);
+ context.jQueryIncremented = true;
+ }
+ }
+ }
+ }
+ };
+
+ function findCycle(manager, traced) {
+ var fullName = manager.map.fullName,
+ depArray = manager.depArray,
+ fullyLoaded = true,
+ i, depName, depManager, result;
+
+ if (manager.isDone || !fullName || !loaded[fullName]) {
+ return result;
+ }
+
+ //Found the cycle.
+ if (traced[fullName]) {
+ return manager;
+ }
+
+ traced[fullName] = true;
+
+ //Trace through the dependencies.
+ if (depArray) {
+ for (i = 0; i < depArray.length; i++) {
+ //Some array members may be null, like if a trailing comma
+ //IE, so do the explicit [i] access and check if it has a value.
+ depName = depArray[i];
+ if (!loaded[depName] && !reservedDependencies[depName]) {
+ fullyLoaded = false;
+ break;
+ }
+ depManager = waiting[depName];
+ if (depManager && !depManager.isDone && loaded[depName]) {
+ result = findCycle(depManager, traced);
+ if (result) {
+ break;
+ }
+ }
+ }
+ if (!fullyLoaded) {
+ //Discard the cycle that was found, since it cannot
+ //be forced yet. Also clear this module from traced.
+ result = undefined;
+ delete traced[fullName];
+ }
+ }
+
+ return result;
+ }
+
+ function forceExec(manager, traced) {
+ var fullName = manager.map.fullName,
+ depArray = manager.depArray,
+ i, depName, depManager, prefix, prefixManager, value;
+
+
+ if (manager.isDone || !fullName || !loaded[fullName]) {
+ return undefined;
+ }
+
+ if (fullName) {
+ if (traced[fullName]) {
+ return defined[fullName];
+ }
+
+ traced[fullName] = true;
+ }
+
+ //Trace through the dependencies.
+ if (depArray) {
+ for (i = 0; i < depArray.length; i++) {
+ //Some array members may be null, like if a trailing comma
+ //IE, so do the explicit [i] access and check if it has a value.
+ depName = depArray[i];
+ if (depName) {
+ //First, make sure if it is a plugin resource that the
+ //plugin is not blocked.
+ prefix = makeModuleMap(depName).prefix;
+ if (prefix && (prefixManager = waiting[prefix])) {
+ forceExec(prefixManager, traced);
+ }
+ depManager = waiting[depName];
+ if (depManager && !depManager.isDone && loaded[depName]) {
+ value = forceExec(depManager, traced);
+ manager.depCallbacks[i](value);
+ }
+ }
+ }
+ }
+
+ return defined[fullName];
+ }
+
+ /**
+ * Checks if all modules for a context are loaded, and if so, evaluates the
+ * new ones in right dependency order.
+ *
+ * @private
+ */
+ function checkLoaded() {
+ var waitInterval = config.waitSeconds * 1000,
+ //It is possible to disable the wait interval by using waitSeconds of 0.
+ expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
+ noLoads = "", hasLoadedProp = false, stillLoading = false,
+ cycleDeps = [],
+ i, prop, err, manager, cycleManager, moduleDeps;
+
+ //If there are items still in the paused queue processing wait.
+ //This is particularly important in the sync case where each paused
+ //item is processed right away but there may be more waiting.
+ if (context.pausedCount > 0) {
+ return undefined;
+ }
+
+ //Determine if priority loading is done. If so clear the priority. If
+ //not, then do not check
+ if (config.priorityWait) {
+ if (isPriorityDone()) {
+ //Call resume, since it could have
+ //some waiting dependencies to trace.
+ resume();
+ } else {
+ return undefined;
+ }
+ }
+
+ //See if anything is still in flight.
+ for (prop in loaded) {
+ if (!(prop in empty)) {
+ hasLoadedProp = true;
+ if (!loaded[prop]) {
+ if (expired) {
+ noLoads += prop + " ";
+ } else {
+ stillLoading = true;
+ if (prop.indexOf('!') === -1) {
+ //No reason to keep looking for unfinished
+ //loading. If the only stillLoading is a
+ //plugin resource though, keep going,
+ //because it may be that a plugin resource
+ //is waiting on a non-plugin cycle.
+ cycleDeps = [];
+ break;
+ } else {
+ moduleDeps = managerCallbacks[prop] && managerCallbacks[prop].moduleDeps;
+ if (moduleDeps) {
+ cycleDeps.push.apply(cycleDeps, moduleDeps);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //Check for exit conditions.
+ if (!hasLoadedProp && !context.waitCount) {
+ //If the loaded object had no items, then the rest of
+ //the work below does not need to be done.
+ return undefined;
+ }
+ if (expired && noLoads) {
+ //If wait time expired, throw error of unloaded modules.
+ err = makeError("timeout", "Load timeout for modules: " + noLoads);
+ err.requireType = "timeout";
+ err.requireModules = noLoads;
+ err.contextName = context.contextName;
+ return req.onError(err);
+ }
+
+ //If still loading but a plugin is waiting on a regular module cycle
+ //break the cycle.
+ if (stillLoading && cycleDeps.length) {
+ for (i = 0; (manager = waiting[cycleDeps[i]]); i++) {
+ if ((cycleManager = findCycle(manager, {}))) {
+ forceExec(cycleManager, {});
+ break;
+ }
+ }
+
+ }
+
+ //If still waiting on loads, and the waiting load is something
+ //other than a plugin resource, or there are still outstanding
+ //scripts, then just try back later.
+ if (!expired && (stillLoading || context.scriptCount)) {
+ //Something is still waiting to load. Wait for it, but only
+ //if a timeout is not already in effect.
+ if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
+ checkLoadedTimeoutId = setTimeout(function () {
+ checkLoadedTimeoutId = 0;
+ checkLoaded();
+ }, 50);
+ }
+ return undefined;
+ }
+
+ //If still have items in the waiting cue, but all modules have
+ //been loaded, then it means there are some circular dependencies
+ //that need to be broken.
+ //However, as a waiting thing is fired, then it can add items to
+ //the waiting cue, and those items should not be fired yet, so
+ //make sure to redo the checkLoaded call after breaking a single
+ //cycle, if nothing else loaded then this logic will pick it up
+ //again.
+ if (context.waitCount) {
+ //Cycle through the waitAry, and call items in sequence.
+ for (i = 0; (manager = waitAry[i]); i++) {
+ forceExec(manager, {});
+ }
+
+ //If anything got placed in the paused queue, run it down.
+ if (context.paused.length) {
+ resume();
+ }
+
+ //Only allow this recursion to a certain depth. Only
+ //triggered by errors in calling a module in which its
+ //modules waiting on it cannot finish loading, or some circular
+ //dependencies that then may add more dependencies.
+ //The value of 5 is a bit arbitrary. Hopefully just one extra
+ //pass, or two for the case of circular dependencies generating
+ //more work that gets resolved in the sync node case.
+ if (checkLoadedDepth < 5) {
+ checkLoadedDepth += 1;
+ checkLoaded();
+ }
+ }
+
+ checkLoadedDepth = 0;
+
+ //Check for DOM ready, and nothing is waiting across contexts.
+ req.checkReadyState();
+
+ return undefined;
+ }
+
+ /**
+ * Resumes tracing of dependencies and then checks if everything is loaded.
+ */
+ resume = function () {
+ var manager, map, url, i, p, args, fullName;
+
+ //Any defined modules in the global queue, intake them now.
+ context.takeGlobalQueue();
+
+ resumeDepth += 1;
+
+ if (context.scriptCount <= 0) {
+ //Synchronous envs will push the number below zero with the
+ //decrement above, be sure to set it back to zero for good measure.
+ //require() calls that also do not end up loading scripts could
+ //push the number negative too.
+ context.scriptCount = 0;
+ }
+
+ //Make sure any remaining defQueue items get properly processed.
+ while (defQueue.length) {
+ args = defQueue.shift();
+ if (args[0] === null) {
+ return req.onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
+ } else {
+ callDefMain(args);
+ }
+ }
+
+ //Skip the resume of paused dependencies
+ //if current context is in priority wait.
+ if (!config.priorityWait || isPriorityDone()) {
+ while (context.paused.length) {
+ p = context.paused;
+ context.pausedCount += p.length;
+ //Reset paused list
+ context.paused = [];
+
+ for (i = 0; (manager = p[i]); i++) {
+ map = manager.map;
+ url = map.url;
+ fullName = map.fullName;
+
+ //If the manager is for a plugin managed resource,
+ //ask the plugin to load it now.
+ if (map.prefix) {
+ callPlugin(map.prefix, manager);
+ } else {
+ //Regular dependency.
+ if (!urlFetched[url] && !loaded[fullName]) {
+ req.load(context, fullName, url);
+
+ //Mark the URL as fetched, but only if it is
+ //not an empty: URL, used by the optimizer.
+ //In that case we need to be sure to call
+ //load() for each module that is mapped to
+ //empty: so that dependencies are satisfied
+ //correctly.
+ if (url.indexOf('empty:') !== 0) {
+ urlFetched[url] = true;
+ }
+ }
+ }
+ }
+
+ //Move the start time for timeout forward.
+ context.startTime = (new Date()).getTime();
+ context.pausedCount -= p.length;
+ }
+ }
+
+ //Only check if loaded when resume depth is 1. It is likely that
+ //it is only greater than 1 in sync environments where a factory
+ //function also then calls the callback-style require. In those
+ //cases, the checkLoaded should not occur until the resume
+ //depth is back at the top level.
+ if (resumeDepth === 1) {
+ checkLoaded();
+ }
+
+ resumeDepth -= 1;
+
+ return undefined;
+ };
+
+ //Define the context object. Many of these fields are on here
+ //just to make debugging easier.
+ context = {
+ contextName: contextName,
+ config: config,
+ defQueue: defQueue,
+ waiting: waiting,
+ waitCount: 0,
+ specified: specified,
+ loaded: loaded,
+ urlMap: urlMap,
+ urlFetched: urlFetched,
+ scriptCount: 0,
+ defined: defined,
+ paused: [],
+ pausedCount: 0,
+ plugins: plugins,
+ needFullExec: needFullExec,
+ fake: {},
+ fullExec: fullExec,
+ managerCallbacks: managerCallbacks,
+ makeModuleMap: makeModuleMap,
+ normalize: normalize,
+ /**
+ * Set a configuration for the context.
+ * @param {Object} cfg config object to integrate.
+ */
+ configure: function (cfg) {
+ var paths, prop, packages, pkgs, packagePaths, requireWait;
+
+ //Make sure the baseUrl ends in a slash.
+ if (cfg.baseUrl) {
+ if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== "/") {
+ cfg.baseUrl += "/";
+ }
+ }
+
+ //Save off the paths and packages since they require special processing,
+ //they are additive.
+ paths = config.paths;
+ packages = config.packages;
+ pkgs = config.pkgs;
+
+ //Mix in the config values, favoring the new values over
+ //existing ones in context.config.
+ mixin(config, cfg, true);
+
+ //Adjust paths if necessary.
+ if (cfg.paths) {
+ for (prop in cfg.paths) {
+ if (!(prop in empty)) {
+ paths[prop] = cfg.paths[prop];
+ }
+ }
+ config.paths = paths;
+ }
+
+ packagePaths = cfg.packagePaths;
+ if (packagePaths || cfg.packages) {
+ //Convert packagePaths into a packages config.
+ if (packagePaths) {
+ for (prop in packagePaths) {
+ if (!(prop in empty)) {
+ configurePackageDir(pkgs, packagePaths[prop], prop);
+ }
+ }
+ }
+
+ //Adjust packages if necessary.
+ if (cfg.packages) {
+ configurePackageDir(pkgs, cfg.packages);
+ }
+
+ //Done with modifications, assing packages back to context config
+ config.pkgs = pkgs;
+ }
+
+ //If priority loading is in effect, trigger the loads now
+ if (cfg.priority) {
+ //Hold on to requireWait value, and reset it after done
+ requireWait = context.requireWait;
+
+ //Allow tracing some require calls to allow the fetching
+ //of the priority config.
+ context.requireWait = false;
+ //But first, call resume to register any defined modules that may
+ //be in a data-main built file before the priority config
+ //call.
+ resume();
+
+ context.require(cfg.priority);
+
+ //Trigger a resume right away, for the case when
+ //the script with the priority load is done as part
+ //of a data-main call. In that case the normal resume
+ //call will not happen because the scriptCount will be
+ //at 1, since the script for data-main is being processed.
+ resume();
+
+ //Restore previous state.
+ context.requireWait = requireWait;
+ config.priorityWait = cfg.priority;
+ }
+
+ //If a deps array or a config callback is specified, then call
+ //require with those args. This is useful when require is defined as a
+ //config object before require.js is loaded.
+ if (cfg.deps || cfg.callback) {
+ context.require(cfg.deps || [], cfg.callback);
+ }
+ },
+
+ requireDefined: function (moduleName, relModuleMap) {
+ return makeModuleMap(moduleName, relModuleMap).fullName in defined;
+ },
+
+ requireSpecified: function (moduleName, relModuleMap) {
+ return makeModuleMap(moduleName, relModuleMap).fullName in specified;
+ },
+
+ require: function (deps, callback, relModuleMap) {
+ var moduleName, fullName, moduleMap;
+ if (typeof deps === "string") {
+ if (isFunction(callback)) {
+ //Invalid call
+ return req.onError(makeError("requireargs", "Invalid require call"));
+ }
+
+ //Synchronous access to one module. If require.get is
+ //available (as in the Node adapter), prefer that.
+ //In this case deps is the moduleName and callback is
+ //the relModuleMap
+ if (req.get) {
+ return req.get(context, deps, callback);
+ }
+
+ //Just return the module wanted. In this scenario, the
+ //second arg (if passed) is just the relModuleMap.
+ moduleName = deps;
+ relModuleMap = callback;
+
+ //Normalize module name, if it contains . or ..
+ moduleMap = makeModuleMap(moduleName, relModuleMap);
+ fullName = moduleMap.fullName;
+
+ if (!(fullName in defined)) {
+ return req.onError(makeError("notloaded", "Module name '" +
+ moduleMap.fullName +
+ "' has not been loaded yet for context: " +
+ contextName));
+ }
+ return defined[fullName];
+ }
+
+ //Call main but only if there are dependencies or
+ //a callback to call.
+ if (deps && deps.length || callback) {
+ main(null, deps, callback, relModuleMap);
+ }
+
+ //If the require call does not trigger anything new to load,
+ //then resume the dependency processing.
+ if (!context.requireWait) {
+ while (!context.scriptCount && context.paused.length) {
+ resume();
+ }
+ }
+ return context.require;
+ },
+
+ /**
+ * Internal method to transfer globalQueue items to this context's
+ * defQueue.
+ */
+ takeGlobalQueue: function () {
+ //Push all the globalDefQueue items into the context's defQueue
+ if (globalDefQueue.length) {
+ //Array splice in the values since the context code has a
+ //local var ref to defQueue, so cannot just reassign the one
+ //on context.
+ apsp.apply(context.defQueue,
+ [context.defQueue.length - 1, 0].concat(globalDefQueue));
+ globalDefQueue = [];
+ }
+ },
+
+ /**
+ * Internal method used by environment adapters to complete a load event.
+ * A load event could be a script load or just a load pass from a synchronous
+ * load call.
+ * @param {String} moduleName the name of the module to potentially complete.
+ */
+ completeLoad: function (moduleName) {
+ var args;
+
+ context.takeGlobalQueue();
+
+ while (defQueue.length) {
+ args = defQueue.shift();
+
+ if (args[0] === null) {
+ args[0] = moduleName;
+ break;
+ } else if (args[0] === moduleName) {
+ //Found matching define call for this script!
+ break;
+ } else {
+ //Some other named define call, most likely the result
+ //of a build layer that included many define calls.
+ callDefMain(args);
+ args = null;
+ }
+ }
+ if (args) {
+ callDefMain(args);
+ } else {
+ //A script that does not call define(), so just simulate
+ //the call for it. Special exception for jQuery dynamic load.
+ callDefMain([moduleName, [],
+ moduleName === "jquery" && typeof jQuery !== "undefined" ?
+ function () {
+ return jQuery;
+ } : null]);
+ }
+
+ //Doing this scriptCount decrement branching because sync envs
+ //need to decrement after resume, otherwise it looks like
+ //loading is complete after the first dependency is fetched.
+ //For browsers, it works fine to decrement after, but it means
+ //the checkLoaded setTimeout 50 ms cost is taken. To avoid
+ //that cost, decrement beforehand.
+ if (req.isAsync) {
+ context.scriptCount -= 1;
+ }
+ resume();
+ if (!req.isAsync) {
+ context.scriptCount -= 1;
+ }
+ },
+
+ /**
+ * Converts a module name + .extension into an URL path.
+ * *Requires* the use of a module name. It does not support using
+ * plain URLs like nameToUrl.
+ */
+ toUrl: function (moduleNamePlusExt, relModuleMap) {
+ var index = moduleNamePlusExt.lastIndexOf("."),
+ ext = null;
+
+ if (index !== -1) {
+ ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
+ moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
+ }
+
+ return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
+ },
+
+ /**
+ * Converts a module name to a file path. Supports cases where
+ * moduleName may actually be just an URL.
+ */
+ nameToUrl: function (moduleName, ext, relModuleMap) {
+ var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
+ config = context.config;
+
+ //Normalize module name if have a base relative module name to work from.
+ moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName);
+
+ //If a colon is in the URL, it indicates a protocol is used and it is just
+ //an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
+ //The slash is important for protocol-less URLs as well as full paths.
+ if (req.jsExtRegExp.test(moduleName)) {
+ //Just a plain path, not module name lookup, so just return it.
+ //Add extension if it is included. This is a bit wonky, only non-.js things pass
+ //an extension, this method probably needs to be reworked.
+ url = moduleName + (ext ? ext : "");
+ } else {
+ //A module that needs to be converted to a path.
+ paths = config.paths;
+ pkgs = config.pkgs;
+
+ syms = moduleName.split("/");
+ //For each module name segment, see if there is a path
+ //registered for it. Start with most specific name
+ //and work up from it.
+ for (i = syms.length; i > 0; i--) {
+ parentModule = syms.slice(0, i).join("/");
+ if (paths[parentModule]) {
+ syms.splice(0, i, paths[parentModule]);
+ break;
+ } else if ((pkg = pkgs[parentModule])) {
+ //If module name is just the package name, then looking
+ //for the main module.
+ if (moduleName === pkg.name) {
+ pkgPath = pkg.location + '/' + pkg.main;
+ } else {
+ pkgPath = pkg.location;
+ }
+ syms.splice(0, i, pkgPath);
+ break;
+ }
+ }
+
+ //Join the path parts together, then figure out if baseUrl is needed.
+ url = syms.join("/") + (ext || ".js");
+ url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url;
+ }
+
+ return config.urlArgs ? url +
+ ((url.indexOf('?') === -1 ? '?' : '&') +
+ config.urlArgs) : url;
+ }
+ };
+
+ //Make these visible on the context so can be called at the very
+ //end of the file to bootstrap
+ context.jQueryCheck = jQueryCheck;
+ context.resume = resume;
+
+ return context;
+ }
+
+ /**
+ * Main entry point.
+ *
+ * If the only argument to require is a string, then the module that
+ * is represented by that string is fetched for the appropriate context.
+ *
+ * If the first argument is an array, then it will be treated as an array
+ * of dependency string names to fetch. An optional function callback can
+ * be specified to execute when all of those dependencies are available.
+ *
+ * Make a local req variable to help Caja compliance (it assumes things
+ * on a require that are not standardized), and to give a short
+ * name for minification/local scope use.
+ */
+ req = requirejs = function (deps, callback) {
+
+ //Find the right context, use default
+ var contextName = defContextName,
+ context, config;
+
+ // Determine if have config object in the call.
+ if (!isArray(deps) && typeof deps !== "string") {
+ // deps is a config object
+ config = deps;
+ if (isArray(callback)) {
+ // Adjust args if there are dependencies
+ deps = callback;
+ callback = arguments[2];
+ } else {
+ deps = [];