Wallet/src/js/init.js

79 lines
2.1 KiB
JavaScript
Raw Normal View History

2014-03-14 17:38:27 -03:00
'use strict';
2014-04-30 12:25:33 -03:00
2014-03-14 17:38:27 -03:00
angular.element(document).ready(function() {
2015-01-03 13:59:18 -03:00
2015-04-13 10:37:42 -03:00
// Run copayApp after device is ready.
var startAngular = function() {
angular.bootstrap(document, ['copayApp']);
2015-04-13 10:37:42 -03:00
};
/* Cordova specific Init */
2014-11-25 15:09:36 -03:00
if (window.cordova !== undefined) {
2015-03-06 12:00:10 -03:00
// Fastclick event
if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
2014-11-25 15:09:36 -03:00
document.addEventListener('deviceready', function() {
document.addEventListener('pause', function() {
2014-12-12 19:17:50 -03:00
if (!window.ignoreMobilePause) {
2015-03-06 12:00:10 -03:00
window.location = '#/';
2014-12-12 15:07:48 -03:00
}
}, false);
2015-04-13 14:58:07 -03:00
document.addEventListener('resume', function() {
if (!window.ignoreMobilePause) {
window.location = '#/cordova/resume';
}
setTimeout(function() {
window.ignoreMobilePause = false;
}, 100);
}, false);
2015-04-13 14:58:07 -03:00
// We are not emitting here, since when the BWS socket reconnects,
// update will be triggered
2015-04-13 17:09:33 -03:00
document.addEventListener('offline', function() {
window.location = '#/cordova/offline';
2015-04-13 17:09:33 -03:00
}, false);
2015-04-13 14:58:07 -03:00
//
// document.addEventListener("online", function() {
// window.location = '#/cordoba/online';
// }, false);
// Removes handler for backbutton event.
// All apps use a natural flow for back button
//document.addEventListener('backbutton', function() {
// window.location = '#/walletHome';
//}, false);
2015-03-06 12:00:10 -03:00
document.addEventListener('menubutton', function() {
window.location = '#/preferences';
}, false);
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);
function handleBitcoinURI(url) {
if (!url) return;
2015-04-16 16:56:15 -03:00
setTimeout(function() {
window.location = '#/uri-payment/' + url;
}, 1000);
}
window.plugins.webintent.getUri(handleBitcoinURI);
window.plugins.webintent.onNewIntent(handleBitcoinURI);
window.handleOpenURL = handleBitcoinURI;
2015-04-13 10:37:42 -03:00
startAngular();
}, false);
2014-11-25 15:09:36 -03:00
} else {
2015-04-13 10:37:42 -03:00
startAngular();
2014-11-25 15:09:36 -03:00
}
2014-03-14 17:38:27 -03:00
});