fixed up things so that deviceready now uses DOMContentLoaded and if DCL fires before something is attached to deviceready the function will be called immediately

This commit is contained in:
Dave Johnson
2010-07-20 11:25:55 -07:00
parent 27c4de6aa0
commit f7a4a0aef8
6 changed files with 325 additions and 143 deletions
+17
View File
@@ -57,3 +57,20 @@ Device.prototype.exitApp = function()
PhoneGap.addConstructor(function() {
navigator.device = window.device = new Device();
});
PhoneGap.onDeviceReady = new PhoneGap.Channel();
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);
}
}
document.addEventListener('DOMContentLoaded', function() {
PhoneGap.onDeviceReady.fire();
})