UNPKG

6.39 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 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;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name Toast
11 * @description
12 * This plugin allows you to show a native Toast (a little text popup) on iOS, Android and WP8. It's great for showing a non intrusive native notification which is guaranteed always in the viewport of the browser.
13 *
14 * Requires Cordova plugin: `cordova-plugin-x-toast`. For more info, please see the [Toast plugin docs](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin).
15 *
16 * @usage
17 * ```typescript
18 * import { Toast } from 'ionic-native';
19 *
20 *
21 * Toast.show("I'm a toast", '5000', 'center').subscribe(
22 * toast => {
23 * console.log(toast);
24 * }
25 * );
26 * ```
27 * @interfaces
28 * ToastOptions
29 */
30var Toast = (function () {
31 function Toast() {
32 }
33 /**
34 * Show a native toast for the given duration at the specified position.
35 *
36 * @param {string} message The message to display.
37 * @param {string} duration Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'.
38 * @param {string} position Where to position the toast, either 'top', 'center', or 'bottom'.
39 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
40 */
41 Toast.show = function (message, duration, position) { return; };
42 /**
43 * Manually hide any currently visible toast.
44 * @returns {Promise<any>} Returns a Promise that resolves on success.
45 */
46 Toast.hide = function () { return; };
47 /**
48 * Show a native toast with the given options.
49 *
50 * @param {Object} options Options for showing a toast. Available options:
51 * message The message to display.
52 * duration Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'.
53 * position Where to position the toast, either 'top', 'center', or 'bottom'.
54 * addPixelsY Offset in pixels to move the toast up or down from its specified position.
55 *
56 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
57 */
58 Toast.showWithOptions = function (options) { return; };
59 /**
60 * Shorthand for `show(message, 'short', 'top')`.
61 * @param message {string}
62 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
63 */
64 Toast.showShortTop = function (message) { return; };
65 /**
66 * Shorthand for `show(message, 'short', 'center')`.
67 * @param message {string}
68 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
69 */
70 Toast.showShortCenter = function (message) { return; };
71 /**
72 * Shorthand for `show(message, 'short', 'bottom')`.
73 * @param message {string}
74 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
75 */
76 Toast.showShortBottom = function (message) { return; };
77 /**
78 * Shorthand for `show(message, 'long', 'top')`.
79 * @param message {string}
80 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
81 */
82 Toast.showLongTop = function (message) { return; };
83 /**
84 * Shorthand for `show(message, 'long', 'center')`.
85 * @param message {string}
86 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
87 */
88 Toast.showLongCenter = function (message) { return; };
89 /**
90 * Shorthand for `show(message, 'long', 'bottom')`.
91 * @param message {string}
92 * @returns {Observable<any>} Returns an Observable that notifies first on success and then when tapped, rejects on error.
93 */
94 Toast.showLongBottom = function (message) { return; };
95 __decorate([
96 plugin_1.Cordova({
97 observable: true,
98 clearFunction: 'hide'
99 })
100 ], Toast, "show", null);
101 __decorate([
102 plugin_1.Cordova()
103 ], Toast, "hide", null);
104 __decorate([
105 plugin_1.Cordova({
106 observable: true,
107 clearFunction: 'hide'
108 })
109 ], Toast, "showWithOptions", null);
110 __decorate([
111 plugin_1.Cordova({
112 observable: true,
113 clearFunction: 'hide'
114 })
115 ], Toast, "showShortTop", null);
116 __decorate([
117 plugin_1.Cordova({
118 observable: true,
119 clearFunction: 'hide'
120 })
121 ], Toast, "showShortCenter", null);
122 __decorate([
123 plugin_1.Cordova({
124 observable: true,
125 clearFunction: 'hide'
126 })
127 ], Toast, "showShortBottom", null);
128 __decorate([
129 plugin_1.Cordova({
130 observable: true,
131 clearFunction: 'hide'
132 })
133 ], Toast, "showLongTop", null);
134 __decorate([
135 plugin_1.Cordova({
136 observable: true,
137 clearFunction: 'hide'
138 })
139 ], Toast, "showLongCenter", null);
140 __decorate([
141 plugin_1.Cordova({
142 observable: true,
143 clearFunction: 'hide'
144 })
145 ], Toast, "showLongBottom", null);
146 Toast = __decorate([
147 plugin_1.Plugin({
148 pluginName: 'Toast',
149 plugin: 'cordova-plugin-x-toast',
150 pluginRef: 'plugins.toast',
151 repo: 'https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin',
152 platforms: ['Android', 'iOS', 'Windows Phone 8']
153 })
154 ], Toast);
155 return Toast;
156}());
157exports.Toast = Toast;
158//# sourceMappingURL=toast.js.map
\No newline at end of file