Created
July 2, 2015 07:32
-
-
Save Heshyo/19cb259ed8ca033b3ca1 to your computer and use it in GitHub Desktop.
Fires "deviceready" when we're not inside a Cordova app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fakes the call of "deviceready". This can be useful for test purposes, but potentially also for the real website | |
// to avoid things like: | |
// if inside the app, call this method inside "deviceready" | |
// else call this method now. | |
(function () { | |
var oldAddEventListener = document.addEventListener; | |
document.addEventListener = function (eventName, callback) { | |
if (eventName === "deviceready") { | |
callback(); | |
} else { | |
oldAddEventListener(eventName, callback); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment