123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. import { AlertCmp } from './alert-component';
  12. import { AlertMdPopIn, AlertMdPopOut, AlertPopIn, AlertPopOut, AlertWpPopIn, AlertWpPopOut } from './alert-transitions';
  13. import { isPresent } from '../../util/util';
  14. import { ViewController } from '../../navigation/view-controller';
  15. /**
  16. * @hidden
  17. */
  18. var Alert = (function (_super) {
  19. __extends(Alert, _super);
  20. function Alert(app, opts, config) {
  21. if (opts === void 0) { opts = {}; }
  22. var _this = this;
  23. opts.inputs = opts.inputs || [];
  24. opts.buttons = opts.buttons || [];
  25. opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
  26. _this = _super.call(this, AlertCmp, opts, null) || this;
  27. _this._app = app;
  28. _this.isOverlay = true;
  29. config.setTransition('alert-pop-in', AlertPopIn);
  30. config.setTransition('alert-pop-out', AlertPopOut);
  31. config.setTransition('alert-md-pop-in', AlertMdPopIn);
  32. config.setTransition('alert-md-pop-out', AlertMdPopOut);
  33. config.setTransition('alert-wp-pop-in', AlertWpPopIn);
  34. config.setTransition('alert-wp-pop-out', AlertWpPopOut);
  35. return _this;
  36. }
  37. /**
  38. * @hidden
  39. */
  40. Alert.prototype.getTransitionName = function (direction) {
  41. var key = (direction === 'back' ? 'alertLeave' : 'alertEnter');
  42. return this._nav && this._nav.config.get(key);
  43. };
  44. /**
  45. * @param {string} title Alert title
  46. */
  47. Alert.prototype.setTitle = function (title) {
  48. this.data.title = title;
  49. return this;
  50. };
  51. /**
  52. * @param {string} subTitle Alert subtitle
  53. */
  54. Alert.prototype.setSubTitle = function (subTitle) {
  55. this.data.subTitle = subTitle;
  56. return this;
  57. };
  58. /**
  59. * @param {string} message Alert message content
  60. */
  61. Alert.prototype.setMessage = function (message) {
  62. this.data.message = message;
  63. return this;
  64. };
  65. /**
  66. * @param {object} input Alert input
  67. */
  68. Alert.prototype.addInput = function (input) {
  69. this.data.inputs.push(input);
  70. return this;
  71. };
  72. /**
  73. * @param {any} button Alert button
  74. */
  75. Alert.prototype.addButton = function (button) {
  76. this.data.buttons.push(button);
  77. return this;
  78. };
  79. /**
  80. * @param {string} cssClass Set the CSS class names on the alert's outer wrapper.
  81. */
  82. Alert.prototype.setCssClass = function (cssClass) {
  83. this.data.cssClass = cssClass;
  84. return this;
  85. };
  86. /**
  87. * @param {string} mode Set the mode of the alert (ios, md, wp).
  88. */
  89. Alert.prototype.setMode = function (mode) {
  90. this.data.mode = mode;
  91. };
  92. /**
  93. * Present the alert instance.
  94. *
  95. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  96. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  97. */
  98. Alert.prototype.present = function (navOptions) {
  99. if (navOptions === void 0) { navOptions = {}; }
  100. navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
  101. return this._app.present(this, navOptions);
  102. };
  103. return Alert;
  104. }(ViewController));
  105. export { Alert };
  106. //# sourceMappingURL=alert.js.map