added onNativeReady and onDOMContentLoaded events

This commit is contained in:
Dave Johnson
2010-07-22 13:05:41 -07:00
parent 3365dba870
commit 742910f369
3 changed files with 20 additions and 1695 deletions
+15 -3
View File
@@ -112,7 +112,6 @@ PhoneGap.Channel.join = function(h, c) {
if (!i) h();
};
/**
* Boolean flag indicating if the PhoneGap API is available and initialized.
*/ // TODO: Remove this, it is unused here ... -jm
@@ -193,6 +192,20 @@ document.addEventListener = function(evt, handler, capture) {
}
};
// Intercept calls to document.addEventListener and watch for deviceready
PhoneGap._document_addEventListener = document.addEventListener;
document.addEventListener = function(evt, handler, capture) {
if (evt.toLowerCase() == 'deviceready') {
PhoneGap.onDeviceReady.sob(handler);
} else {
PhoneGap._document_addEventListener.call(document, evt, handler);
}
};
/**
* Execute a PhoneGap command in a queued fashion, to ensure commands do not
* execute with any race conditions, and only run when PhoneGap is ready to
@@ -331,5 +344,4 @@ PhoneGap.close = function(context, func, params) {
return func.apply(context, params);
}
}
};
};