loading.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 { isPresent } from '../../util/util';
  12. import { PORTAL_LOADING } from '../app/app-constants';
  13. import { LoadingCmp } from './loading-component';
  14. import { LoadingMdPopIn, LoadingMdPopOut, LoadingPopIn, LoadingPopOut, LoadingWpPopIn, LoadingWpPopOut } from './loading-transitions';
  15. import { ViewController } from '../../navigation/view-controller';
  16. /**
  17. * @hidden
  18. */
  19. var Loading = (function (_super) {
  20. __extends(Loading, _super);
  21. function Loading(app, opts, config) {
  22. if (opts === void 0) { opts = {}; }
  23. var _this = this;
  24. opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
  25. opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : false;
  26. opts.dismissOnPageChange = isPresent(opts.dismissOnPageChange) ? !!opts.dismissOnPageChange : false;
  27. _this = _super.call(this, LoadingCmp, opts, null) || this;
  28. _this._app = app;
  29. _this.isOverlay = true;
  30. config.setTransition('loading-pop-in', LoadingPopIn);
  31. config.setTransition('loading-pop-out', LoadingPopOut);
  32. config.setTransition('loading-md-pop-in', LoadingMdPopIn);
  33. config.setTransition('loading-md-pop-out', LoadingMdPopOut);
  34. config.setTransition('loading-wp-pop-in', LoadingWpPopIn);
  35. config.setTransition('loading-wp-pop-out', LoadingWpPopOut);
  36. return _this;
  37. }
  38. /**
  39. * @hidden
  40. */
  41. Loading.prototype.getTransitionName = function (direction) {
  42. var key = (direction === 'back' ? 'loadingLeave' : 'loadingEnter');
  43. return this._nav && this._nav.config.get(key);
  44. };
  45. /**
  46. * @param {string} content sets the html content for the loading indicator.
  47. */
  48. Loading.prototype.setContent = function (content) {
  49. this.data.content = content;
  50. return this;
  51. };
  52. /**
  53. * @param {string} spinner sets the name of the SVG spinner for the loading indicator.
  54. */
  55. Loading.prototype.setSpinner = function (spinner) {
  56. this.data.spinner = spinner;
  57. return this;
  58. };
  59. /**
  60. * @param {string} cssClass sets additional classes for custom styles, separated by spaces.
  61. */
  62. Loading.prototype.setCssClass = function (cssClass) {
  63. this.data.cssClass = cssClass;
  64. return this;
  65. };
  66. /**
  67. * @param {boolean} showBackdrop sets whether to show the backdrop.
  68. */
  69. Loading.prototype.setShowBackdrop = function (showBackdrop) {
  70. this.data.showBackdrop = showBackdrop;
  71. return this;
  72. };
  73. /**
  74. * @param {number} dur how many milliseconds to wait before hiding the indicator.
  75. */
  76. Loading.prototype.setDuration = function (dur) {
  77. this.data.duration = dur;
  78. return this;
  79. };
  80. /**
  81. * Present the loading instance.
  82. *
  83. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  84. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  85. */
  86. Loading.prototype.present = function (navOptions) {
  87. if (navOptions === void 0) { navOptions = {}; }
  88. return this._app.present(this, navOptions, PORTAL_LOADING);
  89. };
  90. /**
  91. * Dismiss all loading components which have been presented.
  92. */
  93. Loading.prototype.dismissAll = function () {
  94. this._nav && this._nav.popAll();
  95. };
  96. return Loading;
  97. }(ViewController));
  98. export { Loading };
  99. //# sourceMappingURL=loading.js.map