a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. import { ChangeDetectionStrategy, Component, ContentChild, ContentChildren, ElementRef, Optional, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
  2. import { Button } from '../button/button';
  3. import { Config } from '../../config/config';
  4. import { Form } from '../../util/form';
  5. import { Icon } from '../icon/icon';
  6. import { Ion } from '../ion';
  7. import { Label } from '../label/label';
  8. import { ItemReorder } from './item-reorder';
  9. /**
  10. * @name Item
  11. * @description
  12. * An item can contain text, images, and anything else. Generally it is placed in a list with other
  13. * items. It can easily be swiped, deleted, reordered, edited, and more. An item is only required to
  14. * be in a [List](../../list/List) if manipulating the item via gestures is required. It requires an
  15. * [ItemSliding](../ItemSliding) wrapper element in order to be swiped.
  16. *
  17. *
  18. * ## Common Usage
  19. * There are a few elements that are considered items, but not all of them are styled to look the same.
  20. * The basic item can be written as an `<ion-item>` element or it can be added to any element by adding
  21. * `ion-item` as an attribute. List headers and item dividers, although styled differently, are also items
  22. * and can be written as `<ion-list-header>` and `<ion-item-divider>`, respectively.
  23. *
  24. * ### As an Element
  25. * A basic item should be written as a `<ion-item>` element when it is not clickable.
  26. *
  27. * ```html
  28. * <ion-item>
  29. * Item
  30. * </ion-item>
  31. * ```
  32. *
  33. * A list header should be written as `<ion-list-header>`.
  34. *
  35. * ```html
  36. * <ion-list-header>
  37. * List Header
  38. * </ion-list-header>
  39. * ```
  40. *
  41. * An item divider should be written as `<ion-item-divider>`.
  42. *
  43. * ```html
  44. * <ion-item-divider>
  45. * Item Divider
  46. * </ion-item-divider>
  47. * ```
  48. *
  49. * ### As an Attribute
  50. * The attribute `ion-item` should be added to a `<button>` when the item can be clicked or tapped. It
  51. * should be added to an `<a>` element when the item needs to contain a `href`. It can be added as an
  52. * attribute to any element to take on the item styling.
  53. *
  54. * ```html
  55. * <button ion-item (click)="buttonClick()">
  56. * Button Item
  57. * </button>
  58. *
  59. * <a ion-item href="https://www.ionicframework.com">
  60. * Anchor Item
  61. * </a>
  62. * ```
  63. *
  64. * Note: do not add `ion-item` as an attribute to an `<ion-list-header>` or `<ion-item-divider>` element
  65. * as they are already items and their styling will be changed to look like a basic item.
  66. *
  67. * ## Detail Arrows
  68. * By default, `<button>` and `<a>` elements with the `ion-item` attribute will display a right arrow icon
  69. * on `ios` mode. To hide the right arrow icon on either of these elements, add the `detail-none` attribute
  70. * to the item. To show the right arrow icon on an element that doesn't display it naturally, add the
  71. * `detail-push` attribute to the item.
  72. *
  73. * ```html
  74. * <ion-item detail-push>
  75. * Item with Detail Arrow
  76. * </ion-item>
  77. *
  78. * <button ion-item (click)="buttonClick()">
  79. * Button Item with Detail Arrow
  80. * </button>
  81. *
  82. * <a ion-item detail-none href="https://www.ionicframework.com">
  83. * Anchor Item with no Detail Arrow
  84. * </a>
  85. * ```
  86. *
  87. * This feature is not enabled by default for `md` and `wp` modes, but it can be enabled by setting the
  88. * Sass variables `$item-md-detail-push-show` and `$item-wp-detail-push-show`, respectively, to `true`.
  89. * It can also be disabled for ios by setting `$item-ios-detail-push-show` to `false`. See the
  90. * [theming documentation](http://ionicframework.com/docs/theming/overriding-ionic-variables/) for
  91. * more information on overriding Sass variables.
  92. *
  93. *
  94. * ## Item Placement
  95. * Items rely heavily on content projection to position content. The item grabs content based on the
  96. * element or attribute and positions it that way. This logic makes it possible to write a complex
  97. * item with simple, understandable markup without having to worry about styling and positioning
  98. * the elements.
  99. *
  100. * The below chart details the attributes item looks for and where it will place the element with
  101. * that attribute inside of the item:
  102. *
  103. * | Attribute | Description |
  104. * |----------------|----------------------------------------------------------------------------------------------------- |
  105. * | `item-start` | Placed to the left of all other elements, outside of the inner item. |
  106. * | `item-end` | Placed to the right of all other elements, inside of the inner item, outside of the input wrapper. |
  107. * | `item-content` | Placed to the right of any `ion-label`, inside of the input wrapper. |
  108. *
  109. * ### Checkboxes, Radios and Toggles
  110. * [Checkboxes](../../checkbox/Checkbox) are positioned in the same place as the `item-start` attribute.
  111. * [Radios](../../radio/RadioButton) and [Toggles](../../toggle/Toggle) are positioned in the same place
  112. * as the `item-end` attribute. All of these components can be positioned differently by adding the
  113. * `item-start` or `item-end` attribute.
  114. *
  115. * ### Content and Inputs
  116. * A [Label](../../label/Label) is placed inside of the item to the left of all content and inputs. The
  117. * following components are all placed in the same position as the `item-content` attribute: [Select](../../select/Select),
  118. * [Input](../../input/Input), [TextArea](../../input/TextArea), [DateTime](../../datetime/DateTime), and
  119. * [Range](../../range/Range).
  120. *
  121. * Any element directly placed inside of an `<ion-item>` that does not have one of the previously mentioned
  122. * attributes and isn't one of the above elements will be placed inside of a [Label](../../label/Label).
  123. *
  124. * ### Text Alignment
  125. * By default, Items will align text to the left and add an ellipsis when the text is wider than the item.
  126. * See the [Utility Attributes Documentation](../../../../theming/css-utilities/) for attributes that can
  127. * be added to `ion-item` to transform the text.
  128. *
  129. * @usage
  130. *
  131. * ```html
  132. * <ion-list>
  133. *
  134. * <ion-list-header>
  135. * Header
  136. * </ion-list-header>
  137. *
  138. * <ion-item>
  139. * Item
  140. * </ion-item>
  141. *
  142. * <ion-item detail-push>
  143. * Item with Detail Arrow
  144. * </ion-item>
  145. *
  146. * <button ion-item (click)="buttonClick()">
  147. * Button Item
  148. * </button>
  149. *
  150. * <ion-item-divider>
  151. * Item Divider
  152. * </ion-item-divider>
  153. *
  154. * <button ion-item detail-none (click)="buttonClick()">
  155. * Button Item with no Detail Arrow
  156. * </button>
  157. *
  158. * <a ion-item href="https://www.ionicframework.com">
  159. * Anchor Item
  160. * </a>
  161. *
  162. * <ion-item no-lines>
  163. * Item with no border
  164. * </ion-item>
  165. *
  166. * <ion-item text-wrap>
  167. * Multiline text that should wrap when it is too long
  168. * to fit on one line in the item.
  169. * </ion-item>
  170. *
  171. * </ion-list>
  172. * ```
  173. *
  174. *
  175. * @advanced
  176. *
  177. * ```html
  178. * <ion-list>
  179. *
  180. * <!-- List header with buttons on each side -->
  181. * <ion-list-header>
  182. * <button ion-button item-start (click)="buttonClick()">Button</button>
  183. * List Header
  184. * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
  185. * </ion-list-header>
  186. *
  187. * <!-- Loops through and creates multiple items -->
  188. * <ion-item *ngFor="let item of items">
  189. * Item {% raw %}{{item}}{% endraw %}
  190. * </ion-item>
  191. *
  192. * <!-- Button item with an icon on the left -->
  193. * <button ion-item>
  194. * <ion-icon name="star" item-start></ion-icon>
  195. * Button Item
  196. * </button>
  197. *
  198. * <!-- Item with a label and content -->
  199. * <ion-item>
  200. * <ion-label>
  201. * Item Label
  202. * </ion-label>
  203. * <div item-content>
  204. * Item Content next to the label
  205. * </div>
  206. * </ion-item>
  207. *
  208. * <!-- Item with left and right buttons -->
  209. * <ion-item>
  210. * <button ion-button item-start (click)="buttonClick()">Button</button>
  211. * Item
  212. * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
  213. * </ion-item>
  214. *
  215. * <!-- Item divider with a right button -->
  216. * <ion-item-divider>
  217. * Item Divider
  218. * <button ion-button item-end>Button</button>
  219. * </ion-item-divider>
  220. *
  221. * <!-- Disabled button item with left and right buttons -->
  222. * <button ion-item disabled>
  223. * <button ion-button item-start (click)="buttonClick()">
  224. * <ion-icon name="home"></ion-icon>
  225. * Left Icon
  226. * </button>
  227. * Disabled Button Item
  228. * <button ion-button outline item-end (click)="buttonClick()">
  229. * <ion-icon name="star"></ion-icon>
  230. * Left Icon
  231. * </button>
  232. * </button>
  233. *
  234. * <!-- Item with an avatar on the left and button on the right -->
  235. * <ion-item>
  236. * <ion-avatar item-start>
  237. * <img src="img/my-avatar.png">
  238. * </ion-avatar>
  239. * Avatar Item
  240. * <button ion-button outline item-end>View</button>
  241. * </ion-item>
  242. *
  243. * <!-- Item with a thumbnail on the right -->
  244. * <ion-item>
  245. * <h2>Item</h2>
  246. * <p>Item Paragraph</p>
  247. * <ion-thumbnail item-end>
  248. * <img src="img/my-thumbnail.png">
  249. * </ion-thumbnail>
  250. * </ion-item>
  251. *
  252. * <!-- Sliding item -->
  253. * <ion-item-sliding>
  254. * <ion-item>
  255. * Item
  256. * </ion-item>
  257. * <ion-item-options>
  258. * <button ion-button color="primary" (click)="archive()">Archive</button>
  259. * </ion-item-options>
  260. * </ion-item-sliding>
  261. *
  262. * </ion-list>
  263. * ```
  264. *
  265. *
  266. * @demo /docs/demos/src/item/
  267. * @see {@link /docs/components#lists List Component Docs}
  268. * @see {@link ../../list/List List API Docs}
  269. * @see {@link ../ItemSliding ItemSliding API Docs}
  270. */
  271. export class Item extends Ion {
  272. constructor(form, config, elementRef, renderer, reorder) {
  273. super(config, elementRef, renderer, 'item');
  274. this._ids = -1;
  275. this._inputs = [];
  276. this._viewLabel = true;
  277. this._name = 'item';
  278. /**
  279. * @hidden
  280. */
  281. this.labelId = null;
  282. this._setName(elementRef);
  283. this._hasReorder = !!reorder;
  284. this.id = form.nextId().toString();
  285. this.labelId = 'lbl-' + this.id;
  286. // auto add "tappable" attribute to ion-item components that have a click listener
  287. if (!renderer.orgListen) {
  288. renderer.orgListen = renderer.listen;
  289. renderer.listen = function (renderElement, name, callback) {
  290. if (name === 'click' && renderElement.setAttribute) {
  291. renderElement.setAttribute('tappable', '');
  292. }
  293. return renderer.orgListen(renderElement, name, callback);
  294. };
  295. }
  296. }
  297. /**
  298. * @hidden
  299. */
  300. registerInput(type) {
  301. this._inputs.push(type);
  302. return this.id + '-' + (++this._ids);
  303. }
  304. /**
  305. * @hidden
  306. */
  307. ngAfterContentInit() {
  308. if (this._viewLabel && this._inputs.length) {
  309. let labelText = this.getLabelText().trim();
  310. this._viewLabel = (labelText.length > 0);
  311. }
  312. if (this._inputs.length > 1) {
  313. this.setElementClass('item-multiple-inputs', true);
  314. }
  315. }
  316. /**
  317. * @hidden
  318. */
  319. _updateColor(newColor, componentName) {
  320. componentName = componentName || 'item'; // item-radio
  321. this._setColor(newColor, componentName);
  322. }
  323. /**
  324. * @hidden
  325. */
  326. _setName(elementRef) {
  327. let nodeName = elementRef.nativeElement.nodeName.replace('ION-', '');
  328. if (nodeName === 'LIST-HEADER' || nodeName === 'ITEM-DIVIDER') {
  329. this._name = nodeName;
  330. }
  331. }
  332. /**
  333. * @hidden
  334. */
  335. getLabelText() {
  336. return this._label ? this._label.text : '';
  337. }
  338. /**
  339. * @hidden
  340. */
  341. set contentLabel(label) {
  342. if (label) {
  343. this._label = label;
  344. label.id = this.labelId;
  345. if (label.type) {
  346. this.setElementClass('item-label-' + label.type, true);
  347. }
  348. this._viewLabel = false;
  349. }
  350. }
  351. /**
  352. * @hidden
  353. */
  354. set viewLabel(label) {
  355. if (!this._label) {
  356. this._label = label;
  357. }
  358. }
  359. /**
  360. * @hidden
  361. */
  362. set _buttons(buttons) {
  363. buttons.forEach(button => {
  364. if (!button._size) {
  365. button.setElementClass('item-button', true);
  366. }
  367. });
  368. }
  369. /**
  370. * @hidden
  371. */
  372. set _icons(icons) {
  373. icons.forEach(icon => {
  374. icon.setElementClass('item-icon', true);
  375. });
  376. }
  377. }
  378. Item.decorators = [
  379. { type: Component, args: [{
  380. selector: 'ion-list-header,ion-item,[ion-item],ion-item-divider',
  381. template: '<ng-content select="[item-start],[item-left],ion-checkbox:not([item-end]):not([item-right])"></ng-content>' +
  382. '<div class="item-inner">' +
  383. '<div class="input-wrapper">' +
  384. '<ng-content select="ion-label"></ng-content>' +
  385. '<ion-label *ngIf="_viewLabel">' +
  386. '<ng-content></ng-content>' +
  387. '</ion-label>' +
  388. '<ng-content select="ion-select,ion-input,ion-textarea,ion-datetime,ion-range,[item-content]"></ng-content>' +
  389. '</div>' +
  390. '<ng-content select="[item-end],[item-right],ion-radio,ion-toggle"></ng-content>' +
  391. '<ion-reorder *ngIf="_hasReorder"></ion-reorder>' +
  392. '</div>' +
  393. '<div class="button-effect"></div>',
  394. host: {
  395. 'class': 'item'
  396. },
  397. changeDetection: ChangeDetectionStrategy.OnPush,
  398. encapsulation: ViewEncapsulation.None,
  399. },] },
  400. ];
  401. /** @nocollapse */
  402. Item.ctorParameters = () => [
  403. { type: Form, },
  404. { type: Config, },
  405. { type: ElementRef, },
  406. { type: Renderer, },
  407. { type: ItemReorder, decorators: [{ type: Optional },] },
  408. ];
  409. Item.propDecorators = {
  410. 'contentLabel': [{ type: ContentChild, args: [Label,] },],
  411. 'viewLabel': [{ type: ViewChild, args: [Label,] },],
  412. '_buttons': [{ type: ContentChildren, args: [Button,] },],
  413. '_icons': [{ type: ContentChildren, args: [Icon,] },],
  414. };
  415. //# sourceMappingURL=item.js.map