123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. (function (factory) {
  12. if (typeof module === "object" && typeof module.exports === "object") {
  13. var v = factory(require, exports);
  14. if (v !== undefined) module.exports = v;
  15. }
  16. else if (typeof define === "function" && define.amd) {
  17. define(["require", "exports", "./alert-component", "./alert-transitions", "../../util/util", "../../navigation/view-controller"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var alert_component_1 = require("./alert-component");
  23. var alert_transitions_1 = require("./alert-transitions");
  24. var util_1 = require("../../util/util");
  25. var view_controller_1 = require("../../navigation/view-controller");
  26. /**
  27. * @hidden
  28. */
  29. var Alert = (function (_super) {
  30. __extends(Alert, _super);
  31. function Alert(app, opts, config) {
  32. if (opts === void 0) { opts = {}; }
  33. var _this = this;
  34. opts.inputs = opts.inputs || [];
  35. opts.buttons = opts.buttons || [];
  36. opts.enableBackdropDismiss = util_1.isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
  37. _this = _super.call(this, alert_component_1.AlertCmp, opts, null) || this;
  38. _this._app = app;
  39. _this.isOverlay = true;
  40. config.setTransition('alert-pop-in', alert_transitions_1.AlertPopIn);
  41. config.setTransition('alert-pop-out', alert_transitions_1.AlertPopOut);
  42. config.setTransition('alert-md-pop-in', alert_transitions_1.AlertMdPopIn);
  43. config.setTransition('alert-md-pop-out', alert_transitions_1.AlertMdPopOut);
  44. config.setTransition('alert-wp-pop-in', alert_transitions_1.AlertWpPopIn);
  45. config.setTransition('alert-wp-pop-out', alert_transitions_1.AlertWpPopOut);
  46. return _this;
  47. }
  48. /**
  49. * @hidden
  50. */
  51. Alert.prototype.getTransitionName = function (direction) {
  52. var key = (direction === 'back' ? 'alertLeave' : 'alertEnter');
  53. return this._nav && this._nav.config.get(key);
  54. };
  55. /**
  56. * @param {string} title Alert title
  57. */
  58. Alert.prototype.setTitle = function (title) {
  59. this.data.title = title;
  60. return this;
  61. };
  62. /**
  63. * @param {string} subTitle Alert subtitle
  64. */
  65. Alert.prototype.setSubTitle = function (subTitle) {
  66. this.data.subTitle = subTitle;
  67. return this;
  68. };
  69. /**
  70. * @param {string} message Alert message content
  71. */
  72. Alert.prototype.setMessage = function (message) {
  73. this.data.message = message;
  74. return this;
  75. };
  76. /**
  77. * @param {object} input Alert input
  78. */
  79. Alert.prototype.addInput = function (input) {
  80. this.data.inputs.push(input);
  81. return this;
  82. };
  83. /**
  84. * @param {any} button Alert button
  85. */
  86. Alert.prototype.addButton = function (button) {
  87. this.data.buttons.push(button);
  88. return this;
  89. };
  90. /**
  91. * @param {string} cssClass Set the CSS class names on the alert's outer wrapper.
  92. */
  93. Alert.prototype.setCssClass = function (cssClass) {
  94. this.data.cssClass = cssClass;
  95. return this;
  96. };
  97. /**
  98. * @param {string} mode Set the mode of the alert (ios, md, wp).
  99. */
  100. Alert.prototype.setMode = function (mode) {
  101. this.data.mode = mode;
  102. };
  103. /**
  104. * Present the alert instance.
  105. *
  106. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  107. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  108. */
  109. Alert.prototype.present = function (navOptions) {
  110. if (navOptions === void 0) { navOptions = {}; }
  111. navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
  112. return this._app.present(this, navOptions);
  113. };
  114. return Alert;
  115. }(view_controller_1.ViewController));
  116. exports.Alert = Alert;
  117. });
  118. //# sourceMappingURL=alert.js.map