change the semantics of Ox.load to call back once the DOM is ready - which wasn't the case when calling Ox.load(callback) in the built version

This commit is contained in:
rolux 2012-06-22 15:02:38 +02:00
parent 260f826282
commit f15d6cad0f

View file

@ -118,6 +118,11 @@ Ox.load = function() {
var callback = arguments[arguments.length - 1], var callback = arguments[arguments.length - 1],
length, loaded = 0, modules = {}, succeeded = 0, length, loaded = 0, modules = {}, succeeded = 0,
type = Ox.typeOf(arguments[0]); type = Ox.typeOf(arguments[0]);
function done(success) {
Ox.documentReady(function() {
callback(success);
});
}
if (type == 'string') { if (type == 'string') {
modules = Ox.extend( modules = Ox.extend(
{}, arguments[0], Ox.isObject(arguments[1]) ? arguments[1] : {} {}, arguments[0], Ox.isObject(arguments[1]) ? arguments[1] : {}
@ -134,6 +139,10 @@ Ox.load = function() {
modules = arguments[0]; modules = arguments[0];
} }
length = Ox.len(modules); length = Ox.len(modules);
Ox.documentReady(function() {
if (!length) {
callback(true);
} else {
Ox.forEach(modules, function(options, module) { Ox.forEach(modules, function(options, module) {
Ox.getFile( Ox.getFile(
Ox.PATH + 'Ox.' + module + '/Ox.' + module + '.js', Ox.PATH + 'Ox.' + module + '/Ox.' + module + '.js',
@ -145,6 +154,8 @@ Ox.load = function() {
} }
); );
}); });
}
});
}; };
/*@ /*@