Fix Meteor.startup not waiting for deviceready in Cordova app
Fix Meteor.startup not waiting for deviceready in Cordova app

This fixes a long standing issue where Meteor.startup was not waiting
for the deviceready event (fired when all plugins have been
initialized) in a Cordova app. It also removes a non-functioning
workaround that was based on the belief that this was a Cordova bug,
and cleans up the code somewhat.

The cause of this issue was that we tried to keep track of
awaitingEventsCount, but forgot that both DOMContentLoaded and loaded
events would usually fire. As a result, awaitingEventsCount became 0
before deviceready fired (leading to all sorts of bugs with code
calling into Cordova).

The holdReady() function is based on a similarly named function in
jQuery and generalizes waiting for events in addition to loading
completing.

meonkeys/meteor,mjmasn/meteor,Hansoft/meteor,yonas/meteor-freebsd,AnthonyAstige/meteor,benstoltz/meteor,lpinto93/meteor,AnthonyAstige/meteor,meonkeys/meteor,mjmasn/meteor,devgrok/meteor,meonkeys/meteor,EduShareOntario/meteor,AnthonyAstige/meteor,Hansoft/meteor,lassombra/meteor,Urigo/meteor,lorensr/meteor,meonkeys/meteor,DAB0mB/meteor,jdivy/meteor,AnthonyAstige/meteor,chasertech/meteor,devgrok/meteor,EduShareOntario/meteor,jdivy/meteor,lassombra/meteor,meonkeys/meteor,devgrok/meteor,jdivy/meteor,newswim/meteor,4commerce-technologies-AG/meteor,chasertech/meteor,yonas/meteor-freebsd,EduShareOntario/meteor,lassombra/meteor,Urigo/meteor,yonas/meteor-freebsd,benstoltz/meteor,AnthonyAstige/meteor,lassombra/meteor,nuvipannu/meteor,mjmasn/meteor,mjmasn/meteor,nuvipannu/meteor,yonas/meteor-freebsd,4commerce-technologies-AG/meteor,DAB0mB/meteor,lpinto93/meteor,EduShareOntario/meteor,lorensr/meteor,lorensr/meteor,jdivy/meteor,4commerce-technologies-AG/meteor,DAB0mB/meteor,benstoltz/meteor,nuvipannu/meteor,yonas/meteor-freebsd,DAB0mB/meteor,meonkeys/meteor,4commerce-technologies-AG/meteor,chasertech/meteor,EduShareOntario/meteor,Hansoft/meteor,jdivy/meteor,devgrok/meteor,Urigo/meteor,EduShareOntario/meteor,EduShareOntario/meteor,mjmasn/meteor,lorensr/meteor,newswim/meteor,devgrok/meteor,4commerce-technologies-AG/meteor,yonas/meteor-freebsd,newswim/meteor,4commerce-technologies-AG/meteor,lorensr/meteor,devgrok/meteor,Urigo/meteor,chasertech/meteor,jdivy/meteor,nuvipannu/meteor,Urigo/meteor,lassombra/meteor,jdivy/meteor,AnthonyAstige/meteor,lorensr/meteor,lassombra/meteor,lassombra/meteor,AnthonyAstige/meteor,nuvipannu/meteor,benstoltz/meteor,Hansoft/meteor,newswim/meteor,Hansoft/meteor,DAB0mB/meteor,newswim/meteor,benstoltz/meteor,yonas/meteor-freebsd,lpinto93/meteor,Hansoft/meteor,newswim/meteor,devgrok/meteor,lpinto93/meteor,lorensr/meteor,Urigo/meteor,benstoltz/meteor,Hansoft/meteor,lpinto93/meteor,Urigo/meteor,AnthonyAstige/meteor,lpinto93/meteor,lpinto93/meteor,newswim/meteor,mjmasn/meteor,chasertech/meteor,DAB0mB/meteor,chasertech/meteor,4commerce-technologies-AG/meteor,chasertech/meteor,nuvipannu/meteor,meonkeys/meteor,DAB0mB/meteor,benstoltz/meteor,mjmasn/meteor,nuvipannu/meteor