Last active
February 25, 2016 02:13
-
-
Save elegantcoder/1de8ff7068bbc0ce1e28 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/*cordova-deviceready-$q*/ | |
'use strict'; | |
angular.module('elcoCordova', []) | |
.factory('elcoCordova.onDeviceReady', [ | |
'$q', | |
'$log', | |
function ($q, console) { | |
console.log('elcoCordova.onDeviceReady'); | |
var deferred = $q.defer(); | |
if (!window.cordova) { | |
setTimeout(function () { | |
deferred.resolve(); | |
}, 100) | |
} else if (window.deviceReady) { | |
console.log('elcoCordova.onDeviceReady', 'window.deviceReady', window.deviceReady); | |
deferred.resolve(); | |
} else { | |
console.log('wait for device ready'); | |
document.addEventListener('deviceready', function () { | |
console.log('document, deviceready emit'); | |
deferred.resolve(); | |
}, false); | |
} | |
return deferred.promise; | |
} | |
]); |
This file contains hidden or 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
<script> | |
window.deviceReady = false; | |
window.onDeviceReady = function () { | |
console.log('DeviceReady'); | |
StatusBar.overlaysWebView(false); | |
StatusBar.styleDefault(); | |
window.deviceReady = true; | |
}; | |
document.addEventListener("deviceready", window.onDeviceReady, false); | |
</script> | |
<script src="cordova.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment