diff --git a/lime/css/lime.css.soy.js b/lime/css/lime.css.soy.js index 17ee7af1..1afa51a2 100644 --- a/lime/css/lime.css.soy.js +++ b/lime/css/lime.css.soy.js @@ -3,8 +3,7 @@ goog.provide('lime.css'); -goog.require('soy'); -goog.require('soydata'); +goog.require('goog.soy'); lime.css.css = function(opt_data, opt_ignored) { diff --git a/lime/demos/pong/compiled/assets/icon.png b/lime/demos/pong/compiled/assets/icon.png deleted file mode 100644 index c8626348..00000000 Binary files a/lime/demos/pong/compiled/assets/icon.png and /dev/null differ diff --git a/lime/demos/pong/compiled/assets/startup.jpg b/lime/demos/pong/compiled/assets/startup.jpg deleted file mode 100644 index df5d4758..00000000 Binary files a/lime/demos/pong/compiled/assets/startup.jpg and /dev/null differ diff --git a/lime/demos/pong/compiled/assets/startup_ipad.jpg b/lime/demos/pong/compiled/assets/startup_ipad.jpg deleted file mode 100644 index 147cdc03..00000000 Binary files a/lime/demos/pong/compiled/assets/startup_ipad.jpg and /dev/null differ diff --git a/lime/demos/pong/compiled/pong.html b/lime/demos/pong/compiled/pong.html deleted file mode 100644 index b2eb8d4a..00000000 --- a/lime/demos/pong/compiled/pong.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - pong - - - - - - - - diff --git a/lime/demos/pong/compiled/pong.js b/lime/demos/pong/compiled/pong.js deleted file mode 100644 index 33f109ac..00000000 --- a/lime/demos/pong/compiled/pong.js +++ /dev/null @@ -1,569 +0,0 @@ -var COMPILED=!0,goog=goog||{};goog.global=this;goog.DEBUG=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.provide=function(a){if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a];for(var b=a;(b=b.substring(0,b.lastIndexOf(".")))&&!goog.getObjectByName(b);)goog.implicitNamespaces_[b]=!0}goog.exportPath_(a)}; -goog.setTestOnly=function(a){if(COMPILED&&!goog.DEBUG)throw a=a||"",Error("Importing test-only code into non-debug environment"+a?": "+a:".");};COMPILED||(goog.isProvided_=function(a){return!goog.implicitNamespaces_[a]&&!!goog.getObjectByName(a)},goog.implicitNamespaces_={});goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;!(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}}; -goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]}; -goog.addDependency=function(a,b,c){if(!COMPILED){var d;a=a.replace(/\\/g,"/");for(var e=goog.dependencies_,f=0;d=b[f];f++)e.nameToPath[d]=a,a in e.pathToNames||(e.pathToNames[a]={}),e.pathToNames[a][d]=!0;for(d=0;b=c[d];d++)a in e.requires||(e.requires[a]={}),e.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0; -goog.require=function(a){if(!COMPILED&&!goog.isProvided_(a)){if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b){goog.included_[b]=!0;goog.writeScripts_();return}}a="goog.require could not find: "+a;goog.global.console&&goog.global.console.error(a);throw Error(a);}};goog.basePath="";goog.nullFunction=function(){};goog.identityFunction=function(a,b){return a};goog.abstractMethod=function(){throw Error("unimplemented abstract method");}; -goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[]; -!COMPILED&&goog.ENABLE_DEBUG_LOADER&&(goog.included_={},goog.dependencies_={pathToNames:{},nameToPath:{},requires:{},visited:{},written:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return"undefined"!=typeof a&&"write"in a},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH)goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("script"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d= --1==d?c.length:d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a){var b=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_;!goog.dependencies_.written[a]&&b(a)&&(goog.dependencies_.written[a]=!0)},goog.writeScriptTag_=function(a){if(goog.inHtmlDocument_()){var b=goog.global.document;if("complete"==b.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}b.write(' + + + + + + + + + \ No newline at end of file diff --git a/lime/src/renderer/canvas.js b/lime/src/renderer/canvas.js index 0ed569a4..dd91b7de 100644 --- a/lime/src/renderer/canvas.js +++ b/lime/src/renderer/canvas.js @@ -40,7 +40,7 @@ lime.Renderer.CANVAS.drawCanvas = function() { bounds = this.boundsCache; } else { - if (this.staticCanvas != 1 && this.children_.length != 0) { + if (this['staticCanvas'] != 1 && this.children_.length != 0) { if(!(this instanceof lime.Scene)){ bounds.expand(PADDING, PADDING, PADDING, PADDING); } diff --git a/lime/src/renderer/renderer.js b/lime/src/renderer/renderer.js index 22acc7da..e68be49f 100644 --- a/lime/src/renderer/renderer.js +++ b/lime/src/renderer/renderer.js @@ -1,6 +1,7 @@ goog.provide('lime.Renderer'); + /** * Renderer logic object. This object defines lower level * technologies that are used to draw Node instaces on screen. @@ -8,26 +9,30 @@ goog.provide('lime.Renderer'); */ lime.Renderer = function() {}; + /** * Draw the object using the renderer */ lime.Renderer.prototype.draw = goog.nullFunction; +// should be goog.abstractMethod, but directory rely on being null function. + /** * Return base object of the subrenderer * @return {lime.Renderer} base renderer. */ lime.Renderer.prototype.getType = function() { - return this.base ? this.base : this; + return this.base ? this.base : this; }; + /** * Make and return subrenderer object. * @param {Object|lime.Renderer} sub Cloned empty instance. * @return {Object|lime.Renderer} Subrenderer. */ lime.Renderer.prototype.makeSubRenderer = function(sub) { - goog.object.extend(/** @lends {this} */sub, this); - sub.base = this.getType(); - return sub; + goog.object.extend(/** @lends {this} */sub, this); + sub.base = this.getType(); + return sub; }; diff --git a/lime/src/scene.js b/lime/src/scene.js index 2ee7dcee..653bcc01 100644 --- a/lime/src/scene.js +++ b/lime/src/scene.js @@ -1,31 +1,34 @@ goog.provide('lime.Scene'); - goog.require('lime'); goog.require('lime.Node'); + + /** * Scene object * @constructor - * @extends lime.Node + * @extends {lime.Node} */ lime.Scene = function() { - lime.Node.call(this); + lime.Node.call(this); - this.setAnchorPoint(0, 0); + this.setAnchorPoint(0, 0); - this.domClassName = goog.getCssName('lime-scene'); - this.createDomElement(); + this.domClassName = goog.getCssName('lime-scene'); + this.createDomElement(); }; goog.inherits(lime.Scene, lime.Node); + /** @inheritDoc */ lime.Scene.prototype.getScene = function() { - return this; + return this; }; + /** @inheritDoc */ lime.Scene.prototype.measureContents = function() { - return this.getFrame(); -} \ No newline at end of file + return this.getFrame(); +}; diff --git a/lime/src/schedulemanager.js b/lime/src/schedulemanager.js index bfc831b5..7ab9d56f 100644 --- a/lime/src/schedulemanager.js +++ b/lime/src/schedulemanager.js @@ -1,54 +1,11 @@ -goog.provide('lime.scheduleManager'); +goog.provide('lime.ScheduleManager'); +goog.provide('lime.Task'); goog.require('goog.array'); -goog.require('goog.userAgent'); +goog.require('goog.async.AnimationDelay'); goog.require('lime'); -/** - * Unified timer provider class - * Don't create instances of this class. Used the shared instance. - * @this {lime.scheduleManager} - * @constructor - */ -lime.scheduleManager = new (function() { - - /** - * Array of registered functions - * @type {Array.} - * @private - */ - this.taskStack_ = []; - - /** - * ScheduleManager is active - * @type {boolean} - * @private - */ - this.active_ = false; - - /** - * Internal setInterval id - * @type {number} - * @private - */ - this.intervalID_ = 0; - - /** - * Maximum update rate in ms. - * @type {number} - * @private - */ - this.displayRate_ = 1000 / 30; - - /** - * Timer last fire timestamp - * @type {number} - * @private - */ - this.lastRunTime_ = 0; - -})(); /** * Scheduled task @@ -56,310 +13,296 @@ lime.scheduleManager = new (function() { * @param {number=} opt_limit Number of calls. * @constructor */ -lime.scheduleManager.Task = function(maxdelta, opt_limit) { - this.delta = this.maxdelta = maxdelta; - this.limit = goog.isDef(opt_limit) ? opt_limit : -1; - this.functionStack_ = []; +lime.Task = function(maxdelta, opt_limit) { + this.delta = this.maxdelta = maxdelta; + this.limit = goog.isDef(opt_limit) ? opt_limit : -1; + this.functionStack_ = []; +}; + + +/** + * Unified timer provider class + * Don't create instances of this class. Used the shared instance. + * @constructor + * @struct + */ +lime.ScheduleManager = function() { + + /** + * Array of registered functions + * @type {Array.} + * @private + */ + this.taskStack_ = [new lime.Task(0)]; + + /** + * Maximum update rate in ms. + * @type {number} + * @private + */ + this.displayRate_ = 1000 / 30; + + /** + * Timer last fire timestamp + * @type {number} + * @private + */ + this.lastRunTime_ = 0; + + /** + * @final + * @type {goog.async.AnimationDelay} + * @private + */ + this.animationDelay_ = new goog.async.AnimationDelay( + this.animationFrameHandler_, window, this); }; + /** * Handle iteration * @param {number} dt Delta time since last iteration. * @private */ -lime.scheduleManager.Task.prototype.step_ = function(dt) { - if (!this.functionStack_.length) return; - if (this.delta > dt) { - this.delta -= dt; +lime.Task.prototype.step_ = function(dt) { + if (!this.functionStack_.length) return; + if (this.delta > dt) { + this.delta -= dt; + } + else { + var delta = this.maxdelta + dt - this.delta; + this.delta = this.maxdelta - (dt - this.delta); + if (this.delta < 0) this.delta = 0; + var f; + var i = this.functionStack_.length; + while (--i >= 0) { + f = this.functionStack_[i]; + if (f && f[0] && goog.isFunction(f[1])) + (f[1]).call(f[2], delta); } - else { - var delta = this.maxdelta + dt - this.delta; - this.delta = this.maxdelta - (dt - this.delta); - if (this.delta < 0) this.delta = 0; - var f; - var i = this.functionStack_.length; - while (--i >= 0) { - f = this.functionStack_[i]; - if (f && f[0] && goog.isFunction(f[1])) - (f[1]).call(f[2], delta); - } - if (this.limit != -1) { - this.limit--; - if (this.limit == 0) { - lime.scheduleManager.unschedule(f[1], f[2]); - } - } + if (this.limit != -1) { + this.limit--; + if (this.limit == 0) { + lime.scheduleManager.unschedule(f[1], f[2]); + } } + } }; -lime.scheduleManager.taskStack_.push(new lime.scheduleManager.Task(0)); - -(function() { - var vendors = ['webkit', 'moz']; - for(var x = 0; x < vendors.length && !goog.global.requestAnimationFrame; ++x) { - goog.global.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - goog.global.cancelAnimationFrame = - goog.global[vendors[x]+'CancelAnimationFrame'] || goog.global[vendors[x]+'CancelRequestAnimationFrame']; - } -}()); - - -/** - * Whether to use requestAnimationFrame instead of timer events - * Exposed here so it could be disabled if needed. - * @type {boolean} - */ -lime.scheduleManager.USE_ANIMATION_FRAME = !!goog.global.requestAnimationFrame; /** * Returns maximum fire rate in ms. If you need FPS then use 1000/x - * @this {lime.scheduleManager} * @return {number} Display rate. */ -lime.scheduleManager.getDisplayRate = function() { - //todo: bad name - return this.displayRate_; +lime.ScheduleManager.prototype.getDisplayRate = function() { + //todo: bad name + return this.displayRate_; }; + /** * Sets maximum fire rate for the scheduler in ms. * If you have FPS then send 1000/x * Note that if animation frame methods are used browser chooses * max display rate and this value has no effect. - * @this {lime.scheduleManager} * @param {number} value New display rate. */ -lime.scheduleManager.setDisplayRate = function(value) { - this.displayRate_ = value; - if (this.active_) { - lime.scheduleManager.disable_(); - lime.scheduleManager.activate_(); - } +lime.ScheduleManager.prototype.setDisplayRate = function(value) { + this.displayRate_ = value; + if (this.animationDelay_.isActive()) { + lime.scheduleManager.disable_(); + lime.scheduleManager.activate_(); + } }; + /** * Schedule a function. Passed function will be called on every frame * with delta time from last run time - * @this {lime.scheduleManager} * @param {function(number)} f Function to be called. * @param {Object} context The context used when calling function. - * @param {lime.scheduleManager.Task=} opt_task Task object. + * @param {lime.Task=} opt_task Task object. */ -lime.scheduleManager.schedule = function(f, context, opt_task) { - var task = goog.isDef(opt_task) ? opt_task : this.taskStack_[0]; - goog.array.insert(task.functionStack_, [1, f, context]); - goog.array.insert(this.taskStack_, task); - if (!this.active_) { - lime.scheduleManager.activate_(); - } +lime.ScheduleManager.prototype.schedule = function(f, context, opt_task) { + var task = goog.isDef(opt_task) ? opt_task : this.taskStack_[0]; + goog.array.insert(task.functionStack_, [1, f, context]); + goog.array.insert(this.taskStack_, task); + if (!this.animationDelay_.isActive()) { + lime.scheduleManager.activate_(); + } }; + /** * Unschedule a function. For functions that have be previously scheduled - * @this {lime.scheduleManager} * @param {function(number)} f Function to be unscheduled. * @param {Object} context Context used when scheduling. */ -lime.scheduleManager.unschedule = function(f, context) { - var j = this.taskStack_.length; - while (--j >= 0) { - var task = this.taskStack_[j], - functionStack_ = task.functionStack_, - fi, i = functionStack_.length; - while (--i >= 0) { - fi = functionStack_[i]; - if (fi[1] == f && fi[2] == context) { - goog.array.remove(functionStack_, fi); - - } - } - if (functionStack_.length == 0 && j != 0) { - goog.array.remove(this.taskStack_, task); - } +lime.ScheduleManager.prototype.unschedule = function(f, context) { + var j = this.taskStack_.length; + while (--j >= 0) { + var task = this.taskStack_[j], + functionStack_ = task.functionStack_, + fi, i = functionStack_.length; + while (--i >= 0) { + fi = functionStack_[i]; + if (fi[1] == f && fi[2] == context) { + goog.array.remove(functionStack_, fi); + + } } - // if no more functions: stop timers - if (this.taskStack_.length == 1 && - this.taskStack_[0].functionStack_.length == 0) { - lime.scheduleManager.disable_(); + if (functionStack_.length == 0 && j != 0) { + goog.array.remove(this.taskStack_, task); } + } + // if no more functions: stop timers + if (this.taskStack_.length == 1 && + this.taskStack_[0].functionStack_.length == 0) { + lime.scheduleManager.disable_(); + } }; + /** * Start the internal timer functions - * @this {lime.scheduleManager} * @private */ -lime.scheduleManager.activate_ = function() { - if (this.active_) return; - - this.lastRunTime_ = goog.now(); - - if(lime.scheduleManager.USE_ANIMATION_FRAME && goog.global.requestAnimationFrame) { - // old mozilla - if(goog.global['mozRequestAnimationFrame'] && goog.userAgent.VERSION < 11) { - goog.global['mozRequestAnimationFrame'](); - this.beforePaintHandlerBinded_ = goog.bind(lime.scheduleManager.beforePaintHandler_,this); - goog.global.addEventListener('MozBeforePaint',this.beforePaintHandlerBinded_, false); - } - else { - this.animationFrameHandlerBinded_ = goog.bind(lime.scheduleManager.animationFrameHandler_,this); - goog.global.requestAnimationFrame(this.animationFrameHandlerBinded_); - } - } - else { - this.intervalID_ = setInterval(goog.bind(lime.scheduleManager.stepTimer_, this), - lime.scheduleManager.getDisplayRate()); - } - this.active_ = true; +lime.ScheduleManager.prototype.activate_ = function() { + if (this.animationDelay_.isActive()) return; + this.lastRunTime_ = goog.now(); + this.animationDelay_.start(); }; - /** * Stop interval timer functions - * @this {lime.scheduleManager} * @private */ -lime.scheduleManager.disable_ = function() { - if (!this.active_) return; - - if(lime.scheduleManager.USE_ANIMATION_FRAME && goog.global.requestAnimationFrame) { - // old mozilla - if(goog.global['mozRequestAnimationFrame'] && goog.userAgent.VERSION < 11) { - goog.global.removeEventListener('MozBeforePaint',this.beforePaintHandlerBinded_, false); - } - else { - goog.global.cancelAnimationFrame(this.animationFrameHandlerBinded_); - } - } - else { - clearInterval(this.intervalID_); - } - this.active_ = false; +lime.ScheduleManager.prototype.disable_ = function() { + this.animationDelay_.stop(); }; + /** * Webkit implemtation of requestAnimationFrame handler. - * @this {lime.scheduleManager} + * @param {number=} time * @private */ -lime.scheduleManager.animationFrameHandler_ = function(time){ - var performance = goog.global['performance'], - now; - if (performance && (now = performance['now'] || performance['webkitNow'])) { - time = performance['timing']['navigationStart'] + now.call(performance); - } - else if (!time) { - time = goog.now(); - } - var delta = time - this.lastRunTime_; - if (delta < 0) { // i0S6 reports relative to the device restart time. So first is negative. - delta = 1; - } - lime.scheduleManager.dispatch_(delta); - this.lastRunTime_ = time; - goog.global.requestAnimationFrame(this.animationFrameHandlerBinded_); -} +lime.ScheduleManager.prototype.animationFrameHandler_ = function(time) { + var performance = goog.global['performance']; + var now; + if (performance && (now = performance['now'] || performance['webkitNow'])) { + time = performance['timing']['navigationStart'] + now.call(performance); + } + else if (!time) { + time = goog.now(); + } + var delta = time - this.lastRunTime_; + if (delta < 0) { + // i0S6 reports relative to the device restart time. So first is negative. + delta = 1; + } + lime.scheduleManager.dispatch_(delta); + this.lastRunTime_ = time; + this.animationDelay_.start(); +}; + /** * Mozilla < 11 implementation of requestAnimationFrame handler. - * @this {lime.scheduleManager} + * @param {*} event event. * @private */ -lime.scheduleManager.beforePaintHandler_ = function(event){ - var delta = event.timeStamp - this.lastRunTime_; - lime.scheduleManager.dispatch_(delta); - this.lastRunTime_ = event.timeStamp; - goog.global['mozRequestAnimationFrame'](); -} +lime.ScheduleManager.prototype.beforePaintHandler_ = function(event) { + var delta = event.timeStamp - this.lastRunTime_; + lime.scheduleManager.dispatch_(delta); + this.lastRunTime_ = event.timeStamp; + goog.global['mozRequestAnimationFrame'](); +}; + /** * Timer events step function that delegates to other objects waiting - * @this {lime.scheduleManager} * @private */ -lime.scheduleManager.stepTimer_ = function() { - var t; - var curTime = goog.now(); - var delta = curTime - this.lastRunTime_; - if (delta < 0) delta = 1; - lime.scheduleManager.dispatch_(delta); - this.lastRunTime_ = curTime; +lime.ScheduleManager.prototype.stepTimer_ = function() { + var t; + var curTime = goog.now(); + var delta = curTime - this.lastRunTime_; + if (delta < 0) delta = 1; + lime.scheduleManager.dispatch_(delta); + this.lastRunTime_ = curTime; }; + /** * Call all scheduled tasks - * @this {lime.scheduleManager} * @param {number} delta Milliseconds since last run. * @private */ -lime.scheduleManager.dispatch_ = function(delta){ - - - var stack = this.taskStack_.slice() - var i = stack.length; - while (--i >= 0) stack[i].step_(delta); - //hack to deal with FF4 CSS transformation issue https://bugzilla.mozilla.org/show_bug.cgi?id=637597 - if(lime.transformSet_ == 1 && (/Firefox\/18./).test(goog.userAgent.getUserAgentString()) && - !lime.FF4_USE_HW_ACCELERATION){ - if(lime.scheduleManager.odd_){ - document.body.style['MozTransform'] = ''; - lime.scheduleManager.odd_=0; - } - else { - document.body.style['MozTransform'] = 'scale(1,1)'; - lime.scheduleManager.odd_=1; - } - lime.transformSet_=0; - } +lime.ScheduleManager.prototype.dispatch_ = function(delta) { + + for (var i = 0; i < this.taskStack_.length; ++i) { + this.taskStack_[i].step_(delta); + } + }; + /** * Change director's activity. Used for pausing updates when director is paused - * @this {lime.scheduleManager} * @param {lime.Director} director Director. * @param {boolean} value Active or inactive? */ -lime.scheduleManager.changeDirectorActivity = function(director, value) { - var t, context, f, d, i, - j = this.taskStack_.length; - while (--j >= 0) { - - t = this.taskStack_[j]; - i = t.functionStack_.length; - while (--i >= 0) { - f = t.functionStack_[i]; - context = f[2]; - if (goog.isFunction(context.getDirector)) { - d = context.getDirector(); - if (d == director) { - f[0] = value; - } - } +lime.ScheduleManager.prototype.changeDirectorActivity = function( + director, value) { + var t, context, f, d, i, + j = this.taskStack_.length; + while (--j >= 0) { + + t = this.taskStack_[j]; + i = t.functionStack_.length; + while (--i >= 0) { + f = t.functionStack_[i]; + context = f[2]; + if (goog.isFunction(context.getDirector)) { + d = context.getDirector(); + if (d == director) { + f[0] = value; } + } } + } }; + /** * Set up function to be called once after a delay * @param {function(number)} f Function to be called. * @param {Object} context Context used when calling object. * @param {number} delay Delay before calling. */ -lime.scheduleManager.callAfter = function(f, context, delay) { - lime.scheduleManager.scheduleWithDelay(f, context, delay, 1); +lime.ScheduleManager.prototype.callAfter = function(f, context, delay) { + this.scheduleWithDelay(f, context, delay, 1); }; + /** * Set up function to be called repeatedly after a delay * @param {function(number)} f Function to be called. * @param {Object} context Context used when calling object. * @param {number} delay Delay before calling. * @param {number=} opt_limit Number of times to call. - * @this {lime.scheduleManager} */ -lime.scheduleManager.scheduleWithDelay = function(f, context, - delay, opt_limit) { - var task = new lime.scheduleManager.Task(delay, opt_limit); - lime.scheduleManager.schedule(f, context, task); +lime.ScheduleManager.prototype.scheduleWithDelay = function(f, context, delay, + opt_limit) { + var task = new lime.Task(delay, opt_limit); + lime.scheduleManager.schedule(f, context, task); }; + + +/** + * @final + * @type {!lime.ScheduleManager} + */ +lime.scheduleManager = new lime.ScheduleManager(); diff --git a/lime/src/shape/canvascontext.js b/lime/src/shape/canvascontext.js index 0ac4d785..e66b89c6 100644 --- a/lime/src/shape/canvascontext.js +++ b/lime/src/shape/canvascontext.js @@ -6,14 +6,15 @@ goog.require('goog.array'); goog.require('goog.math.Coordinate'); goog.require('lime.Renderer.CANVAS.SPRITE'); goog.require('lime.Sprite'); +goog.require('lime.Polygon'); /** * Custom Canvas context * @constructor - * @extends lime.Sprite + * @extends {lime.Sprite} */ lime.CanvasContext = function() { - lime.Sprite.call(this); + goog.base(this); }; goog.inherits(lime.CanvasContext, lime.Sprite); @@ -40,7 +41,7 @@ lime.CanvasContext.prototype.draw = goog.nullFunction; lime.Renderer.CANVAS.CANVASCONTEXT.draw = function(context) { lime.Renderer.CANVAS.SPRITE.draw.call(this, context); - + this.draw(context); }; diff --git a/lime/src/shape/circle.js b/lime/src/shape/circle.js index 96867341..f6effa02 100644 --- a/lime/src/shape/circle.js +++ b/lime/src/shape/circle.js @@ -2,94 +2,98 @@ goog.provide('lime.Circle'); goog.provide('lime.Renderer.CANVAS.CIRCLE'); goog.provide('lime.Renderer.DOM.CIRCLE'); - goog.require('lime.Renderer.CANVAS.SPRITE'); goog.require('lime.Renderer.DOM.SPRITE'); goog.require('lime.Sprite'); goog.require('lime.style'); + + /** * Circle or ellipse shaped tectured object * @constructor - * @extends lime.Sprite + * @extends {lime.Sprite} */ lime.Circle = function() { - lime.Sprite.call(this); - - + goog.base(this); }; goog.inherits(lime.Circle, lime.Sprite); + /** * Common name for circle objects * @type {string} */ lime.Circle.prototype.id = 'circle'; + /** @inheritDoc */ lime.Circle.prototype.supportedRenderers = [ - lime.Renderer.DOM.SPRITE.makeSubRenderer(lime.Renderer.DOM.CIRCLE), - lime.Renderer.CANVAS.SPRITE.makeSubRenderer(lime.Renderer.CANVAS.CIRCLE) + lime.Renderer.DOM.SPRITE.makeSubRenderer(lime.Renderer.DOM.CIRCLE), + lime.Renderer.CANVAS.SPRITE.makeSubRenderer(lime.Renderer.CANVAS.CIRCLE) ]; + /** * @inheritDoc */ lime.Circle.prototype.hitTest = function(e) { - var coord = this.screenToLocal(e.screenPosition); - var s = this.size_, ap = this.anchorPoint_, - a = s.width * .5, b = s.height * .5, - x = coord.x - s.width * (.5 - ap.x), - y = coord.y - s.height * (.5 - ap.y); - - if ((x * x) / (a * a) + (y * y) / (b * b) < 1) { - e.position = coord; - return true; - } - return false; + var coord = this.screenToLocal(e.screenPosition); + var s = this.size_, ap = this.anchorPoint_, + a = s.width * .5, b = s.height * .5, + x = coord.x - s.width * (.5 - ap.x), + y = coord.y - s.height * (.5 - ap.y); + + if ((x * x) / (a * a) + (y * y) / (b * b) < 1) { + e.position = coord; + return true; + } + return false; }; + /** * @inheritDoc * @this {lime.Circle} */ lime.Renderer.DOM.CIRCLE.draw = function(el) { - var size = this.getSize(); + var size = this.getSize(); - lime.Renderer.DOM.SPRITE.draw.call(this, el); + lime.Renderer.DOM.SPRITE.draw.call(this, el); - lime.style.setBorderRadius(el, size.width * .5, size.height * .5); + lime.style.setBorderRadius(el, size.width * .5, size.height * .5); // el.style['-webkit-border-radius'] = el.style['MozBorderRadius'] = // size.width*.5+'px / '+size.height*.5+'px'; }; + /** * @inheritDoc * @this {lime.Circle} */ lime.Renderer.CANVAS.CIRCLE.draw = function(context) { - // console.log('draw'); - var size = this.getSize(), fill = this.fill_,ap = this.getAnchorPoint(); - var frame = this.getFrame(); - var cx = (frame.right - frame.left) * .5; - var cy = (frame.bottom - frame.top) * .5; - context.save(); - context.save(); - context.scale(cx, cy); - context.translate(1-2*ap.x,1-2*ap.y); - context.beginPath(); - context.arc(0, 0, 1, 0, 2 * Math.PI, false); - context.closePath(); - context.restore(); - context.clip(); - - lime.Renderer.CANVAS.SPRITE.draw.call(this, context); - - if(this.stroke_){ - context.lineWidth*=2; - context.stroke(); - } - - context.restore(); + // console.log('draw'); + var ap = this.getAnchorPoint(); + var frame = this.getFrame(); + var cx = (frame.right - frame.left) * .5; + var cy = (frame.bottom - frame.top) * .5; + context.save(); + context.save(); + context.scale(cx, cy); + context.translate(1 - 2 * ap.x, 1 - 2 * ap.y); + context.beginPath(); + context.arc(0, 0, 1, 0, 2 * Math.PI, false); + context.closePath(); + context.restore(); + context.clip(); + + lime.Renderer.CANVAS.SPRITE.draw.call(this, context); + + if (this.getStroke()) { + context.lineWidth *= 2; + context.stroke(); + } + + context.restore(); }; diff --git a/lime/src/shape/label.js b/lime/src/shape/label.js index c988e1a5..11ef493b 100644 --- a/lime/src/shape/label.js +++ b/lime/src/shape/label.js @@ -2,49 +2,52 @@ goog.provide('lime.Label'); goog.provide('lime.Renderer.CANVAS.LABEL'); goog.provide('lime.Renderer.DOM.LABEL'); - +goog.require('goog.style'); goog.require('lime.Renderer.CANVAS.SPRITE'); goog.require('lime.Renderer.DOM.SPRITE'); goog.require('lime.Sprite'); -goog.require('goog.style'); + + /** * Display object for text - * @param {string} txt Text contents of the label. + * @param {string=} txt Text contents of the label. * @constructor - * @extends lime.Sprite + * @extends {lime.Sprite} */ lime.Label = function(txt) { - lime.Sprite.call(this); + goog.base(this); - this.setMultiline(false); - this.setText(txt); + this.setMultiline(false); + this.setText(txt + ''); - this.setFontFamily(lime.Label.defaultFont); - this.setFontSize(14); - this.setFontColor('#000'); - this.setAlign('center'); - this.setFontWeight('400'); + this.setFontFamily(lime.Label.defaultFont); + this.setFontSize(14); + this.setFontColor('#000'); + this.setAlign('center'); + this.setFontWeight('400'); - this.setPadding(0); + this.setPadding(0); - this.setLineHeight(1.15); + this.setLineHeight(1.15); - this.setShadow(null); + this.setShadow(null); - this.setFill(255, 255, 255, 0); + this.setFill(255, 255, 255, 0); - this.setStyle("normal"); + this.setStyle('normal'); }; goog.inherits(lime.Label, lime.Sprite); + /** * Common name for label objects * @type {string} */ lime.Label.prototype.id = 'label'; + /** * Default Font name for labels * @type {string} @@ -53,27 +56,27 @@ lime.Label.defaultFont = 'Arial'; /** @inheritDoc */ lime.Label.prototype.supportedRenderers = [ - lime.Renderer.DOM.SPRITE.makeSubRenderer(lime.Renderer.DOM.LABEL), - lime.Renderer.CANVAS.SPRITE.makeSubRenderer(lime.Renderer.CANVAS.LABEL) + lime.Renderer.DOM.SPRITE.makeSubRenderer(lime.Renderer.DOM.LABEL), + lime.Renderer.CANVAS.SPRITE.makeSubRenderer(lime.Renderer.CANVAS.LABEL) ]; (function() { -var mContext; + var mContext; -/** - * Measure text contents of the label - * @return {goog.math.Size} size of the text. - */ -lime.Label.prototype.measureText = function() { + /** + * Measure text contents of the label + * @return {goog.math.Size} size of the text. + */ + lime.Label.prototype.measureText = function() { if (!goog.isDef(mContext)) { - var cvs = document.createElement('canvas'); - mContext = cvs.getContext('2d'); + var cvs = document.createElement('canvas'); + mContext = cvs.getContext('2d'); } var lh = this.getLineHeight() * this.getFontSize(); if (this.getMultiline()) { - lh *= goog.string.trim(this.text_).split('\n').length + lh *= goog.string.trim(this.text_).split('\n').length; } mContext.font = this.getStyle() + ' ' + this.getFontWeight() + ' ' + this.getFontSize() + 'px ' + this.getFontFamily(); @@ -81,23 +84,24 @@ lime.Label.prototype.measureText = function() { var w = goog.userAgent.WEBKIT ? metrics.width : metrics.width + 1; if (lime.userAgent.IOS5) - w += 1; + w += 1; - var stroke = this.stroke_?this.stroke_.width_:0; + var stroke = this.getStroke() ? this.getStroke().width_ : 0; return new goog.math.Size( - this.padding_[1] + this.padding_[3] + w + stroke*2, - this.padding_[0] + this.padding_[2] + lh + stroke*2 + this.padding_[1] + this.padding_[3] + w + stroke * 2, + this.padding_[0] + this.padding_[2] + lh + stroke * 2 ); -}; + }; })(); + /** @inheritDoc */ lime.Label.prototype.getSize = function() { - var size = lime.Node.prototype.getSize.call(this); - if (!size || (!size.width && !size.height)) { - return this.measureText(); - } - return size; + var size = lime.Node.prototype.getSize.call(this); + if (!size || (!size.width && !size.height)) { + return this.measureText(); + } + return size; }; /** @@ -105,30 +109,32 @@ lime.Label.prototype.getSize = function() { * @return {string} Text contents. */ lime.Label.prototype.getText = function() { - return this.text_; + return this.text_; }; + /** * Set label text * @param {string} txt New text contents. * @return {lime.Label} object itself. */ lime.Label.prototype.setText = function(txt) { - this.text_ = txt + ''; - this.setDirty(lime.Dirty.CONTENT); - delete this.words_; - return this; + this.text_ = txt + ''; + this.setDirty(lime.Dirty.CONTENT); + this.words_ = null; + return this; }; + /** * Set label text - * @param {string} txt New style contents. + * @param {string} style New style contents. * @return {lime.Label} object itself. */ lime.Label.prototype.setStyle = function(style) { - this.style_ = style; - this.setDirty(lime.Dirty.FONT); - return this; + this.style_ = style; + this.setDirty(lime.Dirty.FONT); + return this; }; @@ -137,7 +143,7 @@ lime.Label.prototype.setStyle = function(style) { * @return {string} Style name string. */ lime.Label.prototype.getStyle = function() { - return this.style_; + return this.style_; }; @@ -146,7 +152,7 @@ lime.Label.prototype.getStyle = function() { * @return {string} Font name string. */ lime.Label.prototype.getFontFamily = function() { - return this.fontFamily_; + return this.fontFamily_; }; /** @@ -155,76 +161,84 @@ lime.Label.prototype.getFontFamily = function() { * @return {lime.Label} object itself. */ lime.Label.prototype.setFontWeight = function(value) { - this.fontWeight_ = value; - this.setDirty(lime.Dirty.FONT); - return this; + this.fontWeight_ = value; + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Returns font used to draw the label * @return {string} Font name string. */ lime.Label.prototype.getFontWeight = function() { - return this.fontWeight_; + return this.fontWeight_; }; + /** * Set font name * @param {string} value New font family string. * @return {lime.Label} object itself. */ lime.Label.prototype.setFontFamily = function(value) { - this.fontFamily_ = value; - this.setDirty(lime.Dirty.FONT); - return this; + this.fontFamily_ = value; + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Returns font size in pixels * @return {number} Font size in px. */ lime.Label.prototype.getFontSize = function() { - return this.fontSize_; + return this.fontSize_; }; + /** * Set the font size in pixels * @param {number} value New font size in px. * @return {lime.Label} object itself. */ lime.Label.prototype.setFontSize = function(value) { - this.fontSize_ = value; - this.setDirty(lime.Dirty.FONT); - return this; + this.fontSize_ = value; + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Returns font color as string * @return {string} Font color. */ lime.Label.prototype.getFontColor = function() { - return this.fontColor_; + return this.fontColor_; }; + /** * Sets the font color. Accepts #hex, rgb(), rgba() or plain color name. * @param {string} value New color. * @return {lime.Label} object itself. */ lime.Label.prototype.setFontColor = function(value) { - this.fontColor_ = value; - this.setDirty(lime.Dirty.FONT); - return this; + this.fontColor_ = value; + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Return padding box around the text contents * @return {goog.math.Box} padding box. */ lime.Label.prototype.getPadding = function() { - return this.padding_; + return this.padding_; }; + /** * Set new padding box around text contents. * @param {number} top Top padding. @@ -233,25 +247,25 @@ lime.Label.prototype.getPadding = function() { * @param {number=} opt_left Left padding. * @return {lime.Label} object itself. */ -lime.Label.prototype.setPadding = function(top, opt_right, - opt_bottom, opt_left) { +lime.Label.prototype.setPadding = function(top, opt_right, opt_bottom, opt_left) { - var val = [top, top, top, top]; - if (goog.isDef(opt_right)) { - val[1] = val[3] = opt_right; - } - if (goog.isDef(opt_bottom)) { - val[2] = opt_bottom; - } - if (goog.isDef(opt_left)) { - val[3] = opt_left; - } - this.padding_ = val; + var val = [top, top, top, top]; + if (goog.isDef(opt_right)) { + val[1] = val[3] = opt_right; + } + if (goog.isDef(opt_bottom)) { + val[2] = opt_bottom; + } + if (goog.isDef(opt_left)) { + val[3] = opt_left; + } + this.padding_ = val; - this.setDirty(lime.Dirty.FONT); - return this; + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Sets the line height used in multiline strings. Can be in pixels * or factor from font size. @@ -259,50 +273,56 @@ lime.Label.prototype.setPadding = function(top, opt_right, * @param {boolean=} opt_absolute If height is in pixels. */ lime.Label.prototype.setLineHeight = function(value, opt_absolute) { - this.lineHeightAbsolute_ = opt_absolute || false; - this.lineHeight_ = value; - return this; + this.lineHeightAbsolute_ = opt_absolute || false; + this.lineHeight_ = value; + return this; }; + /** * Return line height as a factor from font size * @return {number} Line height. */ lime.Label.prototype.getLineHeight = function() { - var shadowExtra = Math.abs(this.getShadowOffset().y) + this.shadowBlur_ * 2; - return this.lineHeightAbsolute_ ? - (this.lineHeight_ + shadowExtra) / this.getFontSize() : this.lineHeight_ + shadowExtra / this.getFontSize(); + var shadowExtra = Math.abs(this.getShadowOffset().y) + this.shadowBlur_ * 2; + return this.lineHeightAbsolute_ ? + (this.lineHeight_ + shadowExtra) / this.getFontSize() : this.lineHeight_ + shadowExtra / this.getFontSize(); }; + /** * Returns alignment value * @return {string} Alignement. */ lime.Label.prototype.getAlign = function() { - return this.align_; + return this.align_; }; + /** * Sets label alignment. Accepts normal strings as left,center,right * @param {string} value New alignment value. * @return {lime.Label} object itself. */ lime.Label.prototype.setAlign = function(value) { - this.align_ = value; - this.setDirty(lime.Dirty.FONT); - return this; + this.align_ = value; + this.setDirty(lime.Dirty.FONT); + return this; }; + lime.Label.prototype.getMultiline = function() { - return this.multiline_; -} + return this.multiline_; +}; + lime.Label.prototype.setMultiline = function(bool) { - this.multiline_ = bool; - this.setDirty(lime.Dirty.CONTENT); - return this; + this.multiline_ = bool; + this.setDirty(lime.Dirty.CONTENT); + return this; }; + /** * Shorthand for adding shadow to a label. Calling setShadow(null) removes the shadow. * @param {?string} color Shadow color. @@ -311,74 +331,80 @@ lime.Label.prototype.setMultiline = function(bool) { * @param {number=} opt_offsetY Shadow offset in Y axis. * @return {lime.Label} object itself. */ -lime.Label.prototype.setShadow = function(color, opt_blur, opt_offsetX, opt_offsetY){ - // provide method to reset the shadow - if(arguments.length == 1 && goog.isNull(color)){ - this.setShadowColor('#ccc'); //default color - this.setShadowBlur(0); - this.setShadowOffset(0,0); - } - else if(arguments.length == 2) { - this.setShadowColor(/** @type {!string}*/(color)); - this.setShadowBlur(/** @type {!number} */(opt_blur)); - this.setShadowOffset(new goog.math.Vec2(0,0)); - } - else if(arguments.length == 3) { - this.setShadowColor(/** @type {!string}*/(color)); - this.setShadowBlur(/** @type {!number} */(opt_blur)); - this.setShadowOffset(/** @type {!goog.math.Vec2} */(opt_offsetX)); - } - else { - this.setShadowColor(/** @type {!string}*/(color)); - this.setShadowBlur(/** @type {!number} */(opt_blur)); - this.setShadowOffset(/** @type {!(number|goog.math.Vec2)} */(opt_offsetX), opt_offsetY); - } - this.setDirty(lime.Dirty.FONT); - return this; +lime.Label.prototype.setShadow = function(color, opt_blur, opt_offsetX, opt_offsetY) { + // provide method to reset the shadow + if (arguments.length == 1 && goog.isNull(color)) { + this.setShadowColor('#ccc'); //default color + this.setShadowBlur(0); + this.setShadowOffset(0, 0); + } + else if (arguments.length == 2) { + this.setShadowColor(/** @type {!string}*/(color)); + this.setShadowBlur(/** @type {!number} */(opt_blur)); + this.setShadowOffset(new goog.math.Vec2(0, 0)); + } + else if (arguments.length == 3) { + this.setShadowColor(/** @type {!string}*/(color)); + this.setShadowBlur(/** @type {!number} */(opt_blur)); + this.setShadowOffset(/** @type {!goog.math.Vec2} */(opt_offsetX)); + } + else { + this.setShadowColor(/** @type {!string}*/(color)); + this.setShadowBlur(/** @type {!number} */(opt_blur)); + this.setShadowOffset(/** @type {!(number|goog.math.Vec2)} */(opt_offsetX), opt_offsetY); + } + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Returns true if the label has a shadow. * @private */ -lime.Label.prototype.hasShadow_ = function(){ - return this.shadowBlur_ || this.shadowOffset_.x || this.shadowOffset_.y; +lime.Label.prototype.hasShadow_ = function() { + return this.shadowBlur_ || this.shadowOffset_.x || this.shadowOffset_.y; }; + /** * Returns shadow color * @return {string} shadow color. */ lime.Label.prototype.getShadowColor = function() { - return this.shadowColor_; + return this.shadowColor_; }; + /** * Returns shadow offset in px. * @return {goog.math.Vec2} shadow offset in px. */ lime.Label.prototype.getShadowOffset = function() { - return this.shadowOffset_; + return this.shadowOffset_; }; + /** * Set the shadow color. * @param {string} color The shadow color. */ -lime.Label.prototype.setShadowColor = function(color){ - this.shadowColor_ = color; - return this; +lime.Label.prototype.setShadowColor = function(color) { + this.shadowColor_ = color; + return this; }; + /** * Set the shadow blur radius. * @param {number} radius The shadow blur radius. */ -lime.Label.prototype.setShadowBlur = function(radius){ - this.shadowBlur_ = radius; - return this; +lime.Label.prototype.setShadowBlur = function(radius) { + this.shadowBlur_ = radius; + return this; }; + /** * Sets label shadow offset in px. * @param {(goog.math.Vec2|number)} offset Shadow offset. @@ -386,24 +412,26 @@ lime.Label.prototype.setShadowBlur = function(radius){ * @return {lime.Label} object itself. */ lime.Label.prototype.setShadowOffset = function(offset, opt_offsetY) { - if (arguments.length == 2) { - this.shadowOffset_ = new goog.math.Vec2(arguments[0], arguments[1]); - } - else { - this.shadowOffset_ = offset; - } - this.setDirty(lime.Dirty.FONT); - return this; + if (arguments.length == 2) { + this.shadowOffset_ = new goog.math.Vec2(arguments[0], arguments[1]); + } + else { + this.shadowOffset_ = offset; + } + this.setDirty(lime.Dirty.FONT); + return this; }; + /** * Returns shadow blur radius in px. * @return {number} shadow blur radius in px. */ lime.Label.prototype.getShadowBlur = function() { - return this.shadowBlur_; + return this.shadowBlur_; }; + /** * * Break text into array of line breakable words @@ -416,19 +444,20 @@ lime.Label.prototype.calcWordsArray = function() { var breaks = this.text_.match(regexp); var st = 0; if (breaks) - for (var i = 0; i < breaks.length; i++) { + for (var i = 0; i < breaks.length; i++) { var b = breaks[i]; var ibreak = this.text_.indexOf(b, st); var wlen = ibreak + b.length; words.push(this.text_.substring(st, wlen)); st = wlen; - } + } if (st != len) { - words.push(this.text_.substring(st, len)); + words.push(this.text_.substring(st, len)); } return words; }; + /** * Wrap text on words array to lines based on current * font size and given maximum width. @@ -437,45 +466,46 @@ lime.Label.prototype.calcWordsArray = function() { * @return {Array.} Lines of text. */ lime.Label.prototype.wrapText = function(context, width) { - var lines = [], line = '', words = this.words_, metrics; - for (var i = 0; i < words.length; i++) { - var breaks = 0; - if (this.multiline_) { - var matches = words[i].match(/\n/g) - if (matches) { - breaks = matches.length - } - } - if (line == '') { - line = words[i]; - } - else { - metrics = context.measureText(goog.string.trim(line + words[i])); - if (metrics.width > width) { - lines.push(goog.string.trim(line)); - //breaks-- - line = words[i]; - } - else { - line += words[i]; - } - } - for (var j = 0; j < breaks; j++) { - lines.push(goog.string.trim(line)); - line = '' - } + var lines = [], line = '', words = this.words_, metrics; + for (var i = 0; i < words.length; i++) { + var breaks = 0; + if (this.multiline_) { + var matches = words[i].match(/\n/g); + if (matches) { + breaks = matches.length; + } + } + if (line == '') { + line = words[i]; } - lines.push(line); - return lines; + else { + metrics = context.measureText(goog.string.trim(line + words[i])); + if (metrics.width > width) { + lines.push(goog.string.trim(line)); + //breaks-- + line = words[i]; + } + else { + line += words[i]; + } + } + for (var j = 0; j < breaks; j++) { + lines.push(goog.string.trim(line)); + line = ''; + } + } + lines.push(line); + return lines; }; + /** @inheritDoc */ -lime.Label.prototype.update = function(){ +lime.Label.prototype.update = function() { - if(this.getDirty() & lime.Dirty.CONTENT) - delete this.lastDrawnWidth_; + if (this.getDirty() & lime.Dirty.CONTENT) + delete this.lastDrawnWidth_; - lime.Node.prototype.update.apply(this,arguments); + lime.Node.prototype.update.apply(this, arguments); }; @@ -484,98 +514,102 @@ lime.Label.prototype.update = function(){ * @this {lime.Label} */ lime.Renderer.DOM.LABEL.draw = function(el) { - lime.Renderer.DOM.SPRITE.draw.call(this, el); - - var style = el.style; - if (this.dirty_ & lime.Dirty.CONTENT) { - if (this.getMultiline()) { - el.innerHTML = goog.string.htmlEscape(this.text_).replace(/\n/g, '
') - } - else goog.dom.setTextContent(el, this.text_); - } - if (this.dirty_ & lime.Dirty.FONT) { - style['lineHeight'] = this.getLineHeight(); - style['padding'] = goog.array.map(this.padding_,function(p){return p * this.getRelativeQuality();},this).join('px ') + 'px'; - style['color'] = this.getFontColor(); - style['fontFamily'] = this.getFontFamily(); - style['fontSize'] = this.getFontSize()*this.getRelativeQuality() + 'px'; - style['fontWeight'] = this.getFontWeight(); - style['textAlign'] = this.getAlign(); - style['font-style'] = this.getStyle(); - style['textShadow'] = this.hasShadow_() ? this.getShadowColor() + ' ' + this.getShadowOffset().x + 'px ' + this.getShadowOffset().y + 'px ' + this.getShadowBlur() + 'px' : ''; + lime.Renderer.DOM.SPRITE.draw.call(this, el); + + var style = el.style; + if (this.dirty_ & lime.Dirty.CONTENT) { + if (this.getMultiline()) { + el.innerHTML = goog.string.htmlEscape(this.text_).replace(/\n/g, '
'); } + else goog.dom.setTextContent(el, this.text_); + } + if (this.dirty_ & lime.Dirty.FONT) { + style['lineHeight'] = this.getLineHeight(); + style['padding'] = goog.array.map(this.padding_, function(p) { + return p * this.getRelativeQuality(); + }, this).join('px ') + 'px'; + style['color'] = this.getFontColor(); + style['fontFamily'] = this.getFontFamily(); + style['fontSize'] = this.getFontSize() * this.getRelativeQuality() + 'px'; + style['fontWeight'] = this.getFontWeight(); + style['textAlign'] = this.getAlign(); + style['font-style'] = this.getStyle(); + style['textShadow'] = this.hasShadow_() ? this.getShadowColor() + ' ' + this.getShadowOffset().x + 'px ' + this.getShadowOffset().y + 'px ' + this.getShadowBlur() + 'px' : ''; + } }; + /** * @inheritDoc * @this {lime.Label} */ lime.Renderer.CANVAS.LABEL.draw = function(context) { - lime.Renderer.CANVAS.SPRITE.draw.call(this, context); + lime.Renderer.CANVAS.SPRITE.draw.call(this, context); - var frame = this.getFrame(), - width = -frame.left - this.padding_[3] + frame.right - this.padding_[1] + Math.abs(this.getShadowOffset().x) + Math.abs(this.getShadowBlur() * 2), - dowrap = 0; + var frame = this.getFrame(), + width = -frame.left - this.padding_[3] + frame.right - this.padding_[1] + Math.abs(this.getShadowOffset().x) + Math.abs(this.getShadowBlur() * 2), + dowrap = 0; - if (!this.words_) { - this.words_ = this.calcWordsArray(); - dowrap = 1; - } + if (!this.words_) { + this.words_ = this.calcWordsArray(); + dowrap = 1; + } - var stroke = this.stroke_?this.stroke_.width_:0; + var stroke = this.getStroke() ? this.getStroke().width_ : 0; - context.save(); - var align = this.getAlign(); - if (align == 'left') { - context.translate(frame.left + this.padding_[3]+stroke, - frame.top + this.padding_[0]+stroke); - } - else if (align == 'right') { - context.translate(frame.right - this.padding_[1]-stroke, - frame.top + this.padding_[0]+stroke); - } - else if (align == 'center') { - context.translate( - (frame.left + this.padding_[3] + - frame.right - this.padding_[1]) * .5, - frame.top + this.padding_[0]+stroke); - } + context.save(); + var align = this.getAlign(); + if (align == 'left') { + context.translate(frame.left + this.padding_[3] + stroke, + frame.top + this.padding_[0] + stroke); + } + else if (align == 'right') { + context.translate(frame.right - this.padding_[1] - stroke, + frame.top + this.padding_[0] + stroke); + } + else if (align == 'center') { + context.translate( + (frame.left + this.padding_[3] + + frame.right - this.padding_[1]) * .5, + frame.top + this.padding_[0] + stroke); + } - var lh = this.getLineHeight(); + var lh = this.getLineHeight(); - context.fillStyle = this.getFontColor(); - context.font = this.getStyle() + ' '+ this.getFontWeight() + ' ' + this.getFontSize() + - 'px/' + lh + ' ' + this.getFontFamily(); - context.textAlign = align; - context.textBaseline = 'top'; + context.fillStyle = this.getFontColor(); + context.font = this.getStyle() + ' ' + this.getFontWeight() + ' ' + this.getFontSize() + + 'px/' + lh + ' ' + this.getFontFamily(); + context.textAlign = align; + context.textBaseline = 'top'; - if(this.hasShadow_()){ - context.shadowColor = this.getShadowColor(); - context.shadowOffsetX = this.getShadowOffset().x; - context.shadowOffsetY = this.getShadowOffset().y; - context.shadowBlur = this.getShadowBlur(); - } + if (this.hasShadow_()) { + context.shadowColor = this.getShadowColor(); + context.shadowOffsetX = this.getShadowOffset().x; + context.shadowOffsetY = this.getShadowOffset().y; + context.shadowBlur = this.getShadowBlur(); + } - if(dowrap || width!=this.lastDrawnWidth_){ - this.lines_ = this.wrapText(context, width - 2 * stroke); - this.lastDrawnWidth_ = width; - } + if (dowrap || width != this.lastDrawnWidth_) { + this.lines_ = this.wrapText(context, width - 2 * stroke); + this.lastDrawnWidth_ = width; + } - if (this.lines_) { - var lhpx = lh * this.getFontSize(), - offsetY = (goog.isDef(this.getShadowBlur()) ? Math.abs(this.getShadowBlur()) : 0) + - (goog.isDef(this.getShadowOffset()) ? Math.abs(this.getShadowOffset().y) / 2 : 0), - offsetX = 0; - lhpx = goog.userAgent.WEBKIT ? Math.floor(lhpx) : Math.round(lhpx); - for (var i = 0; i < this.lines_.length; i++) { - context.fillText(this.lines_[i], offsetX, lhpx * i + offsetY - 0.5); - } + if (this.lines_) { + var lhpx = lh * this.getFontSize(), + offsetY = (goog.isDef(this.getShadowBlur()) ? Math.abs(this.getShadowBlur()) : 0) + + (goog.isDef(this.getShadowOffset()) ? Math.abs(this.getShadowOffset().y) / 2 : 0), + offsetX = 0; + lhpx = goog.userAgent.WEBKIT ? Math.floor(lhpx) : Math.round(lhpx); + for (var i = 0; i < this.lines_.length; i++) { + context.fillText(this.lines_[i], offsetX, lhpx * i + offsetY - 0.5); } + } - context.restore(); + context.restore(); }; + /** * Helper function to install new font file so you can use * the font name as font-family. @@ -584,7 +618,29 @@ lime.Renderer.CANVAS.LABEL.draw = function(context) { * @param {string=} opt_format Font format. */ lime.Label.installFont = function(name, fileurl, opt_format) { - var format = opt_format || 'truetype'; - goog.style.installStyles('@font-face{font-family: "' + name + - '";src: url(' + fileurl + ') format("' + format + '");})'); + var format = opt_format || 'truetype'; + goog.style.installStyles('@font-face{font-family: "' + name + + '";src: url(' + fileurl + ') format("' + format + '");})'); +}; + + +/** + * + * @param {string} txt + * @constructor + * @extends {lime.Label} + */ +lime.DroppableLabel = function(txt) { + goog.base(this, txt); + this.setSize(150, 150).setFill('#00f'); +}; +goog.inherits(lime.DroppableLabel, lime.Label); + + +lime.DroppableLabel.prototype.showDropHighlight = function() { + this.runAction(new lime.animation.FadeTo(.6).setDuration(.3)); +}; + +lime.DroppableLabel.prototype.hideDropHighlight = function() { + this.runAction(new lime.animation.FadeTo(1).setDuration(.1)); }; diff --git a/lime/src/shape/polygon.js b/lime/src/shape/polygon.js index 58a91c28..90ce676c 100644 --- a/lime/src/shape/polygon.js +++ b/lime/src/shape/polygon.js @@ -9,12 +9,12 @@ goog.require('lime.Sprite'); /** * Polygon shaped textured object - * @param {Array.} points Polygon points. + * @param {Array.} points Polygon points. * @constructor - * @extends lime.Sprite + * @extends {lime.Sprite} */ lime.Polygon = function(points) { - lime.Sprite.call(this); + goog.base(this); this.setPoints.apply(this, arguments); }; @@ -41,7 +41,7 @@ lime.Polygon.prototype.getPoints = function() { /** * Sets points that define the polygon. Also accepts floats. - * @param {Array.} points Polygon points. + * @param {Array.} points Polygon points. * @return {lime.Polygon} object itself. */ lime.Polygon.prototype.setPoints = function(points) { @@ -52,12 +52,12 @@ lime.Polygon.prototype.setPoints = function(points) { /** * Adds points to current polygon points. Also accepts floats. - * @param {Array.} points Polygon points. + * @param {Array.} points Polygon points. * @return {lime.Polygon} object itself. */ lime.Polygon.prototype.addPoints = function(points) { - var points = goog.array.toArray(arguments); - if (!points.length) return; + points = goog.array.toArray(arguments); + if (!points.length) return null; if (points[0] instanceof goog.math.Coordinate) { goog.array.forEach(points, function(p) { @@ -136,8 +136,8 @@ lime.Polygon.prototype.hitTest = function(e) { lime.Renderer.CANVAS.POLYGON.draw = function(context) { - var size = this.getSize(), fill = this.fill_; - + var size = this.getSize(); + var fill = this.getFill(); var pt = this.getPoints(); @@ -163,7 +163,7 @@ lime.Renderer.CANVAS.POLYGON.draw = function(context) { lime.Renderer.CANVAS.SPRITE.draw.call(this, context); - if(this.stroke_){ + if(this.getStroke()){ context.lineWidth*=2; context.stroke(); } diff --git a/lime/src/shape/roundedrect.js b/lime/src/shape/roundedrect.js index 4fdf1618..264c88f4 100644 --- a/lime/src/shape/roundedrect.js +++ b/lime/src/shape/roundedrect.js @@ -106,7 +106,7 @@ lime.Renderer.CANVAS.ROUNDEDRECT.draw = function(context) { lime.Renderer.CANVAS.SPRITE.draw.call(this, context); - if(this.stroke_){ + if(this.getStroke()){ context.lineWidth*=2; context.stroke(); } diff --git a/lime/src/sprite.js b/lime/src/sprite.js index ea0282f8..daaf6ec4 100755 --- a/lime/src/sprite.js +++ b/lime/src/sprite.js @@ -8,33 +8,39 @@ goog.require('goog.math.Size'); goog.require('lime'); goog.require('lime.Node'); goog.require('lime.fill.Color'); -goog.require('lime.fill.Stroke'); goog.require('lime.fill.Fill'); goog.require('lime.fill.Image'); +goog.require('lime.fill.Stroke'); + + /** * Rectangural textured object * @constructor - * @extends lime.Node + * @extends {lime.Node} */ lime.Sprite = function() { - lime.Node.call(this); - - /** - * Fill object used while drawing - * @type {lime.fill.Fill} - * @private - */ - this.fill_ = null; + goog.base(this); + /** + * Fill object used while drawing + * @type {lime.fill.Fill} + * @private + */ + this.fill_ = null; - this.stroke_ = null; - + /** + * Stroke. + * @type {lime.fill.Stroke} + * @private + */ + this.stroke_ = null; }; goog.inherits(lime.Sprite, lime.Node); + /** * Common name for sprite objects * @type {string} @@ -42,20 +48,26 @@ goog.inherits(lime.Sprite, lime.Node); lime.Sprite.prototype.id = 'sprite'; -/** @inheritDoc */ -lime.Sprite.prototype.supportedRenderers = [ - lime.Renderer.DOM.makeSubRenderer(lime.Renderer.DOM.SPRITE), - lime.Renderer.CANVAS.makeSubRenderer(lime.Renderer.CANVAS.SPRITE) -]; - /** - * Gets fill parameters - * @return {lime.fill.Fill} Fill object. + * @return {lime.fill.Fill} fill. */ lime.Sprite.prototype.getFill = function() { - return this.fill_; + return this.fill_; }; + +lime.Renderer.DOM.SPRITE = lime.Renderer.DOM.makeSubRenderer({}); + +lime.Renderer.CANVAS.SPRITE = lime.Renderer.CANVAS.makeSubRenderer({}); + + +/** @inheritDoc */ +lime.Sprite.prototype.supportedRenderers = [ + lime.Renderer.DOM.SPRITE, + lime.Renderer.CANVAS.SPRITE +]; + + /** * Sets fill parameters * @param {*} fill Fill. @@ -65,48 +77,51 @@ lime.Sprite.prototype.getFill = function() { * @return {lime.Sprite} object itself. */ lime.Sprite.prototype.setFill = function(fill, opt_g, opt_b, opt_a) { - this.fill_ = lime.fill.parse(goog.array.toArray(arguments)); - this.fill_.initForSprite(this); - this.setDirty(lime.Dirty.CONTENT); - return this; + this.fill_ = lime.fill.parse(goog.array.toArray(arguments)); + this.fill_.initForSprite(this); + this.setDirty(lime.Dirty.CONTENT); + return this; }; + /** * Return Stroke object if one is set * @return {lime.fill.Stroke} Stroke object. */ -lime.Sprite.prototype.getStroke = function(){ - return this.stroke_; +lime.Sprite.prototype.getStroke = function() { + return this.stroke_; }; + /** * Sets stroke parameters. - * @param {*} stroke Stroke object or width and (mixed type) Color. + * @param {!lime.fill.Stroke} stroke Stroke object. * @return {lime.Sprite} object itself. */ -lime.Sprite.prototype.setStroke = function(stroke){ - if(stroke && !(stroke instanceof lime.fill.Stroke)){ - stroke = new lime.fill.Stroke(goog.array.toArray(arguments)); - } - this.stroke_ = stroke; - this.setDirty(lime.Dirty.CONTENT); - return this; +lime.Sprite.prototype.setStroke = function(stroke) { + this.stroke_ = stroke; + this.setDirty(lime.Dirty.CONTENT); + return this; }; + /** + * @type {number} * @private */ -// todo: move this function to canvas background rendermode -lime.Sprite.prototype.getCanvasContextName_ = (function() { - var contextID_ = 0; - return function() { +lime.Sprite.prototype.contextID_ = 0; + - if (!goog.isDef(this.canvasContextName_)) { - this.canvasContextName_ = 'limedc' + (contextID_++); - } - return this.canvasContextName_; - }; -})(); +/** + * @private + */ +lime.Sprite.prototype.getCanvasContextName_ = function() { + // todo: move this function to canvas background rendermode + if (!goog.isDef(this.canvasContextName_)) { + this.canvasContextName_ = 'limedc' + (this.contextID_++); + } + return this.canvasContextName_; +}; /** @@ -114,47 +129,43 @@ lime.Sprite.prototype.getCanvasContextName_ = (function() { * @this {lime.Sprite} */ lime.Renderer.DOM.SPRITE.draw = function(el) { - if (!goog.isNull(this.fill_)) { - this.fill_.setDOMStyle(el, this); - } - if (!goog.isNull(this.stroke_)) { - this.stroke_.setDOMStyle(el, this); - } else { - goog.style.setStyle(el, 'border-width', 0); - } + if (!goog.isNull(this.fill_)) { + this.fill_.setDOMStyle(el, this); + } + if (!goog.isNull(this.stroke_)) { + this.stroke_.setDOMStyle(el, this); + } else { + goog.style.setStyle(el, 'border-width', 0); + } }; + /** * @inheritDoc * @this {lime.Sprite} */ lime.Renderer.CANVAS.SPRITE.draw = function(context) { - var size = this.getSize(), fill = this.fill_, stroke = this.stroke_; - - if (!fill && !stroke) return; - - var frame = this.getFrame(); - - - if(fill){ - fill.setCanvasStyle(context, this); - - if(fill.id != 'image' && fill.id!='frame'){ - context.fillRect(frame.left,frame.top, - size.width, size.height); - } + var size = this.getSize(), fill = this.fill_, stroke = this.stroke_; + + if (!fill && !stroke) return; + + var frame = this.getFrame(); + if (fill) { + fill.setCanvasStyle(context, this); + + if (fill.id != 'image' && fill.id != 'frame') { + context.fillRect(frame.left, frame.top, + size.width, size.height); } - - - if(stroke){ - stroke.setCanvasStyle(context,this); - - if(this.id=='sprite' || this.id=='label'){ - var lw = stroke.width_/2; - context.strokeRect(frame.left+lw,frame.top+lw, - size.width-2*lw, size.height-2*lw); - } + } + if (stroke) { + stroke.setCanvasStyle(context, this); + + if (this.id == 'sprite' || this.id == 'label') { + var lw = stroke.width_ / 2; + context.strokeRect(frame.left + lw, frame.top + lw, + size.width - 2 * lw, size.height - 2 * lw); } - + } }; diff --git a/lime/src/transitions/slide_move.js b/lime/src/transitions/slide_move.js index 2bfedc46..8a12af05 100644 --- a/lime/src/transitions/slide_move.js +++ b/lime/src/transitions/slide_move.js @@ -5,7 +5,6 @@ goog.provide('lime.transitions.MoveInRight'); goog.provide('lime.transitions.MoveInUp'); goog.provide('lime.transitions.SlideIn'); - goog.provide('lime.transitions.SlideInDown'); goog.provide('lime.transitions.SlideInLeft'); goog.provide('lime.transitions.SlideInRight'); @@ -17,8 +16,8 @@ goog.require('lime.transitions.Transition'); /** * Slide-In transition. - * @param {lime.scene} outgoing Outgoing scene. - * @param {lime.scene} incoming Incoming scene. + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @param {boolean=} opt_movein Use Move-In transition. * @constructor * @extends lime.transitions.Transition @@ -106,15 +105,24 @@ lime.transitions.SlideIn.prototype.setMode = function(value) { /** - * @inheritDoc - * @extends lime.transitions.SlideIn + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. + * @param {boolean=} opt_movein Use Move-In transition. + * @constructor + * @extends {lime.transitions.SlideIn} */ -lime.transitions.SlideInLeft = lime.transitions.SlideIn; +lime.transitions.SlideInLeft = function(outgoing, incoming, opt_movein) { + goog.base(this, outgoing, incoming, opt_movein); +}; +goog.inherits(lime.transitions.SlideInLeft, lime.transitions.SlideIn); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. + * @param {boolean=} opt_movein * @inheritDoc * @constructor - * @extends lime.transitions.SlideIn + * @extends {lime.transitions.SlideIn} */ lime.transitions.SlideInUp = function(outgoing, incoming, opt_movein) { goog.base(this, outgoing, incoming, opt_movein); @@ -124,9 +132,12 @@ lime.transitions.SlideInUp = function(outgoing, incoming, opt_movein) { goog.inherits(lime.transitions.SlideInUp, lime.transitions.SlideIn); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. + * @param {boolean=} opt_movein * @inheritDoc * @constructor - * @extends lime.transitions.SlideIn + * @extends {lime.transitions.SlideIn} */ lime.transitions.SlideInRight = function(outgoing, incoming, opt_movein) { goog.base(this, outgoing, incoming, opt_movein); @@ -136,9 +147,12 @@ lime.transitions.SlideInRight = function(outgoing, incoming, opt_movein) { goog.inherits(lime.transitions.SlideInRight, lime.transitions.SlideIn); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. + * @param {boolean=} opt_movein * @inheritDoc * @constructor - * @extends lime.transitions.SlideIn + * @extends {lime.transitions.SlideIn} */ lime.transitions.SlideInDown = function(outgoing, incoming, opt_movein) { goog.base(this, outgoing, incoming, opt_movein); @@ -153,9 +167,11 @@ goog.inherits(lime.transitions.SlideInDown, lime.transitions.SlideIn); /** * Move-In transition. Difference form slide-in is that outgoing scene * does not move. + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @inheritDoc * @constructor - * @extends lime.transitions.SlideInLeft + * @extends {lime.transitions.SlideInLeft} */ lime.transitions.MoveInLeft = function(outgoing, incoming) { goog.base(this, outgoing, incoming, true); @@ -163,9 +179,11 @@ lime.transitions.MoveInLeft = function(outgoing, incoming) { goog.inherits(lime.transitions.MoveInLeft, lime.transitions.SlideInLeft); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @inheritDoc * @constructor - * @extends lime.transitions.SlideInUp + * @extends {lime.transitions.SlideInUp} */ lime.transitions.MoveInUp = function(outgoing, incoming) { goog.base(this, outgoing, incoming, true); @@ -173,9 +191,11 @@ lime.transitions.MoveInUp = function(outgoing, incoming) { goog.inherits(lime.transitions.MoveInUp, lime.transitions.SlideInUp); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @inheritDoc * @constructor - * @extends lime.transitions.SlideInRight + * @extends {lime.transitions.SlideInRight} */ lime.transitions.MoveInRight = function(outgoing, incoming) { goog.base(this, outgoing, incoming, true); @@ -183,9 +203,11 @@ lime.transitions.MoveInRight = function(outgoing, incoming) { goog.inherits(lime.transitions.MoveInRight, lime.transitions.SlideInRight); /** + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @inheritDoc * @constructor - * @extends lime.transitions.SlideInDown + * @extends {lime.transitions.SlideInDown} */ lime.transitions.MoveInDown = function(outgoing, incoming) { goog.base(this, outgoing, incoming, true); @@ -195,3 +217,5 @@ goog.inherits(lime.transitions.MoveInDown, lime.transitions.SlideInDown); + + diff --git a/lime/src/transitions/transition.js b/lime/src/transitions/transition.js index 801feaa0..4b829255 100644 --- a/lime/src/transitions/transition.js +++ b/lime/src/transitions/transition.js @@ -1,9 +1,10 @@ goog.provide('lime.transitions.Transition'); +goog.require('goog.debug.Logger'); /** * Animation for switching active scenes - * @param {lime.Scene} outgoing Outgoing scene. - * @param {lime.Scene} incoming Incoming scene. + * @param {lime.Scene=} outgoing Outgoing scene. + * @param {lime.Scene=} incoming Incoming scene. * @constructor * @extends goog.events.EventTarget */ @@ -19,6 +20,26 @@ lime.transitions.Transition = function(outgoing, incoming) { }; goog.inherits(lime.transitions.Transition,goog.events.EventTarget); +/** + * @protected + * @type {goog.debug.Logger} logger. + */ +lime.transitions.Transition.prototype.logger = + goog.debug.Logger.getLogger('lime.transitions.Transition'); + + +/** + * + * @param {lime.Scene} outgoing + * @param {lime.Scene} incoming + * @param {boolean=} opt_a + */ +lime.transitions.Transition.prototype.init = function(outgoing, incoming, opt_a) { + this.outgoing_ = outgoing; + this.incoming_ = incoming; +}; + + /** * Returns the animation duration in seconds. * @return {number} duration. @@ -37,19 +58,6 @@ lime.transitions.Transition.prototype.setDuration = function(value) { return this; }; -/** - * Set finish callback for transition. This function will be called - * after the transition has finished. DEPRECATED! Use event listeners instead. - * @deprecated - * @param {function()} value Callback. - * @return {lime.transitions.Transition} object itself. - */ -lime.transitions.Transition.prototype.setFinishCallback = function(value) { - if(goog.DEBUG && console && console.warn){ - console.warn('Transition.prototype.setFinishCallback() is deprecated. Use event listeners.'); - } - return this; -}; /** * Start the transition animation. diff --git a/lime/src/useragent.js b/lime/src/useragent.js index 3379187e..ed13266c 100644 --- a/lime/src/useragent.js +++ b/lime/src/useragent.js @@ -68,7 +68,7 @@ lime.userAgent.CHROME = goog.userAgent.WEBKIT && (/Chrome\//i).test(ua); /** * Whether the user agent is running on touch based device - * @type boolean + * @type {boolean} */ lime.userAgent.SUPPORTS_TOUCH = goog.isDef(document['ontouchmove']); diff --git a/lime/tests/schedulemanager.htm b/lime/tests/schedulemanager.htm index d295fa81..ebf106c6 100644 --- a/lime/tests/schedulemanager.htm +++ b/lime/tests/schedulemanager.htm @@ -9,7 +9,7 @@ goog.require('goog.testing.jsunit'); goog.require('goog.testing.recordFunction'); goog.require('goog.testing.PropertyReplacer'); - goog.require('lime.scheduleManager'); + goog.require('lime.ScheduleManager');