second back button press to exit
This commit is contained in:
parent
01d02758f4
commit
9cea58584a
1 changed files with 20 additions and 9 deletions
|
|
@ -24,6 +24,10 @@ angular.element(document).ready(function() {
|
||||||
if (window.cordova !== undefined) {
|
if (window.cordova !== undefined) {
|
||||||
|
|
||||||
document.addEventListener('deviceready', function() {
|
document.addEventListener('deviceready', function() {
|
||||||
|
var exitApp = false,
|
||||||
|
intval = setInterval(function() {
|
||||||
|
exitApp = false;
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
document.addEventListener('pause', function() {
|
document.addEventListener('pause', function() {
|
||||||
if (!window.ignoreMobilePause) {
|
if (!window.ignoreMobilePause) {
|
||||||
|
|
@ -45,17 +49,24 @@ angular.element(document).ready(function() {
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Back button event
|
// Back button event
|
||||||
|
|
||||||
document.addEventListener('backbutton', function() {
|
document.addEventListener('backbutton', function() {
|
||||||
var loc = window.location;
|
if (exitApp) {
|
||||||
var exit = loc.toString().match(/disclaimer/) ? 'true' : '';
|
clearInterval(intval)
|
||||||
if (exit != 'true')
|
var loc = window.location;
|
||||||
var exit = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
|
var exit = loc.toString().match(/disclaimer/) ? 'true' : '';
|
||||||
if (!window.ignoreMobilePause) {
|
if (exit != 'true')
|
||||||
window.location = '#/cordova/backbutton/' + exit;
|
var exit = loc.toString().match(/index\.html#\/$/) ? 'true' : '';
|
||||||
|
if (!window.ignoreMobilePause) {
|
||||||
|
window.location = '#/cordova/backbutton/' + exit;
|
||||||
|
}
|
||||||
|
setTimeout(function() {
|
||||||
|
window.ignoreMobilePause = false;
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
window.plugins.toast.showShortCenter('Press again to exit');
|
||||||
|
exitApp = true;
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
|
||||||
window.ignoreMobilePause = false;
|
|
||||||
}, 100);
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener('menubutton', function() {
|
document.addEventListener('menubutton', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue