a zip code crypto-currency system good for red ONLY

action-sheet-component.js 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import { Component, ElementRef, HostListener, Renderer, ViewEncapsulation } from '@angular/core';
  2. import { BLOCK_ALL, GestureController } from '../../gestures/gesture-controller';
  3. import { Config } from '../../config/config';
  4. import { KEY_ESCAPE } from '../../platform/key';
  5. import { NavParams } from '../../navigation/nav-params';
  6. import { ViewController } from '../../navigation/view-controller';
  7. /**
  8. * @hidden
  9. */
  10. export class ActionSheetCmp {
  11. constructor(_viewCtrl, config, _elementRef, gestureCtrl, params, renderer) {
  12. this._viewCtrl = _viewCtrl;
  13. this._elementRef = _elementRef;
  14. this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
  15. this.d = params.data;
  16. this.mode = config.get('mode');
  17. renderer.setElementClass(_elementRef.nativeElement, `action-sheet-${this.mode}`, true);
  18. if (this.d.cssClass) {
  19. this.d.cssClass.split(' ').forEach(cssClass => {
  20. // Make sure the class isn't whitespace, otherwise it throws exceptions
  21. if (cssClass.trim() !== '')
  22. renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
  23. });
  24. }
  25. this.id = (++actionSheetIds);
  26. if (this.d.title) {
  27. this.hdrId = 'acst-hdr-' + this.id;
  28. }
  29. if (this.d.subTitle) {
  30. this.descId = 'acst-subhdr-' + this.id;
  31. }
  32. }
  33. ionViewDidLoad() {
  34. // normalize the data
  35. this.d.buttons = this.d.buttons.map(button => {
  36. if (typeof button === 'string') {
  37. button = { text: button };
  38. }
  39. if (!button.cssClass) {
  40. button.cssClass = '';
  41. }
  42. switch (button.role) {
  43. case 'cancel':
  44. this.cancelButton = button;
  45. return null;
  46. case 'destructive':
  47. button.cssClass = (button.cssClass + ' ' || '') + 'action-sheet-destructive';
  48. break;
  49. case 'selected':
  50. button.cssClass = (button.cssClass + ' ' || '') + 'action-sheet-selected';
  51. break;
  52. }
  53. return button;
  54. }).filter(button => button !== null);
  55. }
  56. ionViewWillEnter() {
  57. this.gestureBlocker.block();
  58. }
  59. ionViewDidLeave() {
  60. this.gestureBlocker.unblock();
  61. }
  62. ionViewDidEnter() {
  63. const focusableEle = this._elementRef.nativeElement.querySelector('button');
  64. if (focusableEle) {
  65. focusableEle.focus();
  66. }
  67. this.enabled = true;
  68. }
  69. keyUp(ev) {
  70. if (this.enabled && ev.keyCode === KEY_ESCAPE && this._viewCtrl.isLast()) {
  71. (void 0) /* console.debug */;
  72. this.bdClick();
  73. }
  74. }
  75. click(button) {
  76. if (!this.enabled) {
  77. return;
  78. }
  79. let shouldDismiss = true;
  80. if (button.handler) {
  81. // a handler has been provided, execute it
  82. if (button.handler() === false) {
  83. // if the return value of the handler is false then do not dismiss
  84. shouldDismiss = false;
  85. }
  86. }
  87. if (shouldDismiss) {
  88. this.dismiss(button.role);
  89. }
  90. }
  91. bdClick() {
  92. if (this.enabled && this.d.enableBackdropDismiss) {
  93. if (this.cancelButton) {
  94. this.click(this.cancelButton);
  95. }
  96. else {
  97. this.dismiss('backdrop');
  98. }
  99. }
  100. }
  101. dismiss(role) {
  102. const opts = {
  103. minClickBlockDuration: 400
  104. };
  105. return this._viewCtrl.dismiss(null, role, opts);
  106. }
  107. ngOnDestroy() {
  108. (void 0) /* assert */;
  109. this.d = this.cancelButton = null;
  110. this.gestureBlocker.destroy();
  111. }
  112. }
  113. ActionSheetCmp.decorators = [
  114. { type: Component, args: [{
  115. selector: 'ion-action-sheet',
  116. template: '<ion-backdrop (click)="bdClick()" [class.backdrop-no-tappable]="!d.enableBackdropDismiss"></ion-backdrop>' +
  117. '<div class="action-sheet-wrapper">' +
  118. '<div class="action-sheet-container">' +
  119. '<div class="action-sheet-group">' +
  120. '<div class="action-sheet-title" id="{{hdrId}}" *ngIf="d.title">{{d.title}}</div>' +
  121. '<div class="action-sheet-sub-title" id="{{descId}}" *ngIf="d.subTitle">{{d.subTitle}}</div>' +
  122. '<button ion-button="action-sheet-button" (click)="click(b)" *ngFor="let b of d.buttons" class="disable-hover" [attr.icon-start]="b.icon ? \'\' : null" [ngClass]="b.cssClass">' +
  123. '<ion-icon [name]="b.icon" *ngIf="b.icon" class="action-sheet-icon"></ion-icon>' +
  124. '{{b.text}}' +
  125. '</button>' +
  126. '</div>' +
  127. '<div class="action-sheet-group action-sheet-group-cancel" *ngIf="cancelButton">' +
  128. '<button ion-button="action-sheet-button" (click)="click(cancelButton)" class="action-sheet-cancel disable-hover" [attr.icon-start]="cancelButton.icon ? \'\' : null" [ngClass]="cancelButton.cssClass">' +
  129. '<ion-icon [name]="cancelButton.icon" *ngIf="cancelButton.icon" class="action-sheet-icon"></ion-icon>' +
  130. '{{cancelButton.text}}' +
  131. '</button>' +
  132. '</div>' +
  133. '</div>' +
  134. '</div>',
  135. host: {
  136. 'role': 'dialog',
  137. '[attr.aria-labelledby]': 'hdrId',
  138. '[attr.aria-describedby]': 'descId'
  139. },
  140. encapsulation: ViewEncapsulation.None,
  141. },] },
  142. ];
  143. /** @nocollapse */
  144. ActionSheetCmp.ctorParameters = () => [
  145. { type: ViewController, },
  146. { type: Config, },
  147. { type: ElementRef, },
  148. { type: GestureController, },
  149. { type: NavParams, },
  150. { type: Renderer, },
  151. ];
  152. ActionSheetCmp.propDecorators = {
  153. 'keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
  154. };
  155. let actionSheetIds = -1;
  156. //# sourceMappingURL=action-sheet-component.js.map