a zip code crypto-currency system good for red ONLY

popover-component.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { Component, ComponentFactoryResolver, ElementRef, HostListener, Renderer, ViewChild, ViewContainerRef } from '@angular/core';
  2. import { Config } from '../../config/config';
  3. import { KEY_ESCAPE } from '../../platform/key';
  4. import { NavParams } from '../../navigation/nav-params';
  5. import { ViewController } from '../../navigation/view-controller';
  6. import { BLOCK_ALL, GestureController } from '../../gestures/gesture-controller';
  7. import { ModuleLoader } from '../../util/module-loader';
  8. /**
  9. * @hidden
  10. */
  11. var PopoverCmp = (function () {
  12. function PopoverCmp(_cfr, _elementRef, _renderer, _config, _navParams, _viewCtrl, gestureCtrl, moduleLoader) {
  13. this._cfr = _cfr;
  14. this._elementRef = _elementRef;
  15. this._renderer = _renderer;
  16. this._config = _config;
  17. this._navParams = _navParams;
  18. this._viewCtrl = _viewCtrl;
  19. this.moduleLoader = moduleLoader;
  20. this._gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
  21. this.d = _navParams.data.opts;
  22. _renderer.setElementClass(_elementRef.nativeElement, "popover-" + _config.get('mode'), true);
  23. if (this.d.cssClass) {
  24. this.d.cssClass.split(' ').forEach(function (cssClass) {
  25. // Make sure the class isn't whitespace, otherwise it throws exceptions
  26. if (cssClass.trim() !== '')
  27. _renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
  28. });
  29. }
  30. this.id = (++popoverIds);
  31. }
  32. PopoverCmp.prototype.ionViewPreLoad = function () {
  33. this._load(this._navParams.data.component);
  34. };
  35. PopoverCmp.prototype._load = function (component) {
  36. if (component) {
  37. var cfr = this.moduleLoader.getComponentFactoryResolver(component);
  38. if (!cfr) {
  39. cfr = this._cfr;
  40. }
  41. var componentFactory = cfr.resolveComponentFactory(component);
  42. // ******** DOM WRITE ****************
  43. var componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []);
  44. this._viewCtrl._setInstance(componentRef.instance);
  45. this._enabled = true;
  46. // Subscribe to events in order to block gestures
  47. // TODO, should we unsubscribe? memory leak?
  48. this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this));
  49. this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this));
  50. }
  51. };
  52. PopoverCmp.prototype._viewWillEnter = function () {
  53. this._gestureBlocker.block();
  54. };
  55. PopoverCmp.prototype._viewDidLeave = function () {
  56. this._gestureBlocker.unblock();
  57. };
  58. PopoverCmp.prototype._setCssClass = function (componentRef, className) {
  59. this._renderer.setElementClass(componentRef.location.nativeElement, className, true);
  60. };
  61. PopoverCmp.prototype._bdClick = function () {
  62. if (this._enabled && this.d.enableBackdropDismiss) {
  63. return this._viewCtrl.dismiss(null, 'backdrop');
  64. }
  65. };
  66. PopoverCmp.prototype._keyUp = function (ev) {
  67. if (this._enabled && ev.keyCode === KEY_ESCAPE && this._viewCtrl.isLast()) {
  68. this._bdClick();
  69. }
  70. };
  71. PopoverCmp.prototype.ngOnDestroy = function () {
  72. (void 0) /* assert */;
  73. this._gestureBlocker.destroy();
  74. };
  75. PopoverCmp.decorators = [
  76. { type: Component, args: [{
  77. selector: 'ion-popover',
  78. template: '<ion-backdrop (click)="_bdClick()" [hidden]="!d.showBackdrop"></ion-backdrop>' +
  79. '<div class="popover-wrapper">' +
  80. '<div class="popover-arrow"></div>' +
  81. '<div class="popover-content">' +
  82. '<div class="popover-viewport">' +
  83. '<div #viewport nav-viewport></div>' +
  84. '</div>' +
  85. '</div>' +
  86. '</div>'
  87. },] },
  88. ];
  89. /** @nocollapse */
  90. PopoverCmp.ctorParameters = function () { return [
  91. { type: ComponentFactoryResolver, },
  92. { type: ElementRef, },
  93. { type: Renderer, },
  94. { type: Config, },
  95. { type: NavParams, },
  96. { type: ViewController, },
  97. { type: GestureController, },
  98. { type: ModuleLoader, },
  99. ]; };
  100. PopoverCmp.propDecorators = {
  101. '_viewport': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
  102. '_keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
  103. };
  104. return PopoverCmp;
  105. }());
  106. export { PopoverCmp };
  107. var popoverIds = -1;
  108. //# sourceMappingURL=popover-component.js.map