mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Merge pull request #260 from mgcrea/master
Minor update & readme tweaks.
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() {
|
||||
|
||||
@@ -7,14 +7,14 @@ by `Olivier Louvignes`
|
||||
|
||||
* Compared to the `iPhone/NativeControls` plugin, it is more documented & simpler to understand (only handle actionSheets). It does also provide new options (style).
|
||||
|
||||
* There is a `Sencha Touch 2.0` plugin to easily leverage this plugin [here](https://github.com/mgcrea/phonegap-plugins/wiki/iPhone-ActionSheet)
|
||||
* There is a `Sencha Touch 2.0` plugin to easily leverage this plugin [here](https://github.com/mgcrea/sencha-touch-plugins/blob/master/PhonegapActionSheet.js)
|
||||
|
||||
## SETUP ##
|
||||
|
||||
Using this plugin requires [iPhone PhoneGap](http://github.com/phonegap/phonegap-iphone).
|
||||
|
||||
1. Make sure your PhoneGap Xcode project has been [updated for the iOS 4 SDK](http://wiki.phonegap.com/Upgrade-your-PhoneGap-Xcode-Template-for-iOS-4)
|
||||
2. Drag and drop the `MessageBox` folder from Finder to your Plugins folder in XCode, using "Create groups for any added folders"
|
||||
2. Drag and drop the `ActionSheet` folder from Finder to your Plugins folder in XCode, using "Create groups for any added folders"
|
||||
3. Add the .js files to your `www` folder on disk, and add reference(s) to the .js files as <link> tags in your html file(s)
|
||||
4. Add new entry with key `ActionSheet` and value `ActionSheet` to `Plugins` in `PhoneGap.plist`
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -7,7 +7,7 @@ by `Olivier Louvignes`
|
||||
|
||||
* Compared to the `iPhone/Prompt` plugin, it is more documented & simpler to understand. It does also provide new options for prompt (message, multiline, input type password).
|
||||
|
||||
* There is a `Sencha Touch 2.0` plugin to easily leverage this plugin [here](https://github.com/mgcrea/phonegap-plugins/wiki/iPhone-MessageBox)
|
||||
* There is a `Sencha Touch 2.0` plugin to easily leverage this plugin [here](https://github.com/mgcrea/sencha-touch-plugins/blob/master/PhonegapMessageBox.js)
|
||||
|
||||
## SETUP ##
|
||||
|
||||
|
||||
Reference in New Issue
Block a user