This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Namespace = { | |
Register: function(_Name) { | |
var chk = false; | |
var cob = ""; | |
var spc = _Name.split("."); | |
for (var i = 0; i < spc.length; i++) { | |
if (cob != "") { | |
cob += "."; | |
} | |
cob += spc[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Namespace.Register('MyApp.Loader'); | |
Namespace.Register('MyApp.ORM.Mappers'); | |
MyApp.Loader.appLoader = function() { | |
// Load application | |
}; | |
MyApp.Loader.modelLoader = function() { | |
// Load up my Models | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.requestAnimFrame = (function() { | |
return self.requestAnimationFrame || self.webkitRequestAnimationFrame || self.mozRequestAnimationFrame || self.oRequestAnimationFrame || self.msRequestAnimationFrame || | |
function(callback) { | |
self.setTimeout(callback, 1000 / 60); | |
}; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DeepElement.ThreeOneFour.Common.Clock = new Class({ | |
Implements: Events, | |
running: false, | |
interval: null, | |
t0: +new Date(), | |
rAFSupport: false, | |
initialize: function() { | |
self.requestAnimFrame = (function() { | |
return self.requestAnimationFrame || self.webkitRequestAnimationFrame || self.mozRequestAnimationFrame || self.oRequestAnimationFrame || self.msRequestAnimationFrame; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i = 0; i <= 100; i++) { | |
var clock = new DeepElement.ThreeOneFour.Clock(); | |
var self = this; | |
clock.addEvent('tick', function(td) { | |
console.log('tick'); | |
var doSomethingWithSelf = self; | |
}); | |
clock.start(); | |
clock.stop(); | |
delete clock; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Namespace.Register("DeepElement.ThreeOneFour.Component") | |
/* | |
* Represents a Javascript Component Baseclass that supports async | |
* loading/unloading | |
* | |
*/ | |
DeepElement.ThreeOneFour.Component = new Class({ | |
Implements: Events, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var component1 = new DeepElement.ThreeOneFour.Component(); | |
var component2 = new DeepElement.ThreeOneFour.Component(); | |
var component3 = new DeepElement.ThreeOneFour.Component(); | |
component1.load(function() { | |
component2.load(function() { | |
component3.load(function() { | |
// phewww! all three loadedF | |
}, function() { | |
// component3 failed to load |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Namespace.Register('DeepElement.ThreeOneFour.Helpers.ComponentLoader'); | |
/* | |
* Asynchronous Loader for Components | |
*/ | |
DeepElement.ThreeOneFour.Helpers.ComponentLoader = new Class({ | |
instances: null, | |
initialize: function(instances) { | |
this.instances = instances; | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Component Load Tests", function() { | |
var componentTestCount = 10; | |
var components = [] | |
for (var i = 0; i <= componentTestCount - 1; i++) { | |
components.push(new DeepElement.ThreeOneFour.Component()); | |
} | |
var comonentLoader = new DeepElement.ThreeOneFour.Helpers.ComponentLoader( | |
components); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build the loader instance and pass in your ordered list of Concrete types that implement DeepElement.ThreeOneFour.Component | |
var comonentLoader = new DeepElement.ThreeOneFour.Helpers.ComponentLoader( | |
components); | |
comonentLoader.load(function() { | |
// all components have loaded | |
}, function() { | |
// a component failed | |
// check the "this" context to find out which one | |
}); |