a zip code crypto-currency system good for red ONLY

button.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. (function (factory) {
  12. if (typeof module === "object" && typeof module.exports === "object") {
  13. var v = factory(require, exports);
  14. if (v !== undefined) module.exports = v;
  15. }
  16. else if (typeof define === "function" && define.amd) {
  17. define(["require", "exports", "@angular/core", "../../config/config", "../ion", "../../util/util"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var core_1 = require("@angular/core");
  23. var config_1 = require("../../config/config");
  24. var ion_1 = require("../ion");
  25. var util_1 = require("../../util/util");
  26. /**
  27. * @name Button
  28. * @module ionic
  29. * @description
  30. * Buttons are simple components in Ionic. They can consist of text and icons
  31. * and be enhanced by a wide range of attributes.
  32. *
  33. * @usage
  34. *
  35. * ```html
  36. *
  37. * <!-- Colors -->
  38. * <button ion-button>Default</button>
  39. *
  40. * <button ion-button color="secondary">Secondary</button>
  41. *
  42. * <button ion-button color="danger">Danger</button>
  43. *
  44. * <button ion-button color="light">Light</button>
  45. *
  46. * <button ion-button color="dark">Dark</button>
  47. *
  48. * <!-- Shapes -->
  49. * <button ion-button full>Full Button</button>
  50. *
  51. * <button ion-button block>Block Button</button>
  52. *
  53. * <button ion-button round>Round Button</button>
  54. *
  55. * <!-- Outline -->
  56. * <button ion-button full outline>Outline + Full</button>
  57. *
  58. * <button ion-button block outline>Outline + Block</button>
  59. *
  60. * <button ion-button round outline>Outline + Round</button>
  61. *
  62. * <!-- Icons -->
  63. * <button ion-button icon-start>
  64. * <ion-icon name="star"></ion-icon>
  65. * Left Icon
  66. * </button>
  67. *
  68. * <button ion-button icon-end>
  69. * Right Icon
  70. * <ion-icon name="star"></ion-icon>
  71. * </button>
  72. *
  73. * <button ion-button icon-only>
  74. * <ion-icon name="star"></ion-icon>
  75. * </button>
  76. *
  77. * <!-- Sizes -->
  78. * <button ion-button large>Large</button>
  79. *
  80. * <button ion-button>Default</button>
  81. *
  82. * <button ion-button small>Small</button>
  83. * ```
  84. *
  85. * @advanced
  86. *
  87. * ```html
  88. *
  89. * <!-- Bind the color and outline inputs to an expression -->
  90. * <button ion-button [color]="isDanger ? 'danger' : 'primary'" [outline]="isOutline">
  91. * Danger (Solid)
  92. * </button>
  93. *
  94. * <!-- Bind the color and round inputs to an expression -->
  95. * <button ion-button [color]="myColor" [round]="isRound">
  96. * Secondary (Round)
  97. * </button>
  98. *
  99. * <!-- Bind the color and clear inputs to an expression -->
  100. * <button ion-button [color]="isSecondary ? 'secondary' : 'primary'" [clear]="isClear">
  101. * Primary (Clear)
  102. * </button>
  103. *
  104. * <!-- Bind the color, outline and round inputs to an expression -->
  105. * <button ion-button [color]="myColor2" [outline]="isOutline" [round]="isRound">
  106. * Dark (Solid + Round)
  107. * </button>
  108. *
  109. * <!-- Bind the click event to a method -->
  110. * <button ion-button (click)="logEvent($event)">
  111. * Click me!
  112. * </button>
  113. * ```
  114. *
  115. * ```ts
  116. * @Component({
  117. * templateUrl: 'main.html'
  118. * })
  119. * class E2EPage {
  120. * isDanger: boolean = true;
  121. * isSecondary: boolean = false;
  122. * isRound: boolean = true;
  123. * isOutline: boolean = false;
  124. * isClear: boolean = true;
  125. * myColor: string = 'secondary';
  126. * myColor2: string = 'dark';
  127. *
  128. * logEvent(event) {
  129. * console.log(event)
  130. * }
  131. * }
  132. *
  133. * ```
  134. *
  135. * @demo /docs/demos/src/button/
  136. * @see {@link /docs/components#buttons Button Component Docs}
  137. * @see {@link /docs/components#fabs FabButton Docs}
  138. * @see {@link ../../fab/FabButton FabButton API Docs}
  139. * @see {@link ../../fab/FabContainer FabContainer API Docs}
  140. */
  141. var Button = (function (_super) {
  142. __extends(Button, _super);
  143. function Button(ionButton, config, elementRef, renderer) {
  144. var _this = _super.call(this, config, elementRef, renderer) || this;
  145. /** @hidden */
  146. _this._role = 'button'; // bar-button
  147. /** @hidden */
  148. _this._style = 'default'; // outline/clear/solid
  149. _this._mode = config.get('mode');
  150. if (config.get('hoverCSS') === false) {
  151. _this.setElementClass('disable-hover', true);
  152. }
  153. if (ionButton.trim().length > 0) {
  154. _this.setRole(ionButton);
  155. }
  156. return _this;
  157. }
  158. Object.defineProperty(Button.prototype, "large", {
  159. /**
  160. * @input {boolean} If true, activates the large button size.
  161. */
  162. set: function (val) {
  163. this._attr('_size', 'large', val);
  164. },
  165. enumerable: true,
  166. configurable: true
  167. });
  168. Object.defineProperty(Button.prototype, "small", {
  169. /**
  170. * @input {boolean} If true, activates the small button size.
  171. */
  172. set: function (val) {
  173. this._attr('_size', 'small', val);
  174. },
  175. enumerable: true,
  176. configurable: true
  177. });
  178. Object.defineProperty(Button.prototype, "default", {
  179. /**
  180. * @input {boolean} If true, activates the default button size. Normally the default, useful for buttons in an item.
  181. */
  182. set: function (val) {
  183. this._attr('_size', 'default', val);
  184. },
  185. enumerable: true,
  186. configurable: true
  187. });
  188. Object.defineProperty(Button.prototype, "outline", {
  189. /**
  190. * @input {boolean} If true, activates a transparent button style with a border.
  191. */
  192. set: function (val) {
  193. this._attr('_style', 'outline', val);
  194. },
  195. enumerable: true,
  196. configurable: true
  197. });
  198. Object.defineProperty(Button.prototype, "clear", {
  199. /**
  200. * @input {boolean} If true, activates a transparent button style without a border.
  201. */
  202. set: function (val) {
  203. this._attr('_style', 'clear', val);
  204. },
  205. enumerable: true,
  206. configurable: true
  207. });
  208. Object.defineProperty(Button.prototype, "solid", {
  209. /**
  210. * @input {boolean} If true, activates a solid button style. Normally the default, useful for buttons in a toolbar.
  211. */
  212. set: function (val) {
  213. this._attr('_style', 'solid', val);
  214. },
  215. enumerable: true,
  216. configurable: true
  217. });
  218. Object.defineProperty(Button.prototype, "round", {
  219. /**
  220. * @input {boolean} If true, activates a button with rounded corners.
  221. */
  222. set: function (val) {
  223. this._attr('_shape', 'round', val);
  224. },
  225. enumerable: true,
  226. configurable: true
  227. });
  228. Object.defineProperty(Button.prototype, "block", {
  229. /**
  230. * @input {boolean} If true, activates a button style that fills the available width.
  231. */
  232. set: function (val) {
  233. this._attr('_display', 'block', val);
  234. },
  235. enumerable: true,
  236. configurable: true
  237. });
  238. Object.defineProperty(Button.prototype, "full", {
  239. /**
  240. * @input {boolean} If true, activates a button style that fills the available width without
  241. * a left and right border.
  242. */
  243. set: function (val) {
  244. this._attr('_display', 'full', val);
  245. },
  246. enumerable: true,
  247. configurable: true
  248. });
  249. Object.defineProperty(Button.prototype, "strong", {
  250. /**
  251. * @input {boolean} If true, activates a button with a heavier font weight.
  252. */
  253. set: function (val) {
  254. this._attr('_decorator', 'strong', val);
  255. },
  256. enumerable: true,
  257. configurable: true
  258. });
  259. Object.defineProperty(Button.prototype, "mode", {
  260. /**
  261. * @input {string} The mode determines which platform styles to use.
  262. * Possible values are: `"ios"`, `"md"`, or `"wp"`.
  263. * For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
  264. */
  265. set: function (val) {
  266. this._assignCss(false);
  267. this._mode = val;
  268. this._assignCss(true);
  269. },
  270. enumerable: true,
  271. configurable: true
  272. });
  273. /** @hidden */
  274. Button.prototype._attr = function (type, attrName, attrValue) {
  275. if (type === '_style') {
  276. this._updateColor(this._color, false);
  277. }
  278. this._setClass(this[type], false);
  279. if (util_1.isTrueProperty(attrValue)) {
  280. this[type] = attrName;
  281. this._setClass(attrName, true);
  282. }
  283. else {
  284. // Special handling for '_style' which defaults to 'default'.
  285. this[type] = (type === '_style' ? 'default' : null);
  286. this._setClass(this[type], true);
  287. }
  288. if (type === '_style') {
  289. this._updateColor(this._color, true);
  290. }
  291. };
  292. Object.defineProperty(Button.prototype, "color", {
  293. /**
  294. * @input {string} The color to use from your Sass `$colors` map.
  295. * Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
  296. * For more information, see [Theming your App](/docs/theming/theming-your-app).
  297. */
  298. set: function (val) {
  299. this._updateColor(this._color, false);
  300. this._updateColor(val, true);
  301. this._color = val;
  302. },
  303. enumerable: true,
  304. configurable: true
  305. });
  306. /** @hidden */
  307. Button.prototype.ngAfterContentInit = function () {
  308. this._init = true;
  309. this._assignCss(true);
  310. };
  311. /**
  312. * @hidden
  313. */
  314. Button.prototype.setRole = function (val) {
  315. this._assignCss(false);
  316. this._role = val;
  317. this._assignCss(true);
  318. };
  319. /**
  320. * @hidden
  321. */
  322. Button.prototype._assignCss = function (assignCssClass) {
  323. var role = this._role;
  324. if (role) {
  325. this.setElementClass(role, assignCssClass); // button
  326. this.setElementClass(role + "-" + this._mode, assignCssClass); // button
  327. this._setClass(this._style, assignCssClass); // button-clear
  328. this._setClass(this._shape, assignCssClass); // button-round
  329. this._setClass(this._display, assignCssClass); // button-full
  330. this._setClass(this._size, assignCssClass); // button-small
  331. this._setClass(this._decorator, assignCssClass); // button-strong
  332. this._updateColor(this._color, assignCssClass); // button-secondary, bar-button-secondary
  333. }
  334. };
  335. /**
  336. * @hidden
  337. */
  338. Button.prototype._setClass = function (type, assignCssClass) {
  339. if (type && this._init) {
  340. type = type.toLocaleLowerCase();
  341. this.setElementClass(this._role + "-" + type, assignCssClass);
  342. this.setElementClass(this._role + "-" + type + "-" + this._mode, assignCssClass);
  343. }
  344. };
  345. /**
  346. * @hidden
  347. */
  348. Button.prototype._updateColor = function (color, isAdd) {
  349. if (color && this._init) {
  350. // The class should begin with the button role
  351. // button, bar-button
  352. var className = this._role;
  353. // If the role is not a bar-button, don't apply the solid style
  354. var style = this._style;
  355. style = (this._role !== 'bar-button' && style === 'solid' ? 'default' : style);
  356. className += (style !== null && style !== '' && style !== 'default' ? '-' + style.toLowerCase() : '');
  357. if (color !== null && color !== '') {
  358. this.setElementClass(className + "-" + this._mode + "-" + color, isAdd);
  359. }
  360. }
  361. };
  362. Button.decorators = [
  363. { type: core_1.Component, args: [{
  364. selector: '[ion-button]',
  365. template: '<span class="button-inner">' +
  366. '<ng-content></ng-content>' +
  367. '</span>' +
  368. '<div class="button-effect"></div>',
  369. changeDetection: core_1.ChangeDetectionStrategy.OnPush,
  370. encapsulation: core_1.ViewEncapsulation.None,
  371. },] },
  372. ];
  373. /** @nocollapse */
  374. Button.ctorParameters = function () { return [
  375. { type: undefined, decorators: [{ type: core_1.Attribute, args: ['ion-button',] },] },
  376. { type: config_1.Config, },
  377. { type: core_1.ElementRef, },
  378. { type: core_1.Renderer, },
  379. ]; };
  380. Button.propDecorators = {
  381. 'large': [{ type: core_1.Input },],
  382. 'small': [{ type: core_1.Input },],
  383. 'default': [{ type: core_1.Input },],
  384. 'outline': [{ type: core_1.Input },],
  385. 'clear': [{ type: core_1.Input },],
  386. 'solid': [{ type: core_1.Input },],
  387. 'round': [{ type: core_1.Input },],
  388. 'block': [{ type: core_1.Input },],
  389. 'full': [{ type: core_1.Input },],
  390. 'strong': [{ type: core_1.Input },],
  391. 'mode': [{ type: core_1.Input },],
  392. 'color': [{ type: core_1.Input },],
  393. };
  394. return Button;
  395. }(ion_1.Ion));
  396. exports.Button = Button;
  397. });
  398. //# sourceMappingURL=button.js.map