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:
parent
260f826282
commit
f15d6cad0f
1 changed files with 21 additions and 10 deletions
|
@ -118,6 +118,11 @@ Ox.load = function() {
|
|||
var callback = arguments[arguments.length - 1],
|
||||
length, loaded = 0, modules = {}, succeeded = 0,
|
||||
type = Ox.typeOf(arguments[0]);
|
||||
function done(success) {
|
||||
Ox.documentReady(function() {
|
||||
callback(success);
|
||||
});
|
||||
}
|
||||
if (type == 'string') {
|
||||
modules = Ox.extend(
|
||||
{}, arguments[0], Ox.isObject(arguments[1]) ? arguments[1] : {}
|
||||
|
@ -134,16 +139,22 @@ Ox.load = function() {
|
|||
modules = arguments[0];
|
||||
}
|
||||
length = Ox.len(modules);
|
||||
Ox.forEach(modules, function(options, module) {
|
||||
Ox.getFile(
|
||||
Ox.PATH + 'Ox.' + module + '/Ox.' + module + '.js',
|
||||
function() {
|
||||
Ox.load[module](options, function(success) {
|
||||
succeeded += success;
|
||||
++loaded == length && callback(succeeded == length);
|
||||
});
|
||||
}
|
||||
);
|
||||
Ox.documentReady(function() {
|
||||
if (!length) {
|
||||
callback(true);
|
||||
} else {
|
||||
Ox.forEach(modules, function(options, module) {
|
||||
Ox.getFile(
|
||||
Ox.PATH + 'Ox.' + module + '/Ox.' + module + '.js',
|
||||
function() {
|
||||
Ox.load[module](options, function(success) {
|
||||
succeeded += success;
|
||||
++loaded == length && callback(succeeded == length);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue