From 18e3c08ca82a76801250c261fde4eccf779a4041 Mon Sep 17 00:00:00 2001 From: Olivier Louvignes Date: Sun, 22 Apr 2012 04:05:54 +0200 Subject: [PATCH] Tweaking `iOS/MessageBox`, added callable checks on callbacks. --- iOS/MessageBox/MessageBox.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iOS/MessageBox/MessageBox.js b/iOS/MessageBox/MessageBox.js index 5036c18..bc63523 100644 --- a/iOS/MessageBox/MessageBox.js +++ b/iOS/MessageBox/MessageBox.js @@ -17,7 +17,7 @@ MessageBox.prototype.alert = function(title, message, callback, options) { var _callback = function(buttonIndex) { var button = 'ok'; - callback.call(config.scope, button); + if(typeof callback == 'function') callback.call(config.scope, button); }; return navigator.notification.alert(message, _callback, title, config.okButtonTitle + ''); @@ -32,8 +32,8 @@ MessageBox.prototype.confirm = function(title, message, callback, options) { }; var _callback = function(buttonIndex) { - var button = (buttonIndex === 0) ? 'yes' : 'no'; - callback.call(config.scope, button); + var button = (buttonIndex === 2) ? 'yes' : 'no'; + if(typeof callback == 'function') callback.call(config.scope, button); }; return navigator.notification.confirm(message, _callback, title, config.noButtonTitle + ', ' + config.yesButtonTitle); @@ -56,7 +56,7 @@ MessageBox.prototype.prompt = function(title, message, callback, options) { var _callback = function(result) { var value = (result.buttonIndex == 1) ? result.value : false; button = (result.buttonIndex == 1) ? 'ok' : 'cancel'; - callback.call(scope, button, value); + if(typeof callback == 'function') callback.call(scope, button, value); }; return cordova.exec(_callback, _callback, 'MessageBox', 'prompt', [config]);