awesome-cordova-plugins/dist/plugins/actionsheet.js

83 lines
3.5 KiB
JavaScript
Raw Normal View History

2015-12-01 10:17:55 +08:00
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2015-12-02 08:47:24 +08:00
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
2015-11-30 06:30:15 +08:00
};
var plugin_1 = require('./plugin');
2016-02-08 06:12:13 +08:00
/**
* The ActionSheet plugin shows a native list of options the user can choose from.
2016-02-19 02:01:27 +08:00
*
* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).
*
* @usage
*
* ```
* import {ActionSheet} from 'ionic-native';
*
* let buttonLabels = ['Share via Facebook', 'Share via Twitter'];
* ActionSheet.show({
* 'title': 'What do you want with this image?',
* 'buttonLabels': buttonLabels,
* 'addCancelButtonWithLabel': 'Cancel',
* 'addDestructiveButtonWithLabel' : 'Delete'
* }).then(buttonIndex => {
* console.log('Button pressed: ' + buttonLabels[buttonIndex - 1]);
* });
* ```
*
2016-02-08 06:12:13 +08:00
*/
2015-11-30 06:30:15 +08:00
var ActionSheet = (function () {
function ActionSheet() {
}
2016-02-06 09:22:23 +08:00
/**
* Show the ActionSheet.
2016-02-19 02:01:27 +08:00
* @param {options} options
* `buttonLabels`: string[]
* `title`: string
* `androidTheme` (Android only): number 1-5
* `androidEnableCancelButton` (Android only): boolean, default false
* `winphoneEnableCancelButton` (WP only): boolean, default false
* `addCancelButtonWithLabel`: string
* `addDestructiveButtonWithLabel`: string
* `position`: [x, y] (iPad pass in [x, y] coords of popover)
* @returns {Promise} Returns a Promise that resolves with the index of the
2016-02-08 06:12:13 +08:00
* button pressed (1 based, so 1, 2, 3, etc.)
2016-02-06 09:22:23 +08:00
*/
ActionSheet.show = function (options) {
2016-02-08 06:12:13 +08:00
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise(function (res, rej) { });
2016-02-06 09:22:23 +08:00
};
/**
* Hide the ActionSheet.
*/
2016-02-08 06:12:13 +08:00
ActionSheet.hide = function () {
// This Promise is replaced by one from the @Cordova decorator that wraps
// the plugin's callbacks. We provide a dummy one here so TypeScript
// knows that the correct return type is Promise, because there's no way
// for it to know the return type from a decorator.
// See https://github.com/Microsoft/TypeScript/issues/4881
return new Promise(function (res, rej) { });
2016-02-06 09:22:23 +08:00
};
2015-12-02 08:47:24 +08:00
__decorate([
plugin_1.Cordova()
], ActionSheet, "show", null);
__decorate([
plugin_1.Cordova()
], ActionSheet, "hide", null);
2015-11-30 06:30:15 +08:00
ActionSheet = __decorate([
plugin_1.Plugin({
name: 'ActionSheet',
plugin: 'cordova-plugin-actionsheet',
pluginRef: 'plugins.actionsheet',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet'
})
], ActionSheet);
return ActionSheet;
})();
exports.ActionSheet = ActionSheet;
2015-12-01 02:34:54 +08:00
//# sourceMappingURL=actionsheet.js.map