a zip code crypto-currency system good for red ONLY

alert-controller.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports", "@angular/core", "./alert", "../app/app", "../../config/config"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var alert_1 = require("./alert");
  14. var app_1 = require("../app/app");
  15. var config_1 = require("../../config/config");
  16. /**
  17. * @name AlertController
  18. * @description
  19. * An Alert is a dialog that presents users with information or collects
  20. * information from the user using inputs. An alert appears on top
  21. * of the app's content, and must be manually dismissed by the user before
  22. * they can resume interaction with the app. It can also optionally have a
  23. * `title`, `subTitle` and `message`.
  24. *
  25. * You can pass all of the alert's options in the first argument of
  26. * the create method: `create(opts)`. Otherwise the alert's instance
  27. * has methods to add options, such as `setTitle()` or `addButton()`.
  28. *
  29. *
  30. * ### Alert Buttons
  31. *
  32. * In the array of `buttons`, each button includes properties for its `text`,
  33. * and optionally a `handler`. If a handler returns `false` then the alert
  34. * will not automatically be dismissed when the button is clicked. All
  35. * buttons will show up in the order they have been added to the `buttons`
  36. * array, from left to right. Note: The right most button (the last one in
  37. * the array) is the main button.
  38. *
  39. * Optionally, a `role` property can be added to a button, such as `cancel`.
  40. * If a `cancel` role is on one of the buttons, then if the alert is
  41. * dismissed by tapping the backdrop, then it will fire the handler from
  42. * the button with a cancel role.
  43. *
  44. *
  45. * ### Alert Inputs
  46. *
  47. * Alerts can also include several different inputs whose data can be passed
  48. * back to the app. Inputs can be used as a simple way to prompt users for
  49. * information. Radios, checkboxes and text inputs are all accepted, but they
  50. * cannot be mixed. For example, an alert could have all radio button inputs,
  51. * or all checkbox inputs, but the same alert cannot mix radio and checkbox
  52. * inputs. Do note however, different types of "text"" inputs can be mixed,
  53. * such as `url`, `email`, `text`, etc. If you require a complex form UI
  54. * which doesn't fit within the guidelines of an alert then we recommend
  55. * building the form within a modal instead.
  56. *
  57. *
  58. * @usage
  59. * ```ts
  60. * import { AlertController } from 'ionic-angular';
  61. *
  62. * constructor(public alertCtrl: AlertController) { }
  63. *
  64. * presentAlert() {
  65. * const alert = this.alertCtrl.create({
  66. * title: 'Low battery',
  67. * subTitle: '10% of battery remaining',
  68. * buttons: ['Dismiss']
  69. * });
  70. * alert.present();
  71. * }
  72. *
  73. * presentConfirm() {
  74. * const alert = this.alertCtrl.create({
  75. * title: 'Confirm purchase',
  76. * message: 'Do you want to buy this book?',
  77. * buttons: [
  78. * {
  79. * text: 'Cancel',
  80. * role: 'cancel',
  81. * handler: () => {
  82. * console.log('Cancel clicked');
  83. * }
  84. * },
  85. * {
  86. * text: 'Buy',
  87. * handler: () => {
  88. * console.log('Buy clicked');
  89. * }
  90. * }
  91. * ]
  92. * });
  93. * alert.present();
  94. * }
  95. *
  96. * presentPrompt() {
  97. * const alert = this.alertCtrl.create({
  98. * title: 'Login',
  99. * inputs: [
  100. * {
  101. * name: 'username',
  102. * placeholder: 'Username'
  103. * },
  104. * {
  105. * name: 'password',
  106. * placeholder: 'Password',
  107. * type: 'password'
  108. * }
  109. * ],
  110. * buttons: [
  111. * {
  112. * text: 'Cancel',
  113. * role: 'cancel',
  114. * handler: data => {
  115. * console.log('Cancel clicked');
  116. * }
  117. * },
  118. * {
  119. * text: 'Login',
  120. * handler: data => {
  121. * if (User.isValid(data.username, data.password)) {
  122. * // logged in!
  123. * } else {
  124. * // invalid login
  125. * return false;
  126. * }
  127. * }
  128. * }
  129. * ]
  130. * });
  131. * alert.present();
  132. * }
  133. * ```
  134. * @advanced
  135. *
  136. *
  137. * Alert options
  138. *
  139. * | Property | Type | Description |
  140. * |-----------------------|-----------|------------------------------------------------------------------------------|
  141. * | title | `string` | The title for the alert. |
  142. * | subTitle | `string` | The subtitle for the alert. |
  143. * | message | `string` | The message for the alert. |
  144. * | cssClass | `string` | Additional classes for custom styles, separated by spaces. |
  145. * | inputs | `array` | An array of inputs for the alert. See input options. |
  146. * | buttons | `array` | An array of buttons for the alert. See buttons options. |
  147. * | enableBackdropDismiss | `boolean` | Whether the alert should be dismissed by tapping the backdrop. Default true. |
  148. *
  149. *
  150. * Input options
  151. *
  152. * | Property | Type | Description |
  153. * |-------------|-----------|-----------------------------------------------------------------|
  154. * | type | `string` | The type the input should be: text, tel, number, etc. |
  155. * | name | `string` | The name for the input. |
  156. * | placeholder | `string` | The input's placeholder (for textual/numeric inputs) |
  157. * | value | `string` | The input's value. |
  158. * | label | `string` | The input's label (only for radio/checkbox inputs) |
  159. * | checked | `boolean` | Whether or not the input is checked. |
  160. * | id | `string` | The input's id. |
  161. *
  162. * Button options
  163. *
  164. * | Property | Type | Description |
  165. * |----------|----------|-----------------------------------------------------------------|
  166. * | text | `string` | The buttons displayed text. |
  167. * | handler | `any` | Emitted when the button is pressed. |
  168. * | cssClass | `string` | An additional CSS class for the button. |
  169. * | role | `string` | The buttons role, null or `cancel`. |
  170. *
  171. * ### Dismissing And Async Navigation
  172. *
  173. * After an alert has been dismissed, the app may need to also transition
  174. * to another page depending on the handler's logic. However, because multiple
  175. * transitions were fired at roughly the same time, it's difficult for the
  176. * nav controller to cleanly animate multiple transitions that may
  177. * have been kicked off asynchronously. This is further described in the
  178. * [`Nav Transition Promises`](../../nav/NavController) section. For alerts,
  179. * this means it's best to wait for the alert to finish its transition
  180. * out before starting a new transition on the same nav controller.
  181. *
  182. * In the example below, after the alert button has been clicked, its handler
  183. * waits on async operation to complete, *then* it uses `pop` to navigate
  184. * back a page in the same stack. The potential problem is that the async operation
  185. * may have been completed before the alert has even finished its transition
  186. * out. In this case, it's best to ensure the alert has finished its transition
  187. * out first, *then* start the next transition.
  188. *
  189. * ```ts
  190. * const alert = this.alertCtrl.create({
  191. * title: 'Hello',
  192. * buttons: [{
  193. * text: 'Ok',
  194. * handler: () => {
  195. * // user has clicked the alert button
  196. * // begin the alert's dismiss transition
  197. * const navTransition = alert.dismiss();
  198. *
  199. * // start some async method
  200. * someAsyncOperation().then(() => {
  201. * // once the async operation has completed
  202. * // then run the next nav transition after the
  203. * // first transition has finished animating out
  204. *
  205. * navTransition.then(() => {
  206. * this.nav.pop();
  207. * });
  208. * });
  209. * return false;
  210. * }
  211. * }]
  212. * });
  213. *
  214. * alert.present();
  215. * ```
  216. *
  217. * It's important to note that the handler returns `false`. A feature of
  218. * button handlers is that they automatically dismiss the alert when their button
  219. * was clicked, however, we'll need more control regarding the transition. Because
  220. * the handler returns `false`, then the alert does not automatically dismiss
  221. * itself. Instead, you now have complete control of when the alert has finished
  222. * transitioning, and the ability to wait for the alert to finish transitioning
  223. * out before starting a new transition.
  224. *
  225. *
  226. * @demo /docs/demos/src/alert/
  227. */
  228. var AlertController = (function () {
  229. function AlertController(_app, config) {
  230. this._app = _app;
  231. this.config = config;
  232. }
  233. /**
  234. * Display an alert with a title, inputs, and buttons
  235. * @param {AlertOptions} opts Alert. See the table below
  236. */
  237. AlertController.prototype.create = function (opts) {
  238. if (opts === void 0) { opts = {}; }
  239. return new alert_1.Alert(this._app, opts, this.config);
  240. };
  241. AlertController.decorators = [
  242. { type: core_1.Injectable },
  243. ];
  244. /** @nocollapse */
  245. AlertController.ctorParameters = function () { return [
  246. { type: app_1.App, },
  247. { type: config_1.Config, },
  248. ]; };
  249. return AlertController;
  250. }());
  251. exports.AlertController = AlertController;
  252. });
  253. //# sourceMappingURL=alert-controller.js.map