a zip code crypto-currency system good for red ONLY

fab-container.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import { Component, ContentChild, ContentChildren } from '@angular/core';
  2. import { Platform } from '../../platform/platform';
  3. import { UIEventManager } from '../../gestures/ui-event-manager';
  4. import { FabButton } from './fab';
  5. import { FabList } from './fab-list';
  6. /**
  7. * @name FabContainer
  8. * @module ionic
  9. *
  10. * @description
  11. * `<ion-fab>` is not a FAB button by itself but a container that assist the fab button (`<button ion-fab>`) allowing it
  12. * to be placed in fixed position that does not scroll with the content. It is also used to implement "material design speed dial",
  13. * ie. a FAB buttons displays a small lists of related actions when clicked.
  14. *
  15. * @property [top] - Places the container on the top of the content
  16. * @property [bottom] - Places the container on the bottom of the content
  17. * @property [left] - Places the container on the left
  18. * @property [right] - Places the container on the right
  19. * @property [middle] - Places the container on the middle vertically
  20. * @property [center] - Places the container on the center horizontally
  21. * @property [edge] - Used to place the container between the content and the header/footer
  22. *
  23. * @usage
  24. *
  25. * ```html
  26. * <!-- this fab is placed at top right -->
  27. * <ion-content>
  28. * <ion-fab top right>
  29. * <button ion-fab>Button</button>
  30. * </ion-fab>
  31. *
  32. * <!-- this fab is placed at the center of the content viewport -->
  33. * <ion-fab center middle>
  34. * <button ion-fab>Button</button>
  35. * </ion-fab>
  36. * </ion-content>
  37. * ```
  38. *
  39. * Ionic's FAB also supports "material design's fab speed dial". It is a normal fab button
  40. * that shows a list of related actions when clicked.
  41. *
  42. * The same `ion-fab` container can contain several `ion-fab-list` with different side values:
  43. * `top`, `bottom`, `left` and `right`. For example, if you want to have a list of button that are
  44. * on the top of the main button, you should use `side="top"` and so on. By default, if side is ommited, `side="bottom"`.
  45. *
  46. * ```html
  47. * <ion-content>
  48. * <!-- this fab is placed at bottom right -->
  49. * <ion-fab bottom right >
  50. * <button ion-fab>Share</button>
  51. * <ion-fab-list side="top">
  52. * <button ion-fab>Facebook</button>
  53. * <button ion-fab>Twitter</button>
  54. * <button ion-fab>Youtube</button>
  55. * </ion-fab-list>
  56. * <ion-fab-list side="left">
  57. * <button ion-fab>Vimeo</button>
  58. * </ion-fab-list>
  59. * </ion-fab>
  60. * </ion-content>
  61. * ```
  62. *
  63. * A FAB speed dial can also be closed programatically.
  64. *
  65. * ```html
  66. * <ion-content>
  67. * <ion-fab bottom right #fab>
  68. * <button ion-fab>Share</button>
  69. * <ion-fab-list side="top">
  70. * <button ion-fab (click)="share('facebook', fab)">Facebook</button>
  71. * <button ion-fab (click)="share('twitter', fab)">Twitter</button>
  72. * </ion-fab-list>
  73. * </ion-fab>
  74. * </ion-content>
  75. * ```
  76. *
  77. * ```ts
  78. * share(socialNet: string, fab: FabContainer) {
  79. * fab.close();
  80. * console.log("Sharing in", socialNet);
  81. * }
  82. * ```
  83. *
  84. * @demo /docs/demos/src/fab/
  85. * @see {@link /docs/components#fabs FAB Component Docs}
  86. */
  87. export class FabContainer {
  88. constructor(plt) {
  89. /**
  90. * @hidden
  91. */
  92. this._listsActive = false;
  93. this._events = new UIEventManager(plt);
  94. }
  95. /**
  96. * @hidden
  97. */
  98. ngAfterContentInit() {
  99. const mainButton = this._mainButton;
  100. if (!mainButton || !mainButton.getNativeElement()) {
  101. console.error('FAB container needs a main <button ion-fab>');
  102. return;
  103. }
  104. this._events.listen(mainButton.getNativeElement(), 'click', this.clickHandler.bind(this), { zone: true });
  105. }
  106. /**
  107. * @hidden
  108. */
  109. clickHandler(ev) {
  110. if (this.canActivateList(ev)) {
  111. this.toggleList();
  112. }
  113. }
  114. /**
  115. * @hidden
  116. */
  117. canActivateList(ev) {
  118. if (this._fabLists.length > 0 && this._mainButton && ev.target) {
  119. let ele = ev.target.closest('ion-fab>[ion-fab]');
  120. return (ele && ele === this._mainButton.getNativeElement());
  121. }
  122. return false;
  123. }
  124. /**
  125. * @hidden
  126. */
  127. toggleList() {
  128. this.setActiveLists(!this._listsActive);
  129. }
  130. /**
  131. * @hidden
  132. */
  133. setActiveLists(isActive) {
  134. if (isActive === this._listsActive) {
  135. return;
  136. }
  137. let lists = this._fabLists.toArray();
  138. for (let list of lists) {
  139. list.setVisible(isActive);
  140. }
  141. this._mainButton.setActiveClose(isActive);
  142. this._listsActive = isActive;
  143. }
  144. /**
  145. * Close an active FAB list container
  146. */
  147. close() {
  148. this.setActiveLists(false);
  149. }
  150. /**
  151. * @hidden
  152. */
  153. ngOnDestroy() {
  154. this._events.destroy();
  155. }
  156. }
  157. FabContainer.decorators = [
  158. { type: Component, args: [{
  159. selector: 'ion-fab',
  160. template: '<ng-content></ng-content>'
  161. },] },
  162. ];
  163. /** @nocollapse */
  164. FabContainer.ctorParameters = () => [
  165. { type: Platform, },
  166. ];
  167. FabContainer.propDecorators = {
  168. '_mainButton': [{ type: ContentChild, args: [FabButton,] },],
  169. '_fabLists': [{ type: ContentChildren, args: [FabList,] },],
  170. };
  171. //# sourceMappingURL=fab-container.js.map