diff --git a/zim.js b/zim.js index 9823518..451d720 100644 --- a/zim.js +++ b/zim.js @@ -359,6 +359,7 @@ call the pd.immediate(baseValue) method with your desired baseValue (not targetV METHODS convert(input) - converts a base value to a target value immediate(input) - immediately sets the target value (no damping) +dispose() - clears interval PROPERTIES damp - can adjust this dynamically (usually just pass it in as a parameter to start) @@ -413,8 +414,7 @@ damp - can adjust this dynamically (usually just pass it in as a parameter to st desiredAmount = targetAmount; differenceAmount = desiredAmount - lastAmount; - lastAmount += differenceAmount*that.damp; - if (targetRound) {lastAmount = Math.round(lastAmount);} + lastAmount += differenceAmount*that.damp; } this.immediate = function(n) { @@ -425,8 +425,12 @@ damp - can adjust this dynamically (usually just pass it in as a parameter to st } this.convert = function(n) { - baseAmount = n; - return lastAmount; + baseAmount = n; + if (targetRound) { + return Math.round(lastAmount); + } else { + return lastAmount; + } } this.dispose = function() { @@ -436,23 +440,64 @@ damp - can adjust this dynamically (usually just pass it in as a parameter to st // DOM CODE + +/*-- +zim.scrollX = function(num, time) +num and time are optional +if not provided, this gets how many pixels from the left the browser window has been scrolled +if only num is provided it scrolls the window to this x position +if num and time are provided it animates the window to the x position in time milliseconds +--*/ + zim.scrollX = function(num, time) { + return zim.abstractScroll("X", "Left", num, time); + } + /*-- -zim.scrollY = function() -how many pixels down from the top the browser window has been scrolled +zim.scrollY = function(num, time) +num and time are optional +if not provided, this gets how many pixels from the top the browser window has been scrolled +if only num is provided it scrolls the window to this y position +if num and time are provided it animates the window to the y position in time milliseconds --*/ - zim.scrollY = function() { - var safari = 0; - var browser=navigator.appName; - var navindex=navigator.userAgent.indexOf('Safari'); - if (navindex != -1 || browser=='Safari') { - var safari = 1; - } - if (!safari && document.compatMode == 'CSS1Compat') { - return document.documentElement.scrollTop; + zim.scrollY = function(num, time) { + return zim.abstractScroll("Y", "Top", num, time); + } + + zim.abstractScroll = function(dir, side, num, time) { + var perpend = (dir == "X") ? "Y" : "X"; // perpendicular direction + if (zot(num)) { + var safari = 0; + var browser=navigator.appName; + var navindex=navigator.userAgent.indexOf('Safari'); + if (navindex != -1 || browser=='Safari') { + var safari = 1; + } + if (!safari && document.compatMode == 'CSS1Compat') { + return document.documentElement["scroll"+side]; + } else { + return document.body["scroll"+side]; + } + } else if (zot(time)) { + window.scrollTo(zim["scroll"+perpend](), num); } else { - return document.body.scrollTop; - } + var interval = 50; + if (time < interval) time = interval; + var steps = time/interval; + var current = zim["scroll"+dir](); + var amount = num - current; + var diff = amount/steps; + var count = 0; + var scrollInterval = setInterval(function() { + count++; + current+=diff; + window.scrollTo(zim["scroll"+perpend](), current); + if (count >= steps) { + window.scrollTo(zim["scroll"+perpend](), num); + clearInterval(scrollInterval); + } + }, interval); + } } /*-- @@ -1086,12 +1131,22 @@ will not be resized - really just to use while building and then comment it out } /*-- -zim.centerReg = function(obj) +zim.centerReg = function(obj, container) centers the registration point on the bounds - obj must have bounds set +if container is specified then sets obj x and y to half the width and height of container just a convenience function - returns obj for chaining --*/ - zim.centerReg = function(obj) { - if (zot(obj) || !obj.getBounds) {zog("zim create - centerReg(): please provide object with bounds set"); return;} + zim.centerReg = function(obj, container) { + if (zot(obj) || !obj.getBounds) {zog("zim create - centerReg(): please provide object with bounds set"); return;} + if (!zot(container)) { + if (!container.getBounds) { + zog("zim create - centerReg(): please provide context with bounds set"); + return; + } else { + obj.x = container.getBounds().width/2; + obj.y = container.getBounds().height/2; + } + } var oB = obj.getBounds(); obj.regX = oB.width/2; obj.regY = oB.height/2; @@ -1379,7 +1434,6 @@ if you nest things inside and want to drag them, will want to set to true // find last angle var angle3 = 180 - angle1 - angle2; - // the next line is b the angle will be relative to the length of c // if c is the longest, then the angle is angle1 // if c is the second longest, then the angle is angle2, etc. @@ -2619,40 +2673,62 @@ dispatches a "change" event when changed by pressing an arrow or a keyboard arro /*-- -zim.Parallax = function(stage, damp, layers) +zim.Parallax = function(stage, damp, layers, auto) Parallax Class -takes objects and moves them with a parallax effect based on mouse movement +takes objects as layers and sets properties based on an input +for instance, each layer could move a different x based on position of mouseX +or each layer could scale a different amount based on scroll of y +The types of input are mouseX, mouseY, scrollX, scrollY +The types of properties to change could be x, y, scaleX, scaleY, rotation, alpha, frameNumber, etc. +Parallax allows scale to be a property which scales scaleX and scaleY together +Parallax allows frame to be a property and calls gotoAndStop() on a Sprite frame +Parallax really just manages multiple ProportionDamp objects for proper parallax, the objects closer move more than the objects farther back make a new object: p = new zim.Parallax(parameters) PARAMETERS -pass in the stage from your code (uses stage.mouseX and stage.mouseY) +pass in a reference to the stage as the first parameter pass in the damping value (.1 default) -pass in an array of layer objects in the following format -[[obj, distanceX, distanceY], [obj2, distanceX, distanceY], etc.] -or you can add these one at a time with the p.addLayer(obj, distanceX, distanceY); method -you must pass in a layer object - the distanceX and distanceY can be 0 for no motion on that axis -the distance is the total distance you want the layer object to travel -relative to the cursor position between 0 and stage width or height -the Parallax class will apply half the distance on either side of the object's start point -should work through nested clips... +pass in an array of layer objects in the following format: + +[{obj:obj, prop:"x", propChange:100, input:"mouseX", inMin:100, inMax:300, factor:1, integer:false}, etc.] + +the first three properties are required +object is the object whose property is being changed +prop is the property that is being changed +propChange is how much you want the property to change + +input defaults to mouseX but can also be mouseY, scrollX, scrollY +the inMin defaults to 0, inMax to stageW (for x prop) stageH (for y prop) +the factor defaults to 1 which means change is in same direction +set factor to -1 to change in the opposite direction +integer rounds the value to an integer +note, if frame is the property, the gotoAndStop() accepts decimals + +or you can add these one at a time with the p.addLayer({layer object properties}); +the auto parameter defaults to true and uses the specified input +if auto is set to false, you must make your own Ticker and use the step(input) method METHODS -addLayer(obj, distanceX, distanceY) - to alternately add layers after the object is made +addLayer({layer object properties}) - adds a layer +removeLayer(index) - removes a layer based on order added +step(input) - used when auto is false to send in custom input data +immediate([]) - immediately sets the target value for each layer object (no damping) dispose() - removes listeners PROPERTIES damp - allows you to dynamically change the damping --*/ - zim.Parallax = function(stage, damp, layers) { + zim.Parallax = function(stage, damp, layers, auto) { if (zon) zog("zim build - Parallax"); if (zot(stage) || !stage.getBounds) {zog("zim build - Parallax(): please pass in the stage with bounds as first parameter"); return;} - if (!stage.getBounds()) {zog("zim build - Pane(): Please give the stage bounds using setBounds()"); return;} - + if (!stage.getBounds()) {zog("zim build - Parallax(): Please give the stage bounds using setBounds()"); return;} + if (zot(auto)) {auto = true;} + var stageW = stage.getBounds().width; var stageH = stage.getBounds().height; @@ -2660,35 +2736,60 @@ damp - allows you to dynamically change the damping // public properties this.damp = (zot(damp)) ? .1 : damp; - //this.x = (zot(damp)) ? stageW/2 : x; - //this.y = (zot(damp)) ? stageH/2 : y; // public methods (do not get hoisted so define early) // addLayer works as a public method // and also is called from the object in case we add layers via the Parallax object parameters - // the function prepares ProportionDamp objects for both x and y + // the function prepares ProportionDamp objects for two values // and stores them on the layer object - // and also stores the desired distances on the layer objects themselves + // and also stores the desired amounts on the layer objects themselves // finally, the layer object is added to the myLayers private property // the timer then loops through these layers and handles things from there - this.addLayer = function(obj, distanceX, distanceY) { - if (zot(obj)) return; - obj.zimX = zot(distanceX)?0:distanceX; - obj.zimY = zot(distanceY)?0:distanceY; - if (obj.zimX != 0) { - obj.zimpX = new zim.ProportionDamp(0, stageW, 0, obj.zimX, that.damp); - } - if (obj.zimY != 0) { - obj.zimpY = new zim.ProportionDamp(0, stageH, 0, obj.zimY, that.damp); + // obj, distanceX, distanceY, minX, minY, maxX, maxY, factor, targetRound + this.addLayer = function(layer) { + //{obj, prop, propChange, input, inMin, inMax, factor, integer} + if (zot(layer.obj) || zot(layer.prop) || zot(layer.propChange)) return; + var obj = {obj:layer.obj, prop:layer.prop}; + obj[obj.prop] = layer.propChange; + if (zot(layer.input)) layer.input = "mouseX"; + obj.input = layer.input; + + var inMin = (zot(layer.inMin)) ? 0 : layer.inMin; + var inMax = (zot(layer.inMax)) ? stageW : layer.inMax; + var factor = (zot(layer.factor)) ? 1 : layer.factor; + var integer = (zot(layer.integer)) ? false : layer.integer; + + // baseMin, baseMax, targetMin, targetMax, damp, factor, targetRound + obj["p_"+obj.prop] = new zim.ProportionDamp(inMin, inMax, 0, obj[obj.prop], that.damp, factor, integer); + if (obj.prop == "scale") { + obj["s_"+obj.prop] = obj.obj.scaleX; // helper to allow scale to be property + } else if (obj.prop == "frame") { + obj["s_"+obj.prop] = obj.obj.currentFrame; + } else { + obj["s_"+obj.prop] = obj.obj[obj.prop]; // obj.s_x = obj.obj.x for example } - obj.zimsX = obj.x; - obj.zimsY = obj.y; - myLayers.push(obj); + myLayers.push(obj); + return myLayers.length-1; } + this.removeLayer = function(index) { + if (zot(index)) return; + var layer = myLayers[index]; + layer["p_"+layer.prop].dispose(); + myLayers.splice(index,1); + } + + this.immediate = function(array) { + var o; + for (var i=0; i=32&&e.keyCode<=40&&e.preventDefault()},t=function(e){e||(e=event),e.preventDefault()},o=t;return window.addEventListener("keydown",e),window.addEventListener("mousewheel",t),window.addEventListener("DOMMouseScroll",o),[e,t,o]}"undefined"==typeof zon&&(zon=!1);var zog=console.log.bind(console);zon&&zog("ZIM WRAP - zog zid zss zgo zum zot zop zil");var zim=function(e){return zon&&zog("ZIM CODE Module"),e.shuffle=function(e){if(!zot(e)){var t,o,n=e.length;if(0==n)return e;for(;--n;)t=Math.floor(Math.random()*(n+1)),o=e[n],e[n]=e[t],e[t]=o;return e}},e.rand=function(e,t,o){zot(o)&&(o=!0),zot(t)&&(t=0),zot(e)&&(e=0),o&&(e>t?e++:t>e&&t++);var n;return 0==e&&0==t?Math.random():(n=0==t?Math.random()*e:Math.min(e,t)+Math.random()*(Math.max(e,t)-Math.min(e,t)),o?Math.floor(n):n)},e.copy=function(t){if(null==t||"object"!=typeof t)return t;if(t instanceof Array)return t.slice(0);if(t instanceof Object){copy={};for(var o in t)t.hasOwnProperty(o)&&(copy[o]=e.copy(t[o]));return copy}},e.arraysEqual=function(t,o,n){if(zot(t)||zot(o))return!1;if(zot(n)&&(n=!0),t.length!=o.length)return!1;for(var i=0;i0?o+(n-o)*s:n-(n-o)*s,a&&(d=Math.round(d)),d)}},e.ProportionDamp=function(e,t,o,n,i,a,r){function s(){isNaN(d)||(d=Math.max(d,e),d=Math.min(d,t),h=(d-e)/(t-e),l=n-o,c=a>0?o+l*h:n-l*h,p=c,u=p-f,f+=u*g.damp,r&&(f=Math.round(f)))}zon&&zog("zim code - ProportionDamp"),zot(o)&&(o=0),zot(n)&&(n=1),zot(i)&&(i=.1),zot(a)&&(a=1),zot(r)&&(r=!1),this.damp=i;var d,h,l,c,u,g=this,p=0,f=0;d=e,f=o;var m=setInterval(s,20);this.immediate=function(e){g.convert(e),s(),f=c,r&&(f=Math.round(f))},this.convert=function(e){return d=e,f},this.dispose=function(){clearInterval(m)}},e.scrollY=function(){var e=0,t=navigator.appName,o=navigator.userAgent.indexOf("Safari");if(-1!=o||"Safari"==t)var e=1;return e||"CSS1Compat"!=document.compatMode?document.body.scrollTop:document.documentElement.scrollTop},e.windowWidth=function(){return isNaN(window.innerWidth)?window.clientWidth:window.innerWidth},e.windowHeight=function(){return isNaN(window.innerHeight)?window.clientHeight:window.innerHeight},e.urlEncode=function(e){var e=(e+"").toString();return encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},e.urlDecode=function(e){return decodeURIComponent((e+"").replace(/\+/g,"%20"))},e.setCookie=function(e,t,o){if(o){var n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3);var i="; expires="+n.toGMTString()}else var i="";document.cookie=e+"="+escape(t)+i+"; path=/"},e.getCookie=function(e){var t,o=document.cookie.split(/;\s*/),n=new Array;for(i=0;ia;a++)n=t.getChildAt(a),n.zimNoSwipe=e.zimNoSwipe,n instanceof createjs.Container&&o(n)}!zot(e)&&e.on&&(e.zimNoSwipe=t?null:!0,e instanceof createjs.Container&&o(e))},e.hitTestPoint=function(e,t,o){if(!zot(e)&&e.globalToLocal){var n=e.globalToLocal(t,o);return e.hitTest(n.x,n.y)}},e.hitTestReg=function(e,t){if(!zot(e)&&!zot(t)&&e.localToLocal&&t.localToLocal){var o=t.localToLocal(t.regX,t.regY,e);return e.hitTest(o.x,o.y)}},e.hitTestRect=function(e,t,o){if(!zot(e)&&!zot(t)&&e.hitTest&&t.getBounds){zot(o)&&(o=0);var n=t.getBounds();if(!n)return void zog("zim create - hitTestRect():\n please setBounds() on param b object");for(var i,a,r,s=0;o>=s;s++){if(i=n.width*(s+1)/(o+1),a=n.height*(s+1)/(o+1),r=t.localToLocal(n.x+i,n.y,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x+n.width,n.y+a,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x+n.width-i,n.y+n.height,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x,n.y+n.height-a,e),e.hitTest(r.x,r.y))return!0}}},e.hitTestCircle=function(e,t,o){if(!zot(e)&&!zot(t)&&e.hitTest&&t.getBounds){zot(o)&&(o=8);var n=t.getBounds();if(!n)return void zog("zim create - hitTestCircle():\n please setBounds() on param b object");for(var i,a,r,s,d=n.x+n.width/2,h=n.y+n.height/2,l=(n.width+n.height)/2/2,c=0;o>c;c++)if(i=c/o*2*Math.PI,a=d+l*Math.cos(i),r=h+l*Math.sin(i),s=t.localToLocal(a,r,e),e.hitTest(s.x,s.y))return!0}},e.hitTestBounds=function(t,o,n){function i(e,t){return e.x>=t.x+t.width||e.x+e.width<=t.x||e.y>=t.y+t.height||e.y+e.height<=t.y?!1:!0}if(!zot(t)&&!zot(o)&&t.getBounds&&o.getBounds){var a=!1;n&&n.graphics&&(a=!0);var r=t.getBounds(),s=o.getBounds();if(!r||!s)return void zog("zim create - hitTestBounds():\n please setBounds() on both objects");var d=e.boundsToGlobal(t),h=e.boundsToGlobal(o);if(a){var l=n.graphics;l.clear(),l.setStrokeStyle(1).beginStroke("blue"),l.drawRect(d.x,d.y,d.width,d.height),l.beginStroke("green"),l.drawRect(h.x,h.y,h.width,h.height),n.getStage().update()}return i(d,h)}},e.boundsToGlobal=function(e,t){if(!zot(e)&&e.getBounds){var o=e.getBounds();if(!o&&zot(t))return void zog("zim create - boundsToGlobal():\n please setBounds() on object (or a rectangle)");t&&(o=t);var n=e.localToGlobal(o.x,o.y),i=e.localToGlobal(o.x+o.width,o.y),a=e.localToGlobal(o.x+o.width,o.y+o.height),r=e.localToGlobal(o.x,o.y+o.height),s=Math.min(n.x,i.x,a.x,r.x),d=Math.min(n.y,i.y,a.y,r.y),h=Math.max(n.x,i.x,a.x,r.x),l=Math.max(n.y,i.y,a.y,r.y);return new createjs.Rectangle(s,d,h-s,l-d)}},e.scale=function(e,t){return!zot(e)&&e.scaleX?(zot(t)&&(t=1),e.scaleX=e.scaleY=t,e):void 0},e.scaleTo=function(t,o,n,i,a){if(zot(t)||!t.getBounds||!t.getBounds())return void zog("zim create - scaleTo(): please provide an object (with setBounds) to scale");if(zot(o)||!o.getBounds||!o.getBounds())return void zog("zim create - scaleTo(): please provide a boundObject (with setBounds) to scale to");if(zot(n)&&(n=-1),zot(i)&&(i=-1),-1==n&&-1==i)return t;zot(a)&&(a="smallest");var r=o.getBounds().width*n/100,s=o.getBounds().height*i/100;if((-1==n||-1==i)&&"both"!=a&&"stretch"!=a)return-1==n?e.scale(t,s/t.getBounds().height):e.scale(t,r/t.getBounds().width),t;if("both"==a||"stretch"==a)return t.scaleX=-1!=n?r/t.getBounds().width:t.scaleX,t.scaleY=-1!=i?s/t.getBounds().height:t.scaleY,t;if("biggest"==a||"largest"==a||"outside"==a)var d=Math.max(r/t.getBounds().width,s/t.getBounds().height);else var d=Math.min(r/t.getBounds().width,s/t.getBounds().height);return e.scale(t,d),t},e.move=function(t,o,n,i,a,r,s,d,h,l){return e.animate(t,{x:o,y:n},i,a,r,s,d,h,l)},e.animate=function(e,t,o,n,i,a,r,s,d){function h(){i&&"function"==typeof i&&i(a),createjs.Ticker.off("tick",l)}if(!zot(e)&&e.on&&!zot(t)&&e.getStage()){zot(n)&&(n="quadInOut"),zot(r)&&(r=0),zot(s)&&(s={override:!0}),zot(d)&&(d=60),createjs.Tween.get(e,s).wait(r).to(t,o,createjs.Ease[n]).call(h);var l=createjs.Ticker.on("tick",e.getStage());return createjs.Ticker.setFPS(d),e}},e.fit=function(e,t,o,n,i,a){if(!zot(e)&&e.getBounds){if(!e.getBounds())return void zog("zim create - fit(): please setBounds() on object");if(zot(t)){if(!e.getStage())return void zog("zim create - fit(): please add boundary dimensions or add obj to stage first");if(!e.getStage().getBounds())return void zog("zim create - fit(): please add boundary dimensions or add obj with bounds to stage first");var r=e.getStage().getBounds().width,s=e.getStage().getBounds().height;t=0,o=0,n=r,i=s}zot(a)&&(a=!0),e.scaleX=e.scaleY=1;var d,h=n,l=i,c=e.getBounds().width,u=e.getBounds().height;d=a?h/l>=c/u?l/u:h/c:h/l>=c/u?h/c:l/u,e.scaleX=e.scaleY=d;var g=c*d,p=u*d;return e.x=t+(h-g)/2,e.y=o+(l-p)/2,{x:e.x,y:e.y,width:g,height:p,scale:d,bX:t,bY:o,bWidth:n,bHeight:i}}},e.outline=function(e,t,o){if(zot(e)||!e.getBounds)return void zog("zim create - outline(): please provide object and shape");if(!e.getBounds())return void zog("zim create - outline(): please setBounds() on object");if(!e.parent)return void zog("zim create - outline(): object should be on stage first");zot(t)&&(t="brown"),zot(o)&&(o=2);var n=e.getBounds(),i=new createjs.Shape,a=e.parent,r=e.localToLocal(n.x,n.y,a),s=e.localToLocal(n.x+n.width,n.y,a),d=e.localToLocal(n.x+n.width,n.y+n.height,a),h=(e.localToLocal(n.x,n.y+n.height,a),i.graphics);h.s(t).ss(o).r(r.x,r.y,s.x-r.x,d.y-s.y),zero={x:r.x-n.x*e.scaleX,y:r.y-n.y*e.scaleY};var l=10,c=l+1;return h.s("white").ss(o+2),h.mt(zero.x-c,zero.y+0).lt(zero.x+c,zero.y+0),h.mt(zero.x+0,zero.y-c).lt(zero.x+0,zero.y+c),h.s(t).ss(o),h.mt(zero.x-l,zero.y+0).lt(zero.x+l,zero.y+0),h.mt(zero.x+0,zero.y-l).lt(zero.x+0,zero.y+l),h.s("white").ss(o+2).dc(e.x,e.y,l+6),h.s(t).ss(o).dc(e.x,e.y,l+6),e.parent.addChild(i),e.getStage()&&e.getStage().update(),e},e.centerReg=function(e){if(zot(e)||!e.getBounds)return void zog("zim create - centerReg(): please provide object with bounds set");var t=e.getBounds();return e.regX=t.width/2,e.regY=t.height/2,e},e}(zim||{}),zim=function(e){return zon&&zog("ZIM BUILD Module"),e.Circle=function(t,o,n,i){function a(){zot(t)&&(t=50),zot(o)&&(o="black");var a=this;this.mouseChildren=!1;var r=this.shape=new createjs.Shape;this.addChild(r);var s=r.graphics,d=s.beginFill(o).command;if(!zot(n)){var h=s.beginStroke(n).command;zot(i)&&(i=1);var l=s.setStrokeStyle(i).command}s.dc(0,0,t),this.width=2*t,this.height=2*t,this.setBounds(-t,-t,this.width,this.height),this.setFill=function(e){zot(e)||(o=e,d.style=o)},Object.defineProperty(a,"color",{get:function(){return o},set:function(e){a.setFill(e)}}),this.setStroke=function(e){h&&!zot(e)&&(n=e,h.style=n)},this.setStrokeSize=function(e){l&&!zot(e)&&(i=e,l.width=i)},this.clone=function(){return new e.Circle(t,o,n,i)}}return a.prototype=new createjs.Container,a.prototype.constructor=e.Circle,new a},e.Rectangle=function(t,o,n,i,a,r){function s(){zot(t)&&(t=100),zot(o)&&(o=100),zot(n)&&(n="black"),zot(r)&&(r=0);var s=this;this.mouseChildren=!1;var d=this.shape=new createjs.Shape;this.addChild(d);var h=d.graphics,l=h.beginFill(n).command;if(!zot(i)){var c=h.beginStroke(i).command;zot(a)&&(a=1);var u=h.setStrokeStyle(a).command}r>0?h.rr(0,0,t,o,r):h.r(0,0,t,o),this.width=t,this.height=o,this.setBounds(0,0,this.width,this.height),this.setFill=function(e){zot(e)||(n=e,l.style=n)},Object.defineProperty(s,"color",{get:function(){return n},set:function(e){s.setFill(e)}}),this.setStroke=function(e){c&&!zot(e)&&(i=e,c.style=i)},this.setStrokeSize=function(e){u&&!zot(e)&&(a=e,u.width=a)},this.clone=function(){return new e.Rectangle(t,o,n,i,a,r)}}return s.prototype=new createjs.Container,s.prototype.constructor=e.Rectangle,new s},e.Triangle=function(t,o,n,i,a,r,s,d){function h(){zot(t)&&(t=100),zot(o)&&(o=t),zot(n)&&(n=t),-1==n&&(n=Math.sqrt(Math.pow(t,2)+Math.pow(o,2))),zot(i)&&(i="black"),zot(s)&&(s=!0),zot(d)&&(d=0),this.mouseChildren=!1;var h=this,l=[t,o,n];if(l.sort(function(e,t){return t-e}),aa=l[0],bb=l[1],cc=l[2],aa>bb+cc)return void zog("zim build - Triangle(): invalid triangle lengths");var c=this.shape=new createjs.Shape;this.addChild(c);var u=c.graphics,g=u.beginFill(i).command;if(!zot(a)){var p=u.beginStroke(a).command;zot(r)&&(r=1);var f=u.setStrokeStyle(r).command}u.mt(0,0),u.lt(t,0);var m,v=180*Math.acos((Math.pow(bb,2)+Math.pow(cc,2)-Math.pow(aa,2))/(2*bb*cc))/Math.PI,z=180*Math.asin(bb*Math.sin(v*Math.PI/180)/aa)/Math.PI,w=180-v-z;m=n==aa?v:n==bb?z:w;var y=Math.cos(m*Math.PI/180)*o,b=Math.sin(m*Math.PI/180)*o;this.width=Math.max(t,t-y),this.height=b,this.setBounds(0,0,this.width,this.height),c.y=this.height,u.lt(t-y,0-b),u.cp(),s&&(this.regX=this.width/2,this.regY=this.height/2+d),this.setFill=function(e){zot(e)||(i=e,g.style=i)},Object.defineProperty(h,"color",{get:function(){return i},set:function(e){h.setFill(e)}}),this.setStroke=function(e){p&&!zot(e)&&(a=e,p.style=a)},this.setStrokeSize=function(e){f&&!zot(e)&&(r=e,f.width=r)},this.clone=function(){return new e.Triangle(t,o,n,i,a,r,s,d)}}return h.prototype=new createjs.Container,h.prototype.constructor=e.Triangle,new h},e.Label=function(t,o,n,i,a,r,s){function d(){zot(t)&&(t="LABEL"),""==t&&(t=" "),zot(o)&&(o=36),zot(n)&&(n="arial"),zot(i)&&(i="black"),zot(a)&&(a=i),zot(r)&&(r=null),zot(s)&&(s=16);var d=this;this.mouseChildren=!1;var h=this.label=new createjs.Text(String(t),o+"px "+n,i);h.textBaseline="alphabetic",h.textAlign="left",r&&s>0&&(h.shadow=new createjs.Shadow(r,3,3,s)),this.addChild(h);var l=new createjs.Shape;l.graphics.f("rgba(0,255,255,.01)").r(0,0,this.getBounds().width,this.getBounds().height),this.hitArea=l,this.width=this.getBounds().width,this.height=this.getBounds().height,this.setBounds(0,0,this.width,this.height),h.y=o-o/6,Object.defineProperty(d,"text",{get:function(){var e=" "==h.text?"":h.text;return e},set:function(e){0==e&&(e=" "),h.text=e,d.setBounds(0,0,h.getBounds().width,h.getBounds().height)}}),this.showRollColor=function(e){zot(e)&&(e=!0),h.color=e?a:i,d.getStage()&&d.getStage().update()},this.on("mouseover",function(){d.showRollColor()}),this.on("mouseout",function(){d.showRollColor(!1)}),this.clone=function(){return new e.Label(d.text,o,n,i,a,r,s)},this.dispose=function(){d.removeAllEventListeners()}}return d.prototype=new createjs.Container,d.prototype.constructor=e.Label,new d},e.Button=function(t,o,n,i,a,r,s,d,h,l){function c(){function c(){g.on("mouseout",u);var e=p.graphics;e.clear(),e.f(a),r&&e.s(r).ss(s),e.rr(0,0,t,o,d),g.label.showRollColor(),g.getStage()&&g.getStage().update()}function u(){g.off("mouseout",u);var e=p.graphics;e.clear(),e.f(i),r&&e.s(r).ss(s),e.rr(0,0,t,o,d),g.label.showRollColor(!1),g.getStage()&&g.getStage().update()}zot(t)&&(t=200),zot(o)&&(o=60),zot(i)&&(i="#C60"),zot(a)&&(a="#F93"),zot(r)&&(r=null),zot(s)&&(s=1),zot(d)&&(d=20),zot(h)&&(h="rgba(0,0,0,.3)"),zot(l)&&(l=16),zot(n)&&(n="PRESS"),("string"==typeof n||"number"==typeof n)&&(n=new e.Label(n,36,"arial","white"));var g=this;this.mouseChildren=!1,this.cursor="pointer";var p=new createjs.Shape,f=p.graphics;f.f(i),r&&f.s(r).ss(s),f.rr(0,0,t,o,d),this.addChild(p),this.backing=p,l>0&&(p.shadow=new createjs.Shadow(h,3,3,l)),this.setBounds(0,0,t,o),this.width=t,this.height=o,n.x=(t-n.getBounds().width)/2+1,n.y=(o-n.getBounds().height)/2+2,this.addChild(n),this.label=n,Object.defineProperty(g,"text",{get:function(){var e=" "==n.text?"":n.text;return e},set:function(e){n.text=e,n.x=(t-n.getBounds().width)/2+1,n.y=(o-n.getBounds().height)/2+2}}),this.on("mouseover",c),this.dispose=function(){g.removeAllEventListeners(),g.removeChild(p),g.removeChild(buttonLabel),p=null,buttonLabel=null}}return c.prototype=new createjs.Container,c.prototype.constructor=e.Button,new c},e.CheckBox=function(t,o,n,i,a){function r(){function r(){s=!s,d.setChecked(s),d.dispatchEvent("change")}zot(t)&&(t=60),zot(o)&&(o=null),("string"==typeof o||"number"==typeof o)&&(o=new e.Label(o,5*t/6,"arial",i));var s=zot(n)?!1:n;zot(i)&&(i="black"),zot(a)&&(a=10),this.setBounds(-a,-a,t+2*a,t+2*a);var d=this;this.cursor="pointer";var h=new createjs.Shape,l=h.graphics;l.f("rgba(255,255,255,.5)").r(0,0,t,t),l.s(i).ss(t/10).r(t/7,t/7,t-t/7*2,t-t/7*2),this.addChild(h);var c=t;o&&(this.addChild(o),o.x=1.3*t,o.y=t/8,this.label=o,c=o.x+o.width);var u=new createjs.Shape;l=u.graphics,l.f("rgba(0,0,0,.01)").r(this.getBounds().x,this.getBounds().y,c+2*a,this.getBounds().height),this.hitArea=u;var g=new createjs.Shape,p=g.graphics;p.f(i).p("AnQAdICBiaIEEDZIF8nfICfB4In/KPg");var f=95;g.setBounds(-f/2,-f/2,f,f);var m=t/(f+66);g.scaleX=g.scaleY=m,g.x=t/2,g.y=t/2,s&&this.addChild(g),this.on("click",r),Object.defineProperty(d,"checked",{get:function(){return s},set:function(e){d.setChecked(e)}}),this.setChecked=function(e){zot(e)&&(e=!0),s=e,s?d.addChild(g):d.removeChild(g),d.getStage()&&d.getStage().update()},this.dispose=function(){d.removeAllEventListeners()}}return r.prototype=new createjs.Container,r.prototype.constructor=e.CheckBox,new r},e.RadioButtons=function(t,o,n,i,a,r){function s(){function s(e){l.setSelected(u.getChildIndex(e.target)),l.dispatchEvent("change")}function d(){for(var r,s=!1,d=o.length-1;d>=0;d--)r=o[d],r.selected&&r.selected===!0&&(s?r.selected="false":s=!0);u.removeAllChildren();for(var g,p=0,d=0;d=0){t=u.getChildAt(e);var n=-2;c&&(n=c.index),c=t.obj}-1==e||n==c.index?(c=null,l.id=null,l.label=null,l.text=""):(t.addChild(t.check),l.id=c.id,l.label=c.label,l.label&&(l.text=l.label.text)),l.getStage()&&l.getStage().update()}},Object.defineProperty(l,"selected",{get:function(){return c},set:function(e){selectedIndex=e}}),Object.defineProperty(l,"selectedIndex",{get:function(){return c?c.index:-1},set:function(e){this.setSelected(e)}}),this.dispose=function(){l.removeAllEventListeners()}}}return s.prototype=new createjs.Container,s.prototype.constructor=e.RadioButtons,new s},e.Pane=function(t,o,n,i,a,r,s,d,h,l,c,u,g){function p(){function p(e,i){return e=Math.max(o/2,Math.min(t.getBounds().width-o/2,e)),i=Math.max(n/2,Math.min(t.getBounds().height-n/2,i)),{x:e,y:i}}if(zot(t)||!t.getBounds)return void zog("zim build - Pane(): Please pass in a reference to a container with bounds set as first parameter");if(!t.getBounds())return void zog("zim build - Pane(): Please give the container bounds using setBounds()");if(zot(t.getStage))return void zog("zim build - Pane(): Please give the container that has a stage property");zot(o)&&(o=200),zot(n)&&(n=200),zot(i)&&(i=null),("string"==typeof i||"number"==typeof i)&&(i=new e.Label(i,40,"arial","black")),zot(a)&&(a="white"),zot(r)&&(r=!1),zot(s)&&(s=!1),zot(d)&&(d=!0),zot(h)&&(h=20),zot(l)&&(l=.14),zot(c)&&(c="#333"),zot(u)&&(u=20),zot(g)&&(g=!0);var f=this.backing=new createjs.Shape,m=f.graphics;m.beginFill("black"),m.drawRect(-5e3,-5e3,1e4,1e4),this.setBounds(-o/2,-n/2,o,n),f.alpha=l;var v=this;f.on("click",function(e){v.hide(),v.dispatchEvent("close"),e.stopImmediatePropagation()}),f.on("mousedown",function(e){e.stopImmediatePropagation()}),d&&this.addChild(f);var z=this.display=new createjs.Shape;if(z.setBounds(0,0,o,n),z.regX=o/2,z.regY=n/2,m=z.graphics,m.beginFill(a),m.drawRoundRect(0,0,o,n,h),u>0&&(z.shadow=new createjs.Shadow(c,8,8,u)),z.on("click",function(e){e.stopImmediatePropagation()}),this.resetX,this.resetY,r){z.cursor="pointer";var w,y;z.on("mousedown",function(e){isNaN(v.resetX)&&(v.resetX=v.x),isNaN(v.resetY)&&(v.resetY=v.y),w=e.stageX-v.x,y=e.stageY-v.y,z.cursor="move"}),z.on("pressmove",function(e){var o=p(e.stageX-w,e.stageY-y);v.x=o.x,v.y=o.y,t.getStage().update()}),this.on("pressup",function(){z.cursor="pointer"})}this.addChild(z),i&&(g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2),this.addChild(i),this.label=i,this.text=i.text),Object.defineProperty(v,"text",{get:function(){var e=" "==i.text?"":i.text;return e},set:function(e){i.text=e,g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2)}}),this.hide=function(){t.removeChild(v),t.getStage().update(),s&&(isNaN(v.resetX)||(v.x=v.resetX),isNaN(v.resetY)||(v.y=v.resetY))},this.show=function(){v.x=t.getBounds().width/2,v.y=t.getBounds().height/2,g&&i&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2),t.addChild(v),t.getStage().update()},this.dispose=function(){z.removeAllEventListeners(),v.removeChild(z),z=null}}return p.prototype=new createjs.Container,p.prototype.constructor=e.Pane,new p},e.Waiter=function(t,o,n,i,a,r,s){function d(){if(zot(t)||!t.getBounds)return void zog("zim build - Waiter(): Please pass in a reference to a container with bounds set as first parameter");if(!t.getBounds())return void zog("zim build - Waiter(): Please give the container bounds using setBounds()");if(zot(t.getStage))return void zog("zim build - Waiter(): Please give the container that has a stage property");zot(o)&&(o=600),zot(n)&&(n="orange"),zot(i)&&(i="white"),zot(a)&&(a=16),zot(r)&&(r="#444"),zot(s)&&(s=14);var e=40,d=3,h=.6*e/2,l=(e-2*h)/2,c=d*(2*h+l)+l;this.setBounds(-c/2,-e/2,c,e);var u=this,g=this.display=new createjs.Shape;this.addChild(g),g.setBounds(0,0,c,e),g.regX=c/2,g.regY=e/2;var p=g.graphics;p.beginFill(n),p.drawRoundRect(0,0,c,e,a),s>0&&(g.shadow=new createjs.Shadow(r,3,3,s)),g.on("click",function(e){e.stopImmediatePropagation()});var f=new createjs.Container;this.addChild(f);for(var m,v=0;d>v;v++)m=new createjs.Shape,m.graphics.f(i).dc(0,0,h),m.x=(v-(d-1)/2)*(2*h+l),f.addChild(m),m.cache(-h,-h,2*h,2*h),m.alpha=0;t.getStage().update(),this.hide=function(){createjs.Tween.get(u,{override:!0}).to({alpha:0},300).call(function(){createjs.Ticker.off("tick",u.ticker),t.removeChild(u),t.getStage().update()})},this.show=function(){for(var e,n=0,i=0;it.length-1&&(o=0),0>o&&(o=t.length-1);else{if(o>t.length-1)return;if(0>o)return}g(o)}function g(e){p=e,a.text=t[p],a.x=b.x+(b.getBounds().width-a.getBounds().width)/2,a.y=b.y+(b.getBounds().height-a.getBounds().height)/2,z.alpha=1,y.setFill(n),z.cursor="pointer",x.alpha=1,B.setFill(n),x.cursor="pointer",c||(0==p&&(z.alpha=.8,y.setFill("#aaa"),z.cursor="default"),p==t.length-1&&(x.alpha=.8,B.setFill("#aaa"),x.cursor="default")),a.getStage()&&a.getStage().update(),f.dispatchEvent("change")}zot(t)&&(t=[1,2,3,4,5,6,7,8,9,10]),zot(o)&&(o=200),zot(n)&&(n="white"),zot(i)&&(i=null),zot(a)&&(a=""),("string"==typeof a||"number"==typeof a)&&(a=new e.Label(a,64,"arial","#555")),zot(r)&&(r=!1),zot(s)&&(s=!0),zot(d)&&(d=16),zot(h)&&(h="rgba(0,0,0,.3)"),zot(l)&&(l=14),zot(c)&&(c=!1);var p,f=this,m=100,v=m/4,z=this.arrowPrev=new createjs.Container;this.addChild(z);var w=new createjs.Shape;w.graphics.f("rgba(255,255,255,.11)").r(0,0,1.5*m,1.5*m),w.regX=1.5*m/2,w.regY=1.5*m/2+v/2,z.hitArea=w;var y=new e.Triangle(m,.8*m,.8*m,n);l>0&&(z.shadow=new createjs.Shadow(h,3,3,l)),z.addChild(y),z.cursor="pointer",z.on("click",function(){u(-1)}),r?(z.rotation=0,z.x=o/2,z.y=z.getBounds().height/2):(z.rotation=-90,z.x=z.getBounds().height/2,z.y=z.getBounds().width/2);var b=this.textBox=new createjs.Shape;this.addChild(b),b.setBounds(0,0,o,m),null!=i&&b.graphics.s(i).ss(1.5),b.graphics.f(n).rr(0,0,o,m,d),l>0&&(b.shadow=new createjs.Shadow(h,3,3,l)),r?b.y=y.height+v:b.x=y.height+v,this.addChild(a),t.length>0&&(p=0,a.text=t[p]),a.x=b.x+(b.getBounds().width-a.getBounds().width)/2,a.y=b.y+(b.getBounds().height-a.getBounds().height)/2;var x=this.arrowNext=new createjs.Container;this.addChild(x);var C=new createjs.Shape;C.graphics.f("rgba(255,255,255,.01)").r(0,0,1.5*m,1.5*m),C.regX=1.5*m/2,C.regY=1.5*m/2+v/2,x.hitArea=C;var B=new e.Triangle(m,.8*m,.8*m,n);l>0&&(x.shadow=new createjs.Shadow(h,3,3,l)),x.addChild(B),x.cursor="pointer",x.on("click",function(){u(1)}),r?(x.rotation=180,x.x=o/2,x.y=b.y+b.getBounds().height+x.getBounds().height/2+v):(x.rotation=90,x.x=b.x+b.getBounds().width+x.getBounds().height/2+v,x.y=x.getBounds().width/2),g(p),Object.defineProperty(this,"currentIndex",{get:function(){return p},set:function(e){p=Math.min(t.length-1,Math.max(0,e)),g(p)}}),Object.defineProperty(this,"currentValue",{get:function(){return t[p]},set:function(e){t.indexOf(e)>-1&&(p=t.indexOf(e)),g(p)}}),Object.defineProperty(this,"loop",{get:function(){return c},set:function(e){c=e,g(p)}}),Object.defineProperty(this,"stepperArray",{get:function(){return t},set:function(e){t=e}}),s&&(this.keyDownEvent=function(e){if(e||(e=event),e.keyCode>=37&&e.keyCode<=40){var o;if(38==e.keyCode||39==e.keyCode?o=p+1:(37==e.keyCode||40==e.keyCode)&&(o=p-1),o>t.length-1)return;if(0>o)return;g(o)}},window.addEventListener("keydown",this.keyDownEvent)),this.next=function(){u(1)},this.prev=function(){u(-1)},this.dispose=function(){f.removeAllEventListeners()}}return u.prototype=new createjs.Container,u.prototype.constructor=e.Stepper,new u},e.Parallax=function(t,o,n){function i(){for(var e,o,n,i,a=0;a0?t.x<0&&e.xd&&t.x>e.x?t.x=e.x-e.getBounds().width+s.gapFix:e.x>d&&e.x>t.x&&(e.x=t.x-t.getBounds().width+s.gapFix)):(e.y-=s.speed*s.direction,t.y-=s.speed*s.direction,s.direction*s.speed>0?t.y<0&&e.yh&&t.y>e.y?t.y=e.y-e.getBounds().height+s.gapFix:e.y>h&&e.y>t.y&&(e.y=t.y-t.getBounds().height+s.gapFix)),e.getStage().update())}}if(zon&&zog("zim build - Scroller"),!zot(e)&&e.getBounds&&!zot(t)&&t.getBounds){zot(i)&&(i=!0);var s=this;if(this.speed=zot(o)?1:o,this.direction=zot(n)?1:n,this.gapFix=zot(a)?0:a,!e.getBounds()||!t.getBounds())return void zog("zim build - Scroller(): please setBounds() on backing objects");if(!e.getStage())return void zog("zim build - Scroller(): please add backing objects to stage to start");var d,h;i?t.x=e.getBounds().width:t.y=e.getBounds().height;var l=createjs.Ticker.on("tick",r);createjs.Ticker.setFPS(60),this.dispose=function(){zon&&zog("bye from Scroller"),createjs.Ticker.off("tick",l)}}},e}(zim||{}),zim=function(e){return zon&&zog("ZIM PAGES Module"),e.Swipe=function(t,o,n){function i(){if(zot(t)||!t.on)return void zog("zim pages - Swipe():\nPlease pass in object");zot(o)&&(o=30),zot(n)&&(n=80),this.distance=o,this.duration=n,this.active=!0;var e,i,a,r,s,d,h=this;t.on("mousedown",function(o){function n(){var t=!1;Math.abs(a-e)>Math.abs(r-i)?(a-e>h.distance&&(h.direction="right",h.dispatchEvent("swipe"),t=!0),e-a>h.distance&&(h.direction="left",h.dispatchEvent("swipe"),t=!0)):(r-i>h.distance&&(h.direction="down",h.dispatchEvent("swipe"),t=!0),i-r>h.distance&&(h.direction="up",h.dispatchEvent("swipe"),t=!0)),t||(h.direction="none",h.dispatchEvent("swipe"))}h.active&&!o.target.zimNoSwipe&&(h.obj=o.target,a=e=o.stageX,r=i=o.stageY,s=!0,h.dispatchEvent("swipedown"),clearTimeout(d),d=setTimeout(function(){s&&(n(),s=!1)},h.duration),t.on("pressmove",function(e){a=e.stageX,r=e.stageY}),t.on("pressup",function(){s&&(n(),s=!1,clearTimeout(d))}))}),this.disable=function(){h.active=!1 -},this.enable=function(){h.active=!0}}return i.prototype=new createjs.EventDispatcher,i.prototype.constructor=e.Swipe,new i},e.Pages=function(t,o,n,i,a){function r(){function r(){s=new createjs.Shape,s.graphics.f("black").r(0,0,l,c+1),d=new createjs.Shape,d.graphics.f("white").r(0,0,l,c+1)}if(zot(t)||!t.getBounds||!t.getBounds())return void zog("zim pages - Pages():\nobject must have bounds set");zot(o)&&(o=[]),zot(n)&&(n="none"),zot(i)&&(i=200),zot(a)&&(a=[]),this.transitionTable=a,this.speed=i,this.active=!0;var s,d,h=this,l=t.getBounds().width,c=t.getBounds().height,u=this.page=o[0]?o[0].page:null;("none"!=n||a!=[])&&r();for(var g,p,f=["left","right","up","down"],m=0;m0&&setTimeout(function(){h.settle()},e)},this.settle=function(){h.removeAllChildren(),h.addChild(u),h.dispatchEvent("puffed")},this.disable=function(){h.active=!1},this.enable=function(){h.active=!0},this.dispose=function(){h.swipe.off("swipe",w),h.removeAllChildren(),o=null}}return r.prototype=new createjs.Container,r.prototype.constructor=e.Pages,new r},e.HotSpots=function(t,o,n){function i(){function i(t){var i=null;if(!Array.isArray(t.rect)){if(i=t.rect,!i)return void zog("zim pages - HotSpots(): HotSpot "+t.page+" "+t.rect+" button does not exist");if(!i.getBounds())return void zog("zim pages - HotSpots(): HotSpots button needs bounds");t.rect=[i.x,i.y,i.getBounds().width,i.getBounds().height]}s=new e.HotSpot(t.page,t.rect[0],t.rect[1],t.rect[2],t.rect[3],t.call,o),s.zimHSpage=t.page,s.button=i,d.push(s),s.on("click",a),i&&(s.spot.mouseEnabled=!1,s.spot.mouseChildren=!1,i.zimHScall=t.call,i.zimHSEvent=i.on("click",a),n||(i.zimHSMDEvent=i.on("mousedown",function(e){e.stopImmediatePropagation()})),i.cursor="pointer")}function a(e){"function"==typeof e.currentTarget.zimHScall&&e.currentTarget.zimHScall()}if(zot(t)||!Array.isArray(t))return void zog("zim pages - HotSpots():\nplease provide an array of HotSpot data");zot(o)&&(o=!0),zot(n)&&(n=!1);for(var r,s,d=[],h=0;h=0;i--)r=t[i],s=d[i],n&&!Array.isArray(n)&&(n=[n.x,n.y,n.getBounds().width,n.getBounds().height]),(zot(o)&&zot(n)||zot(n)&&o==r.page||zot(o)&&e.arraysEqual(n,r.rect)||o==r.page&&e.arraysEqual(n,r.rect))&&(t.splice(i,1),s.button&&(s.button.off("click",s.button.zimHSEvent),s.button.zimHSEvent=null),s.off("click",a),s.dispose(),d.splice(i,1))},this.dispose=function(){for(var e=0;er;r++)i.mt(r*x/20,0).lt(r*x/20,C);for(var r=1;20>r;r++)i.mt(0,r*C/20).lt(x,r*C/20);e.alpha=.3,i=a.graphics,i.s(o).ss(1);for(var r=1;10>r;r++)i.mt(r*x/10,0).lt(r*x/10,C);for(var r=1;10>r;r++)i.mt(0,r*C/10).lt(x,r*C/10)}else{for(var r=0;x/g>r;r++)i.mt(r*g,0).lt(r*g,C);for(var r=0;C/g>r;r++)i.mt(0,r*g).lt(x,r*g);e.alpha=.3,i=a.graphics,i.s(o).ss(1);for(var r=0;x/(10*g)>r;r++)i.mt(10*r*g,0).lt(10*r*g,C);for(var r=0;C/(10*g)>r;r++)i.mt(0,10*r*g).lt(x,10*r*g)}var s=80;i.s("#FFFFFF").ss(8),i.mt(x/2,C/2-s/2).lt(x/2,C/2+s/2),i.mt(x/2-s/2,C/2).lt(x/2+s/2,C/2),i.s("#000000").ss(4),i.mt(x/2,C/2-s/2).lt(x/2,C/2+s/2),i.mt(x/2-s/2,C/2).lt(x/2+s/2,C/2),i.s(o).ss(3),i.dr(0,0,x,C),a.alpha=.5,B.cache(0,0,x,C),u.addChild(m),u.addChild(v),l.update()}function h(e){e||(e=event),l&&(String.fromCharCode(e.keyCode)==i.toUpperCase()&&(u.visible=!u.visible,l.off("stagemousemove",c),u.visible&&(c=l.on("stagemousemove",s,u)),l.update()),String.fromCharCode(e.keyCode)==a.toUpperCase()&&(u.removeChild(B),B=null,u.pixels=!u.pixels))}if(zot(t)&&(t="stage"),zot(o)&&(o="black"),!("stage"==t||t.getBounds&&t.getBounds()))return void zog("zim pages - Grid(): Please provide bounds for the obj (setBounds())");zot(n)&&(n=!0),zot(i)&&(i="G"),zot(a)&&(a="P");var l,c,u=this,g=10;this.mouseChildren=!1,this.mouseEnabled=!1;var p=80,f=26,m=e("#dddddd",o,"#333333");m.shape.regX=p/2,m.shape.regY=-f/4,m.label.y=3*f/4;var v=e("#dddddd",o,"#333333");v.shape.regX=-p/6,v.shape.regY=f/2,v.label.x=p/2+p/6;var z,w,y=p/6+p/2,b=2*f;m.x=y,v.y=b,m.label.text="x:0",v.label.text="y:0";var x,C,B,S=setInterval(function(){"stage"==t?u&&u.getStage()&&r():t&&t.getStage()&&r()},100),j=!1,M={x:0,y:0};Object.defineProperty(this,"pixels",{get:function(){return!n},set:function(e){n=!e,u.resize()}}),window.addEventListener("keydown",h),this.resize=function(){return u?(u.removeChild(B),B=null,l&&(d(),s(),setTimeout(function(){u.removeChild(B),B=null,d()},200)),!0):!1},this.dispose=function(){clearInterval(S),u.removeAllChildren(),window.removeEventListener("keydown",h),u.parent&&u.parent.removeChild(u),u=null}}return r.prototype=new createjs.Container,r.prototype.constructor=e.Grid,new r},e.GridManager=function(){e.Manager.call(this,"GridManager")},e.GridManager.prototype=new e.Manager,e.GridManager.prototype.constructor=e.GridManager,e.Layout=function(t,o,n,i,a,r,s,d){function h(){function h(){for(var e=0,t=0;t100)return void zog("zim pages - Layout(): cannot fit regions into 100% bounds");var B=100-f;h(),this.resize=function(){if(g.active){c=s.getBounds(),t.setBounds(0,0,c.width,c.height),u.graphics.clear(),""!=i&&u.graphics.f(i).r(0,0,c.width,c.height);for(var d=0;d0&&0==p.maxGiven&&(x=p.object.getBounds()[v],C=p.object.getBounds()[z],S=p.given*c[v]/100,j=p[y]*c[z]/100,M=C/x*S,M>j?(k=!0,p.maxGiven=x/C*j*100/c[v],b+=p.given-p.maxGiven,T-=p.maxGiven):l=!1);if(!k)break;if(l)break;totalPrimaries=0;for(var d=0;d0?p.maxGiven0&&p.given0?p.maxGiven0&&p.given100?void zog("zim build - Layout(): cannot fit regions into 100% bounds"):(B=100-f,h(),void g.resize())}for(var L=!0,E=0,A=0,d=0;d0?A+=p[v]:p.maxGiven>0?A+=p.maxGiven:p.given>0&&(A+=p.given),0==p[v]&&(L=!1);if(L||l){E+=n;var X=100-A-E;if(E-=n+o[0][w],0!=X&&0!=E)for(var d=0;d0?p.marginGiven*c[v]/100:p[w]*c[v]/100,x=p[v]>0?p[v]:p.maxGiven>0?p.maxGiven:p.given>0?p.given:0,x=x*c[v]/100,C=p[y]*c[z]/100,O=(c[z]-C)/2,Y=a?e.fit(p.object,O,I,C,x):e.fit(p.object,I,O,x,C),"top"==p.valign?p.object.y=Y.bY:"bottom"==p.valign&&(p.object.y=Y.bY+Y.bHeight-Y.height),"left"==p.align?p.object.x=Y.bX:"right"==p.align&&(p.object.x=Y.bX+Y.bWidth-Y.width),r&&r.graphics&&(H.s("white").ss(2).r(Y.bX,Y.bY,Y.bWidth,Y.bHeight),H.s("#ff8203").ss(2).drawDashedRect(Y.bX,Y.bY,Y.bWidth,Y.bHeight,20)),F=G=0,(0==I||I+x==c[v])&&(a?F=1:G=1),C==c[z]&&(a?G=1:F=1),""!=p.backgroundColor&&u.graphics.f(p.backgroundColor).r(Y.bX,Y.bY,Y.bWidth+G,Y.bHeight+F),I+=x}},this.resize(),r&&t.addChild(r),t.addChildAt(u,0),window.addEventListener("keydown",l),this.disable=function(){g.active=!1,window.removeEventListener("keydown",l),r&&(r.alpha=0)},this.enable=function(){g.active=!0,window.addEventListener("keydown",l),g.resize(),r&&(r.alpha=1)},this.removeShape=function(){r&&(r.graphics.clear(),t.removeChild(r),r=null,r=!1),window.removeEventListener("keydown",l)},this.addShape=function(e){g.removeShape(),r=e,window.addEventListener("keydown",l),t.addChild(r),g.resize()},this.dispose=function(){g.removeShape()}}return h.prototype=new createjs.EventDispatcher,h.prototype.constructor=e.Layout,new h},e.LayoutManager=function(){zon&&zog("zim pages - LayoutManager");var e=this;this.items=[],this.add=function(t){e.items.push(t)},this.resize=function(){for(var t=0;tr?"horizontal":"vertical",g!=p&&(p=g,m.dispatchEvent("orientation")),i){if("fit"==t)a/r>=v/z?(n=r,o=n*v/z):(o=a,n=o*z/v);else if("outside"==t)document.body.style.overflow="hidden",a/r>=v/z?(o=a,n=o*z/v):(n=r,o=n*v/z);else if("full"==t)return document.body.style.overflow="hidden",i.style.left=i.style.top="0px",v=a,z=r,f&&f.setBounds(0,0,v,z),void h();i.style.width=o+"px",i.style.height=n+"px",i.style.left=(a-o)/2+"px",i.style.top=(r-n)/2+"px"}}function c(){var e=document.createElement("canvas");e.setAttribute("id","myCanvas"),u=Math.max(window.innerWidth,screen.width,window.innerHeight,screen.height),"full"==t?(e.setAttribute("width",u),e.setAttribute("height",u)):(e.setAttribute("width",v),e.setAttribute("height",z)),document.body.appendChild(e)}zot(t)&&(t="full"),zot(o)&&(o=500),zot(n)&&(n=500),zot(i)&&(i=!0),zot(a)&&(a=!0),zot(r)&&(r=!0);var u,g,p,f,m=this,v=o,z=n,w=!1;window.addEventListener("load",s),"none"!=t&&window.addEventListener("resize",l),Object.defineProperty(m,"stage",{get:function(){return f},set:function(){zog("zim.Frame(): stage is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(m,"stageW",{get:function(){return v},set:function(){zog("zim.Frame(): stageW is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(m,"stageH",{get:function(){return z},set:function(){zog("zim.Frame(): stageH is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(m,"width",{get:function(){return v},set:function(){zog("zim.Frame(): width is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(m,"height",{get:function(){return z},set:function(){zog("zim.Frame(): height is read only - see remakeCanvas(), perhaps")}}),this.remakeCanvas=function(e,o){"full"!=t&&(zot(e)&&(e=v),zot(o)&&(o=z),zid("myCanvas")&&zid("myCanvas").parentNode.removeChild(zid("myCanvas")),v=e,z=o,c(),d())},this.dispose=function(){window.removeEventListener("resize",l),f.removeAllChildren(),f.removeAllEventListeners(),zid("myCanvas")&&zid("myCanvas").parentNode.removeChild(zid("myCanvas")),f=null,m=null}}return s.prototype=new createjs.EventDispatcher,s.prototype.constructor=e.Frame,new s},e}(zim||{}); \ No newline at end of file +function zid(e){return document.getElementById(e)}function zss(e){return document.getElementById(e)?document.getElementById(e).style:void(zon&&zog("zim wrap - zss(): id not found"))}function zgo(e,t,o){zot(t)&&""!=t||"_self"==t?window.location.href=e:zot(o)?window.open(e,"_blank"):window.open(e,"_blank","modal=yes,alwaysRaised=yes")}function zum(e){return zot(e)?void 0:Number(String(e).replace(/[^\d\.\-]/g,""))}function zot(e){return null===e?!0:"undefined"==typeof e}function zop(e){zot(e)||(e.stopImmediatePropagation&&e.stopImmediatePropagation(),window.event&&(window.event.cancelBubble=!0))}function zil(){var e=function(e){e||(e=event),e.keyCode&&e.keyCode>=32&&e.keyCode<=40&&e.preventDefault()},t=function(e){e||(e=event),e.preventDefault()},o=t;return window.addEventListener("keydown",e),window.addEventListener("mousewheel",t),window.addEventListener("DOMMouseScroll",o),[e,t,o]}"undefined"==typeof zon&&(zon=!1);var zog=console.log.bind(console);zon&&zog("ZIM WRAP - zog zid zss zgo zum zot zop zil");var zim=function(e){return zon&&zog("ZIM CODE Module"),e.shuffle=function(e){if(!zot(e)){var t,o,n=e.length;if(0==n)return e;for(;--n;)t=Math.floor(Math.random()*(n+1)),o=e[n],e[n]=e[t],e[t]=o;return e}},e.rand=function(e,t,o){zot(o)&&(o=!0),zot(t)&&(t=0),zot(e)&&(e=0),o&&(e>t?e++:t>e&&t++);var n;return 0==e&&0==t?Math.random():(n=0==t?Math.random()*e:Math.min(e,t)+Math.random()*(Math.max(e,t)-Math.min(e,t)),o?Math.floor(n):n)},e.copy=function(t){if(null==t||"object"!=typeof t)return t;if(t instanceof Array)return t.slice(0);if(t instanceof Object){copy={};for(var o in t)t.hasOwnProperty(o)&&(copy[o]=e.copy(t[o]));return copy}},e.arraysEqual=function(t,o,n){if(zot(t)||zot(o))return!1;if(zot(n)&&(n=!0),t.length!=o.length)return!1;for(var i=0;i0?o+(n-o)*s:n-(n-o)*s,a&&(d=Math.round(d)),d)}},e.ProportionDamp=function(e,t,o,n,i,a,r){function s(){isNaN(d)||(d=Math.max(d,e),d=Math.min(d,t),h=(d-e)/(t-e),l=n-o,c=a>0?o+l*h:n-l*h,p=c,u=p-f,f+=u*g.damp)}zon&&zog("zim code - ProportionDamp"),zot(o)&&(o=0),zot(n)&&(n=1),zot(i)&&(i=.1),zot(a)&&(a=1),zot(r)&&(r=!1),this.damp=i;var d,h,l,c,u,g=this,p=0,f=0;d=e,f=o;var v=setInterval(s,20);this.immediate=function(e){g.convert(e),s(),f=c,r&&(f=Math.round(f))},this.convert=function(e){return d=e,r?Math.round(f):f},this.dispose=function(){clearInterval(v)}},e.scrollX=function(t,o){return e.abstractScroll("X","Left",t,o)},e.scrollY=function(t,o){return e.abstractScroll("Y","Top",t,o)},e.abstractScroll=function(t,o,n,i){var a="X"==t?"Y":"X";if(zot(n)){var r=0,s=navigator.appName,d=navigator.userAgent.indexOf("Safari");if(-1!=d||"Safari"==s)var r=1;return r||"CSS1Compat"!=document.compatMode?document.body["scroll"+o]:document.documentElement["scroll"+o]}if(zot(i))window.scrollTo(e["scroll"+a](),n);else{var h=50;h>i&&(i=h);var l=i/h,c=e["scroll"+t](),u=n-c,g=u/l,p=0,f=setInterval(function(){p++,c+=g,window.scrollTo(e["scroll"+a](),c),p>=l&&(window.scrollTo(e["scroll"+a](),n),clearInterval(f))},h)}},e.windowWidth=function(){return isNaN(window.innerWidth)?window.clientWidth:window.innerWidth},e.windowHeight=function(){return isNaN(window.innerHeight)?window.clientHeight:window.innerHeight},e.urlEncode=function(e){var e=(e+"").toString();return encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},e.urlDecode=function(e){return decodeURIComponent((e+"").replace(/\+/g,"%20"))},e.setCookie=function(e,t,o){if(o){var n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3);var i="; expires="+n.toGMTString()}else var i="";document.cookie=e+"="+escape(t)+i+"; path=/"},e.getCookie=function(e){var t,o=document.cookie.split(/;\s*/),n=new Array;for(i=0;ia;a++)n=t.getChildAt(a),n.zimNoSwipe=e.zimNoSwipe,n instanceof createjs.Container&&o(n)}!zot(e)&&e.on&&(e.zimNoSwipe=t?null:!0,e instanceof createjs.Container&&o(e))},e.hitTestPoint=function(e,t,o){if(!zot(e)&&e.globalToLocal){var n=e.globalToLocal(t,o);return e.hitTest(n.x,n.y)}},e.hitTestReg=function(e,t){if(!zot(e)&&!zot(t)&&e.localToLocal&&t.localToLocal){var o=t.localToLocal(t.regX,t.regY,e);return e.hitTest(o.x,o.y)}},e.hitTestRect=function(e,t,o){if(!zot(e)&&!zot(t)&&e.hitTest&&t.getBounds){zot(o)&&(o=0);var n=t.getBounds();if(!n)return void zog("zim create - hitTestRect():\n please setBounds() on param b object");for(var i,a,r,s=0;o>=s;s++){if(i=n.width*(s+1)/(o+1),a=n.height*(s+1)/(o+1),r=t.localToLocal(n.x+i,n.y,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x+n.width,n.y+a,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x+n.width-i,n.y+n.height,e),e.hitTest(r.x,r.y))return!0;if(r=t.localToLocal(n.x,n.y+n.height-a,e),e.hitTest(r.x,r.y))return!0}}},e.hitTestCircle=function(e,t,o){if(!zot(e)&&!zot(t)&&e.hitTest&&t.getBounds){zot(o)&&(o=8);var n=t.getBounds();if(!n)return void zog("zim create - hitTestCircle():\n please setBounds() on param b object");for(var i,a,r,s,d=n.x+n.width/2,h=n.y+n.height/2,l=(n.width+n.height)/2/2,c=0;o>c;c++)if(i=c/o*2*Math.PI,a=d+l*Math.cos(i),r=h+l*Math.sin(i),s=t.localToLocal(a,r,e),e.hitTest(s.x,s.y))return!0}},e.hitTestBounds=function(t,o,n){function i(e,t){return e.x>=t.x+t.width||e.x+e.width<=t.x||e.y>=t.y+t.height||e.y+e.height<=t.y?!1:!0}if(!zot(t)&&!zot(o)&&t.getBounds&&o.getBounds){var a=!1;n&&n.graphics&&(a=!0);var r=t.getBounds(),s=o.getBounds();if(!r||!s)return void zog("zim create - hitTestBounds():\n please setBounds() on both objects");var d=e.boundsToGlobal(t),h=e.boundsToGlobal(o);if(a){var l=n.graphics;l.clear(),l.setStrokeStyle(1).beginStroke("blue"),l.drawRect(d.x,d.y,d.width,d.height),l.beginStroke("green"),l.drawRect(h.x,h.y,h.width,h.height),n.getStage().update()}return i(d,h)}},e.boundsToGlobal=function(e,t){if(!zot(e)&&e.getBounds){var o=e.getBounds();if(!o&&zot(t))return void zog("zim create - boundsToGlobal():\n please setBounds() on object (or a rectangle)");t&&(o=t);var n=e.localToGlobal(o.x,o.y),i=e.localToGlobal(o.x+o.width,o.y),a=e.localToGlobal(o.x+o.width,o.y+o.height),r=e.localToGlobal(o.x,o.y+o.height),s=Math.min(n.x,i.x,a.x,r.x),d=Math.min(n.y,i.y,a.y,r.y),h=Math.max(n.x,i.x,a.x,r.x),l=Math.max(n.y,i.y,a.y,r.y);return new createjs.Rectangle(s,d,h-s,l-d)}},e.scale=function(e,t){return!zot(e)&&e.scaleX?(zot(t)&&(t=1),e.scaleX=e.scaleY=t,e):void 0},e.scaleTo=function(t,o,n,i,a){if(zot(t)||!t.getBounds||!t.getBounds())return void zog("zim create - scaleTo(): please provide an object (with setBounds) to scale");if(zot(o)||!o.getBounds||!o.getBounds())return void zog("zim create - scaleTo(): please provide a boundObject (with setBounds) to scale to");if(zot(n)&&(n=-1),zot(i)&&(i=-1),-1==n&&-1==i)return t;zot(a)&&(a="smallest");var r=o.getBounds().width*n/100,s=o.getBounds().height*i/100;if((-1==n||-1==i)&&"both"!=a&&"stretch"!=a)return-1==n?e.scale(t,s/t.getBounds().height):e.scale(t,r/t.getBounds().width),t;if("both"==a||"stretch"==a)return t.scaleX=-1!=n?r/t.getBounds().width:t.scaleX,t.scaleY=-1!=i?s/t.getBounds().height:t.scaleY,t;if("biggest"==a||"largest"==a||"outside"==a)var d=Math.max(r/t.getBounds().width,s/t.getBounds().height);else var d=Math.min(r/t.getBounds().width,s/t.getBounds().height);return e.scale(t,d),t},e.move=function(t,o,n,i,a,r,s,d,h,l){return e.animate(t,{x:o,y:n},i,a,r,s,d,h,l)},e.animate=function(e,t,o,n,i,a,r,s,d){function h(){i&&"function"==typeof i&&i(a),createjs.Ticker.off("tick",l)}if(!zot(e)&&e.on&&!zot(t)&&e.getStage()){zot(n)&&(n="quadInOut"),zot(r)&&(r=0),zot(s)&&(s={override:!0}),zot(d)&&(d=60),createjs.Tween.get(e,s).wait(r).to(t,o,createjs.Ease[n]).call(h);var l=createjs.Ticker.on("tick",e.getStage());return createjs.Ticker.setFPS(d),e}},e.fit=function(e,t,o,n,i,a){if(!zot(e)&&e.getBounds){if(!e.getBounds())return void zog("zim create - fit(): please setBounds() on object");if(zot(t)){if(!e.getStage())return void zog("zim create - fit(): please add boundary dimensions or add obj to stage first");if(!e.getStage().getBounds())return void zog("zim create - fit(): please add boundary dimensions or add obj with bounds to stage first");var r=e.getStage().getBounds().width,s=e.getStage().getBounds().height;t=0,o=0,n=r,i=s}zot(a)&&(a=!0),e.scaleX=e.scaleY=1;var d,h=n,l=i,c=e.getBounds().width,u=e.getBounds().height;d=a?h/l>=c/u?l/u:h/c:h/l>=c/u?h/c:l/u,e.scaleX=e.scaleY=d;var g=c*d,p=u*d;return e.x=t+(h-g)/2,e.y=o+(l-p)/2,{x:e.x,y:e.y,width:g,height:p,scale:d,bX:t,bY:o,bWidth:n,bHeight:i}}},e.outline=function(e,t,o){if(zot(e)||!e.getBounds)return void zog("zim create - outline(): please provide object and shape");if(!e.getBounds())return void zog("zim create - outline(): please setBounds() on object");if(!e.parent)return void zog("zim create - outline(): object should be on stage first");zot(t)&&(t="brown"),zot(o)&&(o=2);var n=e.getBounds(),i=new createjs.Shape,a=e.parent,r=e.localToLocal(n.x,n.y,a),s=e.localToLocal(n.x+n.width,n.y,a),d=e.localToLocal(n.x+n.width,n.y+n.height,a),h=(e.localToLocal(n.x,n.y+n.height,a),i.graphics);h.s(t).ss(o).r(r.x,r.y,s.x-r.x,d.y-s.y),zero={x:r.x-n.x*e.scaleX,y:r.y-n.y*e.scaleY};var l=10,c=l+1;return h.s("white").ss(o+2),h.mt(zero.x-c,zero.y+0).lt(zero.x+c,zero.y+0),h.mt(zero.x+0,zero.y-c).lt(zero.x+0,zero.y+c),h.s(t).ss(o),h.mt(zero.x-l,zero.y+0).lt(zero.x+l,zero.y+0),h.mt(zero.x+0,zero.y-l).lt(zero.x+0,zero.y+l),h.s("white").ss(o+2).dc(e.x,e.y,l+6),h.s(t).ss(o).dc(e.x,e.y,l+6),e.parent.addChild(i),e.getStage()&&e.getStage().update(),e},e.centerReg=function(e,t){if(zot(e)||!e.getBounds)return void zog("zim create - centerReg(): please provide object with bounds set");if(!zot(t)){if(!t.getBounds)return void zog("zim create - centerReg(): please provide context with bounds set");e.x=t.getBounds().width/2,e.y=t.getBounds().height/2}var o=e.getBounds();return e.regX=o.width/2,e.regY=o.height/2,e},e}(zim||{}),zim=function(e){return zon&&zog("ZIM BUILD Module"),e.Circle=function(t,o,n,i){function a(){zot(t)&&(t=50),zot(o)&&(o="black");var a=this;this.mouseChildren=!1;var r=this.shape=new createjs.Shape;this.addChild(r);var s=r.graphics,d=s.beginFill(o).command;if(!zot(n)){var h=s.beginStroke(n).command;zot(i)&&(i=1);var l=s.setStrokeStyle(i).command}s.dc(0,0,t),this.width=2*t,this.height=2*t,this.setBounds(-t,-t,this.width,this.height),this.setFill=function(e){zot(e)||(o=e,d.style=o)},Object.defineProperty(a,"color",{get:function(){return o},set:function(e){a.setFill(e)}}),this.setStroke=function(e){h&&!zot(e)&&(n=e,h.style=n)},this.setStrokeSize=function(e){l&&!zot(e)&&(i=e,l.width=i)},this.clone=function(){return new e.Circle(t,o,n,i)}}return a.prototype=new createjs.Container,a.prototype.constructor=e.Circle,new a},e.Rectangle=function(t,o,n,i,a,r){function s(){zot(t)&&(t=100),zot(o)&&(o=100),zot(n)&&(n="black"),zot(r)&&(r=0);var s=this;this.mouseChildren=!1;var d=this.shape=new createjs.Shape;this.addChild(d);var h=d.graphics,l=h.beginFill(n).command;if(!zot(i)){var c=h.beginStroke(i).command;zot(a)&&(a=1);var u=h.setStrokeStyle(a).command}r>0?h.rr(0,0,t,o,r):h.r(0,0,t,o),this.width=t,this.height=o,this.setBounds(0,0,this.width,this.height),this.setFill=function(e){zot(e)||(n=e,l.style=n)},Object.defineProperty(s,"color",{get:function(){return n},set:function(e){s.setFill(e)}}),this.setStroke=function(e){c&&!zot(e)&&(i=e,c.style=i)},this.setStrokeSize=function(e){u&&!zot(e)&&(a=e,u.width=a)},this.clone=function(){return new e.Rectangle(t,o,n,i,a,r)}}return s.prototype=new createjs.Container,s.prototype.constructor=e.Rectangle,new s},e.Triangle=function(t,o,n,i,a,r,s,d){function h(){zot(t)&&(t=100),zot(o)&&(o=t),zot(n)&&(n=t),-1==n&&(n=Math.sqrt(Math.pow(t,2)+Math.pow(o,2))),zot(i)&&(i="black"),zot(s)&&(s=!0),zot(d)&&(d=0),this.mouseChildren=!1;var h=this,l=[t,o,n];if(l.sort(function(e,t){return t-e}),aa=l[0],bb=l[1],cc=l[2],aa>bb+cc)return void zog("zim build - Triangle(): invalid triangle lengths");var c=this.shape=new createjs.Shape;this.addChild(c);var u=c.graphics,g=u.beginFill(i).command;if(!zot(a)){var p=u.beginStroke(a).command;zot(r)&&(r=1);var f=u.setStrokeStyle(r).command}u.mt(0,0),u.lt(t,0);var v,m=180*Math.acos((Math.pow(bb,2)+Math.pow(cc,2)-Math.pow(aa,2))/(2*bb*cc))/Math.PI,z=180*Math.asin(bb*Math.sin(m*Math.PI/180)/aa)/Math.PI,w=180-m-z;v=n==aa?m:n==bb?z:w;var b=Math.cos(v*Math.PI/180)*o,y=Math.sin(v*Math.PI/180)*o;this.width=Math.max(t,t-b),this.height=y,this.setBounds(0,0,this.width,this.height),c.y=this.height,u.lt(t-b,0-y),u.cp(),s&&(this.regX=this.width/2,this.regY=this.height/2+d),this.setFill=function(e){zot(e)||(i=e,g.style=i)},Object.defineProperty(h,"color",{get:function(){return i},set:function(e){h.setFill(e)}}),this.setStroke=function(e){p&&!zot(e)&&(a=e,p.style=a)},this.setStrokeSize=function(e){f&&!zot(e)&&(r=e,f.width=r)},this.clone=function(){return new e.Triangle(t,o,n,i,a,r,s,d)}}return h.prototype=new createjs.Container,h.prototype.constructor=e.Triangle,new h},e.Label=function(t,o,n,i,a,r,s){function d(){zot(t)&&(t="LABEL"),""==t&&(t=" "),zot(o)&&(o=36),zot(n)&&(n="arial"),zot(i)&&(i="black"),zot(a)&&(a=i),zot(r)&&(r=null),zot(s)&&(s=16);var d=this;this.mouseChildren=!1;var h=this.label=new createjs.Text(String(t),o+"px "+n,i);h.textBaseline="alphabetic",h.textAlign="left",r&&s>0&&(h.shadow=new createjs.Shadow(r,3,3,s)),this.addChild(h);var l=new createjs.Shape;l.graphics.f("rgba(0,255,255,.01)").r(0,0,this.getBounds().width,this.getBounds().height),this.hitArea=l,this.width=this.getBounds().width,this.height=this.getBounds().height,this.setBounds(0,0,this.width,this.height),h.y=o-o/6,Object.defineProperty(d,"text",{get:function(){var e=" "==h.text?"":h.text;return e},set:function(e){0==e&&(e=" "),h.text=e,d.setBounds(0,0,h.getBounds().width,h.getBounds().height)}}),this.showRollColor=function(e){zot(e)&&(e=!0),e?h.color=a:h.color=i,d.getStage()&&d.getStage().update()},this.on("mouseover",function(e){d.showRollColor()}),this.on("mouseout",function(e){d.showRollColor(!1)}),this.clone=function(){return new e.Label(d.text,o,n,i,a,r,s)},this.dispose=function(){d.removeAllEventListeners()}}return d.prototype=new createjs.Container,d.prototype.constructor=e.Label,new d},e.Button=function(t,o,n,i,a,r,s,d,h,l){function c(){function c(e){g.on("mouseout",u);var n=p.graphics;n.clear(),n.f(a),r&&n.s(r).ss(s),n.rr(0,0,t,o,d),g.label.showRollColor(),g.getStage()&&g.getStage().update()}function u(e){g.off("mouseout",u);var n=p.graphics;n.clear(),n.f(i),r&&n.s(r).ss(s),n.rr(0,0,t,o,d),g.label.showRollColor(!1),g.getStage()&&g.getStage().update()}zot(t)&&(t=200),zot(o)&&(o=60),zot(i)&&(i="#C60"),zot(a)&&(a="#F93"),zot(r)&&(r=null),zot(s)&&(s=1),zot(d)&&(d=20),zot(h)&&(h="rgba(0,0,0,.3)"),zot(l)&&(l=16),zot(n)&&(n="PRESS"),("string"==typeof n||"number"==typeof n)&&(n=new e.Label(n,36,"arial","white"));var g=this;this.mouseChildren=!1,this.cursor="pointer";var p=new createjs.Shape,f=p.graphics;f.f(i),r&&f.s(r).ss(s),f.rr(0,0,t,o,d),this.addChild(p),this.backing=p,l>0&&(p.shadow=new createjs.Shadow(h,3,3,l)),this.setBounds(0,0,t,o),this.width=t,this.height=o,n.x=(t-n.getBounds().width)/2+1,n.y=(o-n.getBounds().height)/2+2,this.addChild(n),this.label=n,Object.defineProperty(g,"text",{get:function(){var e=" "==n.text?"":n.text;return e},set:function(e){n.text=e,n.x=(t-n.getBounds().width)/2+1,n.y=(o-n.getBounds().height)/2+2}}),this.on("mouseover",c),this.dispose=function(){g.removeAllEventListeners(),g.removeChild(p),g.removeChild(buttonLabel),p=null,buttonLabel=null}}return c.prototype=new createjs.Container,c.prototype.constructor=e.Button,new c},e.CheckBox=function(t,o,n,i,a){function r(){function r(e){s=!s,d.setChecked(s),d.dispatchEvent("change")}zot(t)&&(t=60),zot(o)&&(o=null),("string"==typeof o||"number"==typeof o)&&(o=new e.Label(o,5*t/6,"arial",i));var s=zot(n)?!1:n;zot(i)&&(i="black"),zot(a)&&(a=10),this.setBounds(-a,-a,t+2*a,t+2*a);var d=this;this.cursor="pointer";var h=new createjs.Shape,l=h.graphics;l.f("rgba(255,255,255,.5)").r(0,0,t,t),l.s(i).ss(t/10).r(t/7,t/7,t-t/7*2,t-t/7*2),this.addChild(h);var c=t;o&&(this.addChild(o),o.x=1.3*t,o.y=t/8,this.label=o,c=o.x+o.width);var u=new createjs.Shape;l=u.graphics,l.f("rgba(0,0,0,.01)").r(this.getBounds().x,this.getBounds().y,c+2*a,this.getBounds().height),this.hitArea=u;var g=new createjs.Shape,p=g.graphics;p.f(i).p("AnQAdICBiaIEEDZIF8nfICfB4In/KPg");var f=95;g.setBounds(-f/2,-f/2,f,f);var v=t/(f+66);g.scaleX=g.scaleY=v,g.x=t/2,g.y=t/2,s&&this.addChild(g),this.on("click",r),Object.defineProperty(d,"checked",{get:function(){return s},set:function(e){d.setChecked(e)}}),this.setChecked=function(e){zot(e)&&(e=!0),s=e,s?d.addChild(g):d.removeChild(g),d.getStage()&&d.getStage().update()},this.dispose=function(){d.removeAllEventListeners()}}return r.prototype=new createjs.Container,r.prototype.constructor=e.CheckBox,new r},e.RadioButtons=function(t,o,n,i,a,r){function s(){function s(e){l.setSelected(u.getChildIndex(e.target)),l.dispatchEvent("change")}function d(){for(var r,s=!1,d=o.length-1;d>=0;d--)r=o[d],r.selected&&r.selected===!0&&(s?r.selected="false":s=!0);u.removeAllChildren();for(var g,p=0,d=0;d=0){t=u.getChildAt(e);var n=-2;c&&(n=c.index),c=t.obj}-1==e||n==c.index?(c=null,l.id=null,l.label=null,l.text=""):(t.addChild(t.check),l.id=c.id,l.label=c.label,l.label&&(l.text=l.label.text)),l.getStage()&&l.getStage().update()}},Object.defineProperty(l,"selected",{get:function(){return c},set:function(e){selectedIndex=e}}),Object.defineProperty(l,"selectedIndex",{get:function(){return c?c.index:-1},set:function(e){this.setSelected(e)}}),this.dispose=function(){l.removeAllEventListeners()}}}return s.prototype=new createjs.Container,s.prototype.constructor=e.RadioButtons,new s},e.Pane=function(t,o,n,i,a,r,s,d,h,l,c,u,g){function p(){function p(e,i){return e=Math.max(o/2,Math.min(t.getBounds().width-o/2,e)),i=Math.max(n/2,Math.min(t.getBounds().height-n/2,i)),{x:e,y:i}}if(zot(t)||!t.getBounds)return void zog("zim build - Pane(): Please pass in a reference to a container with bounds set as first parameter");if(!t.getBounds())return void zog("zim build - Pane(): Please give the container bounds using setBounds()");if(zot(t.getStage))return void zog("zim build - Pane(): Please give the container that has a stage property");zot(o)&&(o=200),zot(n)&&(n=200),zot(i)&&(i=null),("string"==typeof i||"number"==typeof i)&&(i=new e.Label(i,40,"arial","black")),zot(a)&&(a="white"),zot(r)&&(r=!1),zot(s)&&(s=!1),zot(d)&&(d=!0),zot(h)&&(h=20),zot(l)&&(l=.14),zot(c)&&(c="#333"),zot(u)&&(u=20),zot(g)&&(g=!0);var f=this.backing=new createjs.Shape,v=f.graphics;v.beginFill("black"),v.drawRect(-5e3,-5e3,1e4,1e4),this.setBounds(-o/2,-n/2,o,n),f.alpha=l;var m=this;f.on("click",function(e){m.hide(),m.dispatchEvent("close"),e.stopImmediatePropagation()}),f.on("mousedown",function(e){e.stopImmediatePropagation()}),d&&this.addChild(f);var z=this.display=new createjs.Shape;if(z.setBounds(0,0,o,n),z.regX=o/2,z.regY=n/2,v=z.graphics,v.beginFill(a),v.drawRoundRect(0,0,o,n,h),u>0&&(z.shadow=new createjs.Shadow(c,8,8,u)),z.on("click",function(e){e.stopImmediatePropagation()}),this.resetX,this.resetY,r){z.cursor="pointer";var w,b;z.on("mousedown",function(e){isNaN(m.resetX)&&(m.resetX=m.x),isNaN(m.resetY)&&(m.resetY=m.y),w=e.stageX-m.x,b=e.stageY-m.y,z.cursor="move"}),z.on("pressmove",function(e){var o=p(e.stageX-w,e.stageY-b);m.x=o.x,m.y=o.y,t.getStage().update()}),this.on("pressup",function(e){z.cursor="pointer"})}this.addChild(z),i&&(g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2),this.addChild(i),this.label=i,this.text=i.text),Object.defineProperty(m,"text",{get:function(){var e=" "==i.text?"":i.text;return e},set:function(e){i.text=e,g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2)}}),this.hide=function(){t.removeChild(m),t.getStage().update(),s&&(isNaN(m.resetX)||(m.x=m.resetX),isNaN(m.resetY)||(m.y=m.resetY))},this.show=function(){m.x=t.getBounds().width/2,m.y=t.getBounds().height/2,g&&i&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2),t.addChild(m),t.getStage().update()},this.dispose=function(){z.removeAllEventListeners(),m.removeChild(z),z=null}}return p.prototype=new createjs.Container,p.prototype.constructor=e.Pane,new p},e.Waiter=function(t,o,n,i,a,r,s){function d(){if(zot(t)||!t.getBounds)return void zog("zim build - Waiter(): Please pass in a reference to a container with bounds set as first parameter");if(!t.getBounds())return void zog("zim build - Waiter(): Please give the container bounds using setBounds()");if(zot(t.getStage))return void zog("zim build - Waiter(): Please give the container that has a stage property");zot(o)&&(o=600),zot(n)&&(n="orange"),zot(i)&&(i="white"),zot(a)&&(a=16),zot(r)&&(r="#444"),zot(s)&&(s=14);var e=40,d=3,h=.6*e/2,l=(e-2*h)/2,c=d*(2*h+l)+l;this.setBounds(-c/2,-e/2,c,e);var u=this,g=this.display=new createjs.Shape;this.addChild(g),g.setBounds(0,0,c,e),g.regX=c/2,g.regY=e/2;var p=g.graphics;p.beginFill(n),p.drawRoundRect(0,0,c,e,a),s>0&&(g.shadow=new createjs.Shadow(r,3,3,s)),g.on("click",function(e){e.stopImmediatePropagation()});var f=new createjs.Container;this.addChild(f);for(var v,m=0;d>m;m++)v=new createjs.Shape,v.graphics.f(i).dc(0,0,h),v.x=(m-(d-1)/2)*(2*h+l),f.addChild(v),v.cache(-h,-h,2*h,2*h),v.alpha=0;t.getStage().update(),this.hide=function(){createjs.Tween.get(u,{override:!0}).to({alpha:0},300).call(function(){createjs.Ticker.off("tick",u.ticker),t.removeChild(u),t.getStage().update()})},this.show=function(){for(var e,n=0,i=0;it.length-1&&(o=0),0>o&&(o=t.length-1);else{if(o>t.length-1)return;if(0>o)return}g(o)}function g(e){p=e,a.text=t[p],a.x=y.x+(y.getBounds().width-a.getBounds().width)/2,a.y=y.y+(y.getBounds().height-a.getBounds().height)/2,z.alpha=1,b.setFill(n),z.cursor="pointer",x.alpha=1,B.setFill(n),x.cursor="pointer",c||(0==p&&(z.alpha=.8,b.setFill("#aaa"),z.cursor="default"),p==t.length-1&&(x.alpha=.8,B.setFill("#aaa"),x.cursor="default")),a.getStage()&&a.getStage().update(),f.dispatchEvent("change")}zot(t)&&(t=[1,2,3,4,5,6,7,8,9,10]),zot(o)&&(o=200),zot(n)&&(n="white"),zot(i)&&(i=null),zot(a)&&(a=""),("string"==typeof a||"number"==typeof a)&&(a=new e.Label(a,64,"arial","#555")),zot(r)&&(r=!1),zot(s)&&(s=!0),zot(d)&&(d=16),zot(h)&&(h="rgba(0,0,0,.3)"),zot(l)&&(l=14),zot(c)&&(c=!1);var p,f=this,v=100,m=v/4,z=this.arrowPrev=new createjs.Container;this.addChild(z);var w=new createjs.Shape;w.graphics.f("rgba(255,255,255,.11)").r(0,0,1.5*v,1.5*v),w.regX=1.5*v/2,w.regY=1.5*v/2+m/2,z.hitArea=w;var b=new e.Triangle(v,.8*v,.8*v,n);l>0&&(z.shadow=new createjs.Shadow(h,3,3,l)),z.addChild(b),z.cursor="pointer",z.on("click",function(e){u(-1)}),r?(z.rotation=0,z.x=o/2,z.y=z.getBounds().height/2):(z.rotation=-90,z.x=z.getBounds().height/2,z.y=z.getBounds().width/2);var y=this.textBox=new createjs.Shape;this.addChild(y),y.setBounds(0,0,o,v),null!=i&&y.graphics.s(i).ss(1.5),y.graphics.f(n).rr(0,0,o,v,d),l>0&&(y.shadow=new createjs.Shadow(h,3,3,l)),r?y.y=b.height+m:y.x=b.height+m,this.addChild(a),t.length>0&&(p=0,a.text=t[p]),a.x=y.x+(y.getBounds().width-a.getBounds().width)/2,a.y=y.y+(y.getBounds().height-a.getBounds().height)/2;var x=this.arrowNext=new createjs.Container;this.addChild(x);var C=new createjs.Shape;C.graphics.f("rgba(255,255,255,.01)").r(0,0,1.5*v,1.5*v),C.regX=1.5*v/2,C.regY=1.5*v/2+m/2,x.hitArea=C;var B=new e.Triangle(v,.8*v,.8*v,n);l>0&&(x.shadow=new createjs.Shadow(h,3,3,l)),x.addChild(B),x.cursor="pointer",x.on("click",function(e){u(1)}),r?(x.rotation=180,x.x=o/2,x.y=y.y+y.getBounds().height+x.getBounds().height/2+m):(x.rotation=90,x.x=y.x+y.getBounds().width+x.getBounds().height/2+m,x.y=x.getBounds().width/2),g(p),Object.defineProperty(this,"currentIndex",{get:function(){return p},set:function(e){p=Math.min(t.length-1,Math.max(0,e)),g(p)}}),Object.defineProperty(this,"currentValue",{get:function(){return t[p]},set:function(e){t.indexOf(e)>-1&&(p=t.indexOf(e)),g(p)}}),Object.defineProperty(this,"loop",{get:function(){return c},set:function(e){c=e,g(p)}}),Object.defineProperty(this,"stepperArray",{get:function(){return t},set:function(e){t=e}}),s&&(this.keyDownEvent=function(e){if(e||(e=event),e.keyCode>=37&&e.keyCode<=40){var o;if(38==e.keyCode||39==e.keyCode?o=p+1:(37==e.keyCode||40==e.keyCode)&&(o=p-1),o>t.length-1)return;if(0>o)return;g(o)}},window.addEventListener("keydown",this.keyDownEvent)),this.next=function(){u(1)},this.prev=function(){u(-1)},this.dispose=function(){f.removeAllEventListeners()}}return u.prototype=new createjs.Container,u.prototype.constructor=e.Stepper,new u},e.Parallax=function(t,o,n,i){function a(e){s.step()}if(zon&&zog("zim build - Parallax"),zot(t)||!t.getBounds)return void zog("zim build - Parallax(): please pass in the stage with bounds as first parameter");if(!t.getBounds())return void zog("zim build - Parallax(): Please give the stage bounds using setBounds()");zot(i)&&(i=!0);var r=t.getBounds().width,s=(t.getBounds().height,this);this.damp=zot(o)?.1:o,this.addLayer=function(t){if(!(zot(t.obj)||zot(t.prop)||zot(t.propChange))){var o={obj:t.obj,prop:t.prop};o[o.prop]=t.propChange,zot(t.input)&&(t.input="mouseX"),o.input=t.input;var n=zot(t.inMin)?0:t.inMin,i=zot(t.inMax)?r:t.inMax,a=zot(t.factor)?1:t.factor,h=zot(t.integer)?!1:t.integer;return o["p_"+o.prop]=new e.ProportionDamp(n,i,0,o[o.prop],s.damp,a,h),"scale"==o.prop?o["s_"+o.prop]=o.obj.scaleX:"frame"==o.prop?o["s_"+o.prop]=o.obj.currentFrame:o["s_"+o.prop]=o.obj[o.prop],d.push(o),d.length-1}},this.removeLayer=function(e){if(!zot(e)){var t=d[e];t["p_"+t.prop].dispose(),d.splice(e,1)}},this.immediate=function(e){for(var t,o=0;o0?t.x<0&&e.xd&&t.x>e.x?t.x=e.x-e.getBounds().width+s.gapFix:e.x>d&&e.x>t.x&&(e.x=t.x-t.getBounds().width+s.gapFix)):(e.y-=s.speed*s.direction,t.y-=s.speed*s.direction,s.direction*s.speed>0?t.y<0&&e.yh&&t.y>e.y?t.y=e.y-e.getBounds().height+s.gapFix:e.y>h&&e.y>t.y&&(e.y=t.y-t.getBounds().height+s.gapFix)),e.getStage().update())}}if(zon&&zog("zim build - Scroller"),!zot(e)&&e.getBounds&&!zot(t)&&t.getBounds){zot(i)&&(i=!0);var s=this;if(this.speed=zot(o)?1:o,this.direction=zot(n)?1:n,this.gapFix=zot(a)?0:a,!e.getBounds()||!t.getBounds())return void zog("zim build - Scroller(): please setBounds() on backing objects");if(!e.getStage())return void zog("zim build - Scroller(): please add backing objects to stage to start"); +var d,h;i?t.x=e.getBounds().width:t.y=e.getBounds().height;var l=createjs.Ticker.on("tick",r);createjs.Ticker.setFPS(60),this.dispose=function(){zon&&zog("bye from Scroller"),createjs.Ticker.off("tick",l)}}},e}(zim||{}),zim=function(e){return zon&&zog("ZIM PAGES Module"),e.Swipe=function(t,o,n){function i(){if(zot(t)||!t.on)return void zog("zim pages - Swipe():\nPlease pass in object");zot(o)&&(o=30),zot(n)&&(n=80),this.distance=o,this.duration=n,this.active=!0;var e,i,a,r,s,d,h=this;t.on("mousedown",function(o){function n(){var t=!1;Math.abs(a-e)>Math.abs(r-i)?(a-e>h.distance&&(h.direction="right",h.dispatchEvent("swipe"),t=!0),e-a>h.distance&&(h.direction="left",h.dispatchEvent("swipe"),t=!0)):(r-i>h.distance&&(h.direction="down",h.dispatchEvent("swipe"),t=!0),i-r>h.distance&&(h.direction="up",h.dispatchEvent("swipe"),t=!0)),t||(h.direction="none",h.dispatchEvent("swipe"))}h.active&&!o.target.zimNoSwipe&&(h.obj=o.target,a=e=o.stageX,r=i=o.stageY,s=!0,h.dispatchEvent("swipedown"),clearTimeout(d),d=setTimeout(function(){s&&(n(),s=!1)},h.duration),t.on("pressmove",function(e){a=e.stageX,r=e.stageY}),t.on("pressup",function(e){s&&(n(),s=!1,clearTimeout(d))}))}),this.disable=function(){h.active=!1},this.enable=function(){h.active=!0}}return i.prototype=new createjs.EventDispatcher,i.prototype.constructor=e.Swipe,new i},e.Pages=function(t,o,n,i,a){function r(){function r(){s=new createjs.Shape,s.graphics.f("black").r(0,0,l,c+1),d=new createjs.Shape,d.graphics.f("white").r(0,0,l,c+1)}if(zot(t)||!t.getBounds||!t.getBounds())return void zog("zim pages - Pages():\nobject must have bounds set");zot(o)&&(o=[]),zot(n)&&(n="none"),zot(i)&&(i=200),zot(a)&&(a=[]),this.transitionTable=a,this.speed=i,this.active=!0;var s,d,h=this,l=t.getBounds().width,c=t.getBounds().height,u=this.page=o[0]?o[0].page:null;("none"!=n||a!=[])&&r();for(var g,p,f=["left","right","up","down"],v=0;v0&&setTimeout(function(){h.settle()},e)},this.settle=function(){h.removeAllChildren(),h.addChild(u),h.dispatchEvent("puffed")},this.disable=function(){h.active=!1},this.enable=function(){h.active=!0},this.dispose=function(){h.swipe.off("swipe",w),h.removeAllChildren(),o=null}}return r.prototype=new createjs.Container,r.prototype.constructor=e.Pages,new r},e.HotSpots=function(t,o,n){function i(){function i(t){var i=null;if(!Array.isArray(t.rect)){if(i=t.rect,!i)return void zog("zim pages - HotSpots(): HotSpot "+t.page+" "+t.rect+" button does not exist");if(!i.getBounds())return void zog("zim pages - HotSpots(): HotSpots button needs bounds");t.rect=[i.x,i.y,i.getBounds().width,i.getBounds().height]}s=new e.HotSpot(t.page,t.rect[0],t.rect[1],t.rect[2],t.rect[3],t.call,o),s.zimHSpage=t.page,s.button=i,d.push(s),s.on("click",a),i&&(s.spot.mouseEnabled=!1,s.spot.mouseChildren=!1,i.zimHScall=t.call,i.zimHSEvent=i.on("click",a),n||(i.zimHSMDEvent=i.on("mousedown",function(e){e.stopImmediatePropagation()})),i.cursor="pointer")}function a(e){"function"==typeof e.currentTarget.zimHScall&&e.currentTarget.zimHScall()}if(zot(t)||!Array.isArray(t))return void zog("zim pages - HotSpots():\nplease provide an array of HotSpot data");zot(o)&&(o=!0),zot(n)&&(n=!1);for(var r,s,d=[],h=0;h=0;i--)r=t[i],s=d[i],n&&!Array.isArray(n)&&(n=[n.x,n.y,n.getBounds().width,n.getBounds().height]),(zot(o)&&zot(n)||zot(n)&&o==r.page||zot(o)&&e.arraysEqual(n,r.rect)||o==r.page&&e.arraysEqual(n,r.rect))&&(t.splice(i,1),s.button&&(s.button.off("click",s.button.zimHSEvent),s.button.zimHSEvent=null),s.off("click",a),s.dispose(),d.splice(i,1))},this.dispose=function(){for(var e=0;er;r++)i.mt(r*x/20,0).lt(r*x/20,C);for(var r=1;20>r;r++)i.mt(0,r*C/20).lt(x,r*C/20);e.alpha=.3,i=a.graphics,i.s(o).ss(1);for(var r=1;10>r;r++)i.mt(r*x/10,0).lt(r*x/10,C);for(var r=1;10>r;r++)i.mt(0,r*C/10).lt(x,r*C/10)}else{for(var r=0;x/g>r;r++)i.mt(r*g,0).lt(r*g,C);for(var r=0;C/g>r;r++)i.mt(0,r*g).lt(x,r*g);e.alpha=.3,i=a.graphics,i.s(o).ss(1);for(var r=0;x/(10*g)>r;r++)i.mt(r*(10*g),0).lt(r*(10*g),C);for(var r=0;C/(10*g)>r;r++)i.mt(0,r*(10*g)).lt(x,r*(10*g))}var s=80;i.s("#FFFFFF").ss(8),i.mt(x/2,C/2-s/2).lt(x/2,C/2+s/2),i.mt(x/2-s/2,C/2).lt(x/2+s/2,C/2),i.s("#000000").ss(4),i.mt(x/2,C/2-s/2).lt(x/2,C/2+s/2),i.mt(x/2-s/2,C/2).lt(x/2+s/2,C/2),i.s(o).ss(3),i.dr(0,0,x,C),a.alpha=.5,B.cache(0,0,x,C),u.addChild(v),u.addChild(m),l.update()}function h(e){e||(e=event),l&&(String.fromCharCode(e.keyCode)==i.toUpperCase()&&(u.visible=!u.visible,l.off("stagemousemove",c),u.visible&&(c=l.on("stagemousemove",s,u)),l.update()),String.fromCharCode(e.keyCode)==a.toUpperCase()&&(u.removeChild(B),B=null,u.pixels=!u.pixels))}if(zot(t)&&(t="stage"),zot(o)&&(o="black"),!("stage"==t||t.getBounds&&t.getBounds()))return void zog("zim pages - Grid(): Please provide bounds for the obj (setBounds())");zot(n)&&(n=!0),zot(i)&&(i="G"),zot(a)&&(a="P");var l,c,u=this,g=10;this.mouseChildren=!1,this.mouseEnabled=!1;var p=80,f=26,v=e("#dddddd",o,"#333333");v.shape.regX=p/2,v.shape.regY=-f/4,v.label.y=3*f/4;var m=e("#dddddd",o,"#333333");m.shape.regX=-p/6,m.shape.regY=f/2,m.label.x=p/2+p/6;var z,w,b=p/6+p/2,y=2*f;v.x=b,m.y=y,v.label.text="x:0",m.label.text="y:0";var x,C,B,S=setInterval(function(){"stage"==t?u&&u.getStage()&&r():t&&t.getStage()&&r()},100),j=!1,M={x:0,y:0};Object.defineProperty(this,"pixels",{get:function(){return!n},set:function(e){n=!e,u.resize()}}),window.addEventListener("keydown",h),this.resize=function(){return u?(u.removeChild(B),B=null,l&&(d(),s(),setTimeout(function(){u.removeChild(B),B=null,d()},200)),!0):!1},this.dispose=function(){clearInterval(S),u.removeAllChildren(),window.removeEventListener("keydown",h),u.parent&&u.parent.removeChild(u),u=null}}return r.prototype=new createjs.Container,r.prototype.constructor=e.Grid,new r},e.GridManager=function(){e.Manager.call(this,"GridManager")},e.GridManager.prototype=new e.Manager,e.GridManager.prototype.constructor=e.GridManager,e.Layout=function(t,o,n,i,a,r,s,d){function h(){function h(){for(var e=0,t=0;t100)return void zog("zim pages - Layout(): cannot fit regions into 100% bounds");var B=100-f;h(),this.resize=function(){if(g.active){c=s.getBounds(),t.setBounds(0,0,c.width,c.height),u.graphics.clear(),""!=i&&u.graphics.f(i).r(0,0,c.width,c.height);for(var d=0;d0&&0==p.maxGiven&&(x=p.object.getBounds()[m],C=p.object.getBounds()[z],S=p.given*c[m]/100,j=p[b]*c[z]/100,M=C/x*S,M>j?(k=!0,p.maxGiven=x/C*j*100/c[m],y+=p.given-p.maxGiven,T-=p.maxGiven):l=!1);if(!k)break;if(l)break;totalPrimaries=0;for(var d=0;d0?p.maxGiven0&&p.given0?p.maxGiven0&&p.given100?void zog("zim build - Layout(): cannot fit regions into 100% bounds"):(B=100-f,h(),void g.resize())}for(var L=!0,E=0,A=0,d=0;d0?A+=p[m]:p.maxGiven>0?A+=p.maxGiven:p.given>0&&(A+=p.given),0==p[m]&&(L=!1);if(L||l){E+=n;var X=100-A-E;if(E-=n+o[0][w],0!=X&&0!=E)for(var d=0;d0?p.marginGiven*c[m]/100:p[w]*c[m]/100,x=p[m]>0?p[m]:p.maxGiven>0?p.maxGiven:p.given>0?p.given:0,x=x*c[m]/100,C=p[b]*c[z]/100,O=(c[z]-C)/2,Y=a?e.fit(p.object,O,I,C,x):e.fit(p.object,I,O,x,C),"top"==p.valign?p.object.y=Y.bY:"bottom"==p.valign&&(p.object.y=Y.bY+Y.bHeight-Y.height),"left"==p.align?p.object.x=Y.bX:"right"==p.align&&(p.object.x=Y.bX+Y.bWidth-Y.width),r&&r.graphics&&(H.s("white").ss(2).r(Y.bX,Y.bY,Y.bWidth,Y.bHeight),H.s("#ff8203").ss(2).drawDashedRect(Y.bX,Y.bY,Y.bWidth,Y.bHeight,20)),F=G=0,(0==I||I+x==c[m])&&(a?F=1:G=1),C==c[z]&&(a?G=1:F=1),""!=p.backgroundColor&&u.graphics.f(p.backgroundColor).r(Y.bX,Y.bY,Y.bWidth+G,Y.bHeight+F),I+=x}},this.resize(),r&&t.addChild(r),t.addChildAt(u,0),window.addEventListener("keydown",l),this.disable=function(){g.active=!1,window.removeEventListener("keydown",l),r&&(r.alpha=0)},this.enable=function(){g.active=!0,window.addEventListener("keydown",l),g.resize(),r&&(r.alpha=1)},this.removeShape=function(){r&&(r.graphics.clear(),t.removeChild(r),r=null,r=!1),window.removeEventListener("keydown",l)},this.addShape=function(e,o){g.removeShape(),r=e,window.addEventListener("keydown",l),t.addChild(r),g.resize()},this.dispose=function(){g.removeShape()}}return h.prototype=new createjs.EventDispatcher,h.prototype.constructor=e.Layout,new h},e.LayoutManager=function(){zon&&zog("zim pages - LayoutManager");var e=this;this.items=[],this.add=function(t){e.items.push(t)},this.resize=function(){for(var t=0;tr?"horizontal":"vertical",g!=p&&(p=g,v.dispatchEvent("orientation")),i){if("fit"==t)a/r>=m/z?(n=r,o=n*m/z):(o=a,n=o*z/m);else if("outside"==t)document.body.style.overflow="hidden",a/r>=m/z?(o=a,n=o*z/m):(n=r,o=n*m/z);else if("full"==t)return document.body.style.overflow="hidden",i.style.left=i.style.top="0px",m=a,z=r,f&&f.setBounds(0,0,m,z),void h();i.style.width=o+"px",i.style.height=n+"px",i.style.left=(a-o)/2+"px",i.style.top=(r-n)/2+"px"}}function c(){var e=document.createElement("canvas");e.setAttribute("id","myCanvas"),u=Math.max(window.innerWidth,screen.width,window.innerHeight,screen.height),"full"==t?(e.setAttribute("width",u),e.setAttribute("height",u)):(e.setAttribute("width",m),e.setAttribute("height",z)),document.body.appendChild(e)}zot(t)&&(t="full"),zot(o)&&(o=500),zot(n)&&(n=500),zot(i)&&(i=!0),zot(a)&&(a=!0),zot(r)&&(r=!0);var u,g,p,f,v=this,m=o,z=n,w=!1;window.addEventListener("load",s),"none"!=t&&window.addEventListener("resize",l),Object.defineProperty(v,"stage",{get:function(){return f},set:function(e){zog("zim.Frame(): stage is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(v,"stageW",{get:function(){return m},set:function(e){zog("zim.Frame(): stageW is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(v,"stageH",{get:function(){return z},set:function(e){zog("zim.Frame(): stageH is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(v,"width",{get:function(){return m},set:function(e){zog("zim.Frame(): width is read only - see remakeCanvas(), perhaps")}}),Object.defineProperty(v,"height",{get:function(){return z},set:function(e){zog("zim.Frame(): height is read only - see remakeCanvas(), perhaps")}}),this.remakeCanvas=function(e,o){"full"!=t&&(zot(e)&&(e=m),zot(o)&&(o=z),zid("myCanvas")&&zid("myCanvas").parentNode.removeChild(zid("myCanvas")),m=e,z=o,c(),d())},this.dispose=function(){window.removeEventListener("resize",l),f.removeAllChildren(),f.removeAllEventListeners(),zid("myCanvas")&&zid("myCanvas").parentNode.removeChild(zid("myCanvas")),f=null,v=null}}return s.prototype=new createjs.EventDispatcher,s.prototype.constructor=e.Frame,new s},e}(zim||{}); \ No newline at end of file diff --git a/zimbuild.js b/zimbuild.js index fee98f0..7591d0d 100644 --- a/zimbuild.js +++ b/zimbuild.js @@ -8,7 +8,7 @@ if (typeof zog === "undefined") { // bootstrap zimwrap.js document.write('