Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ons.ready(function() {
// ons._defaultDeviceBackButtonHandler
ons._deviceBackButtonDispatcher.enable();
ons._defaultDeviceBackButtonHandler = ons._deviceBackButtonDispatcher.createHandler(window.document.body, () => {
if (Object.hasOwnProperty.call(navigator, 'app')) {
navigator.app.exitApp();
} else {
console.warn('Could not close the app. Is \'cordova.js\' included?\nError: \'window.navigator.app\' is undefined.');
}
});
document.body._gestureDetector = new ons.GestureDetector(document.body);
// Simulate Device Back Button on ESC press
if (!ons.platform.isWebView()) {
document.body.addEventListener('keydown', function(event) {
if (event.keyCode === 27) {
ons._deviceBackButtonDispatcher.fireDeviceBackButtonEvent();
}
})
document.body.addEventListener('keydown', function(event) {
if (event.keyCode === 27) {
ons._deviceBackButtonDispatcher.fireDeviceBackButtonEvent();
}
})
}