Skip to content

Commit 525f18d

Browse files
authored
Merge pull request #2117 from WalcoFPV/cordova_app_exit_confirm
2 parents 2d46b79 + 12d3819 commit 525f18d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

locales/en/messages.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5832,5 +5832,11 @@
58325832
},
58335833
"cordovaWebviewUsed": {
58345834
"message": "used"
5835+
},
5836+
"cordovaExitAppTitle": {
5837+
"message": "Confirmation"
5838+
},
5839+
"cordovaExitAppMessage": {
5840+
"message": "Do you really want to close the configurator?"
58355841
}
58365842
}

src/js/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ function startProcess() {
187187
chrome.runtime.onSuspend.addListener(closeHandler);
188188
} else if (GUI.isCordova()) {
189189
window.addEventListener('beforeunload', closeHandler);
190+
document.addEventListener('backbutton', function(e) {
191+
e.preventDefault();
192+
navigator.notification.confirm(
193+
i18n.getMessage('cordovaExitAppMessage'),
194+
function(stat) {
195+
if (stat === 1) {
196+
navigator.app.exitApp();
197+
}
198+
},
199+
i18n.getMessage('cordovaExitAppTitle'),
200+
[i18n.getMessage('yes'),i18n.getMessage('no')]
201+
);
202+
});
190203
}
191204

192205
$('.connect_b a.connect').removeClass('disabled');

0 commit comments

Comments
 (0)