Small fixes for iPhone/ActionSheet plugin.

This commit is contained in:
Olivier Louvignes
2011-11-28 03:22:05 +01:00
parent 1a520d46f5
commit c55e324021
2 changed files with 9 additions and 8 deletions

View File

@@ -12,30 +12,31 @@ ActionSheet.prototype.create = function(title, items, fn, options) {
if(!options) options = {};
var service = 'ActionSheet',
action = 'create',
callbackId = service + (PhoneGap.callbackId + 1);
var config = {
title : title+'' || 'Title',
title : title+'' || '',
items : items || ['Cancel'],
callback : fn || function(){},
scope: options.hasOwnProperty('scope') ? options.scope : null,
style : options.hasOwnProperty('style') ? options.style+'' : 'default',
destructiveButtonIndex : options.hasOwnProperty('destructiveButtonIndex') ? options.destructiveButtonIndex*1 : false,
cancelButtonIndex : options.hasOwnProperty('cancelButtonIndex') ? options.cancelButtonIndex*1 : false
destructiveButtonIndex : options.hasOwnProperty('destructiveButtonIndex') ? options.destructiveButtonIndex*1 : undefined,
cancelButtonIndex : options.hasOwnProperty('cancelButtonIndex') ? options.cancelButtonIndex*1 : undefined
};
var callback = function(result) {
var buttonValue = false, // value for cancelButton
buttonIndex = result.buttonIndex;
if(!config.cancelButtonIndex || result.buttonIndex != config.cancelButtonIndex) {
buttonValue = config.items[result.buttonIndex];
if(!config.cancelButtonIndex || buttonIndex != config.cancelButtonIndex) {
buttonValue = config.items[buttonIndex];
}
config.callback.call(config.scope || null, button, result.buttonIndex);
config.callback.call(config.scope || null, buttonValue, buttonIndex);
};
PhoneGap.exec(callback, callback, 'ActionSheet', 'create', [config]);
PhoneGap.exec(callback, callback, service, action, [config]);
};
PhoneGap.addConstructor(function() {

View File

@@ -25,7 +25,7 @@ MessageBox.prototype.prompt = function(title, msg, fn, options) {
title : title+'' || 'Prompt',
message : msg+'' || '',
callback : fn || function(){},
scope: null,
scope: options.hasOwnProperty('scope') ? options.scope : null,
type : options.hasOwnProperty('type') ? options.type+'' : 'text',
placeholder : options.hasOwnProperty('placeholder') ? options.placeholder+'' : '',
okButtonTitle : options.hasOwnProperty('okButtonTitle') ? options.okButtonTitle+'' : 'OK',