mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Small fixes for iPhone/ActionSheet plugin.
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user