a zip code crypto-currency system good for red ONLY

tab.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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", "../app/app", "../../config/config", "../../navigation/deep-linker", "../../platform/dom-controller", "../../gestures/gesture-controller", "../../util/util", "../../navigation/nav-controller-base", "../../platform/platform", "./tabs", "../../transitions/transition-controller"], 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 app_1 = require("../app/app");
  24. var config_1 = require("../../config/config");
  25. var deep_linker_1 = require("../../navigation/deep-linker");
  26. var dom_controller_1 = require("../../platform/dom-controller");
  27. var gesture_controller_1 = require("../../gestures/gesture-controller");
  28. var util_1 = require("../../util/util");
  29. var nav_controller_base_1 = require("../../navigation/nav-controller-base");
  30. var platform_1 = require("../../platform/platform");
  31. var tabs_1 = require("./tabs");
  32. var transition_controller_1 = require("../../transitions/transition-controller");
  33. /**
  34. * @name Tab
  35. * @description
  36. * The Tab component, written `<ion-tab>`, is styled based on the mode and should
  37. * be used in conjunction with the [Tabs](../Tabs/) component.
  38. *
  39. * Each `ion-tab` is a declarative component for a [NavController](../../../navigation/NavController/).
  40. * Basically, each tab is a `NavController`. For more information on using
  41. * navigation controllers take a look at the [NavController API Docs](../../../navigation/NavController/).
  42. *
  43. * See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs.
  44. *
  45. * @usage
  46. *
  47. * To add a basic tab, you can use the following markup where the `root` property
  48. * is the page you want to load for that tab, `tabTitle` is the optional text to
  49. * display on the tab, and `tabIcon` is the optional [icon](../../icon/Icon/).
  50. *
  51. * ```html
  52. * <ion-tabs>
  53. * <ion-tab [root]="chatRoot" tabTitle="Chat" tabIcon="chat"></ion-tab>
  54. * </ion-tabs>
  55. * ```
  56. *
  57. * Then, in your class you can set `chatRoot` to an imported class:
  58. *
  59. * ```ts
  60. * import { ChatPage } from '../chat/chat';
  61. *
  62. * export class Tabs {
  63. * // here we'll set the property of chatRoot to
  64. * // the imported class of ChatPage
  65. * chatRoot = ChatPage;
  66. *
  67. * constructor() {
  68. *
  69. * }
  70. * }
  71. * ```
  72. *
  73. * You can also pass some parameters to the root page of the tab through
  74. * `rootParams`. Below we pass `chatParams` to the Chat tab:
  75. *
  76. * ```html
  77. * <ion-tabs>
  78. * <ion-tab [root]="chatRoot" [rootParams]="chatParams" tabTitle="Chat" tabIcon="chat"></ion-tab>
  79. * </ion-tabs>
  80. * ```
  81. *
  82. * ```ts
  83. * export class Tabs {
  84. * chatRoot = ChatPage;
  85. *
  86. * // set some user information on chatParams
  87. * chatParams = {
  88. * user1: 'admin',
  89. * user2: 'ionic'
  90. * };
  91. *
  92. * constructor() {
  93. *
  94. * }
  95. * }
  96. * ```
  97. *
  98. * And in `ChatPage` you can get the data from `NavParams`:
  99. *
  100. * ```ts
  101. * export class ChatPage {
  102. * constructor(navParams: NavParams) {
  103. * console.log('Passed params', navParams.data);
  104. * }
  105. * }
  106. * ```
  107. *
  108. * Sometimes you may want to call a method instead of navigating to a new
  109. * page. You can use the `(ionSelect)` event to call a method on your class when
  110. * the tab is selected. Below is an example of presenting a modal from one of
  111. * the tabs.
  112. *
  113. * ```html
  114. * <ion-tabs>
  115. * <ion-tab (ionSelect)="chat()" tabTitle="Show Modal"></ion-tab>
  116. * </ion-tabs>pop
  117. * ```
  118. *
  119. * ```ts
  120. * export class Tabs {
  121. * constructor(public modalCtrl: ModalController) {
  122. *
  123. * }
  124. *
  125. * chat() {
  126. * let modal = this.modalCtrl.create(ChatPage);
  127. * modal.present();
  128. * }
  129. * }
  130. * ```
  131. *
  132. *
  133. * @demo /docs/demos/src/tabs/
  134. * @see {@link /docs/components#tabs Tabs Component Docs}
  135. * @see {@link ../../tabs/Tabs Tabs API Docs}
  136. * @see {@link ../../nav/Nav Nav API Docs}
  137. * @see {@link ../../nav/NavController NavController API Docs}
  138. */
  139. var Tab = (function (_super) {
  140. __extends(Tab, _super);
  141. function Tab(parent, app, config, plt, elementRef, zone, renderer, cfr, _cd, gestureCtrl, transCtrl, linker, _dom, errHandler) {
  142. var _this =
  143. // A Tab is a NavController for its child pages
  144. _super.call(this, parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, _dom, errHandler) || this;
  145. _this._cd = _cd;
  146. _this.linker = linker;
  147. _this._dom = _dom;
  148. /**
  149. * @hidden
  150. */
  151. _this._isEnabled = true;
  152. /**
  153. * @hidden
  154. */
  155. _this._isShown = true;
  156. /**
  157. * @output {Tab} Emitted when the current tab is selected.
  158. */
  159. _this.ionSelect = new core_1.EventEmitter();
  160. _this.id = parent.add(_this);
  161. _this._tabsHideOnSubPages = config.getBoolean('tabsHideOnSubPages');
  162. _this._tabId = 'tabpanel-' + _this.id;
  163. _this._btnId = 'tab-' + _this.id;
  164. return _this;
  165. }
  166. Object.defineProperty(Tab.prototype, "enabled", {
  167. /**
  168. * @input {boolean} If true, enable the tab. If false,
  169. * the user cannot interact with this element.
  170. * Default: `true`.
  171. */
  172. get: function () {
  173. return this._isEnabled;
  174. },
  175. set: function (val) {
  176. this._isEnabled = util_1.isTrueProperty(val);
  177. },
  178. enumerable: true,
  179. configurable: true
  180. });
  181. Object.defineProperty(Tab.prototype, "show", {
  182. /**
  183. * @input {boolean} If true, the tab button is visible within the
  184. * tabbar. Default: `true`.
  185. */
  186. get: function () {
  187. return this._isShown;
  188. },
  189. set: function (val) {
  190. this._isShown = util_1.isTrueProperty(val);
  191. },
  192. enumerable: true,
  193. configurable: true
  194. });
  195. Object.defineProperty(Tab.prototype, "tabsHideOnSubPages", {
  196. /**
  197. * @input {boolean} If true, hide the tabs on child pages.
  198. */
  199. get: function () {
  200. return this._tabsHideOnSubPages;
  201. },
  202. set: function (val) {
  203. this._tabsHideOnSubPages = util_1.isTrueProperty(val);
  204. },
  205. enumerable: true,
  206. configurable: true
  207. });
  208. Object.defineProperty(Tab.prototype, "_vp", {
  209. /**
  210. * @hidden
  211. */
  212. set: function (val) {
  213. this.setViewport(val);
  214. },
  215. enumerable: true,
  216. configurable: true
  217. });
  218. /**
  219. * @hidden
  220. */
  221. Tab.prototype.ngOnInit = function () {
  222. this.tabBadgeStyle = this.tabBadgeStyle ? this.tabBadgeStyle : 'default';
  223. };
  224. /**
  225. * @hidden
  226. */
  227. Tab.prototype.load = function (opts) {
  228. var _this = this;
  229. var segment = this._segment;
  230. if (segment || (!this._loaded && this.root)) {
  231. this.setElementClass('show-tab', true);
  232. // okay, first thing we need to do if check if the view already exists
  233. var nameToUse = segment && segment.name ? segment.name : this.root;
  234. var dataToUse = segment ? segment.data : this.rootParams;
  235. var numViews = this.length() - 1;
  236. for (var i = numViews; i >= 0; i--) {
  237. var viewController = this.getByIndex(i);
  238. if (viewController && (viewController.id === nameToUse || viewController.component === nameToUse)) {
  239. if (i === numViews) {
  240. // this is the last view in the stack and it's the same
  241. // as the segment so there's no change needed
  242. return Promise.resolve();
  243. }
  244. else {
  245. // it's not the exact view as the end
  246. // let's have this nav go back to this exact view
  247. return this.popTo(viewController, {
  248. animate: false,
  249. updateUrl: false,
  250. });
  251. }
  252. }
  253. }
  254. var promise = null;
  255. if (segment && segment.defaultHistory && segment.defaultHistory.length && this._views.length === 0) {
  256. promise = this.linker.initViews(segment).then(function (views) {
  257. return _this.setPages(views, opts);
  258. });
  259. }
  260. else {
  261. promise = this.push(nameToUse, dataToUse, opts);
  262. }
  263. return promise.then(function () {
  264. _this._segment = null;
  265. _this._loaded = true;
  266. });
  267. }
  268. else {
  269. // if this is not the Tab's initial load then we need
  270. // to refresh the tabbar and content dimensions to be sure
  271. // they're lined up correctly
  272. this._dom.read(function () {
  273. _this.resize();
  274. });
  275. return Promise.resolve();
  276. }
  277. };
  278. /**
  279. * @hidden
  280. */
  281. Tab.prototype.resize = function () {
  282. var active = this.getActive();
  283. if (!active) {
  284. return;
  285. }
  286. var content = active.getIONContent();
  287. content && content.resize();
  288. };
  289. /**
  290. * @hidden
  291. */
  292. Tab.prototype._viewAttachToDOM = function (viewCtrl, componentRef, viewport) {
  293. var isTabSubPage = (this._tabsHideOnSubPages && viewCtrl.index > 0);
  294. if (isTabSubPage) {
  295. viewport = this.parent.portal;
  296. }
  297. _super.prototype._viewAttachToDOM.call(this, viewCtrl, componentRef, viewport);
  298. if (isTabSubPage) {
  299. // add the .tab-subpage css class to tabs pages that should act like subpages
  300. var pageEleRef = viewCtrl.pageRef();
  301. if (pageEleRef) {
  302. this._renderer.setElementClass(pageEleRef.nativeElement, 'tab-subpage', true);
  303. }
  304. }
  305. };
  306. /**
  307. * @hidden
  308. */
  309. Tab.prototype.setSelected = function (isSelected) {
  310. this.isSelected = isSelected;
  311. this.setElementClass('show-tab', isSelected);
  312. this.setElementAttribute('aria-hidden', (!isSelected).toString());
  313. if (isSelected) {
  314. // this is the selected tab, detect changes
  315. this._cd.reattach();
  316. }
  317. else {
  318. // this tab is not selected, do not detect changes
  319. this._cd.detach();
  320. }
  321. };
  322. Object.defineProperty(Tab.prototype, "index", {
  323. /**
  324. * @hidden
  325. */
  326. get: function () {
  327. return this.parent.getIndex(this);
  328. },
  329. enumerable: true,
  330. configurable: true
  331. });
  332. /**
  333. * @hidden
  334. */
  335. Tab.prototype.updateHref = function (component, data) {
  336. if (this.btn && this.linker) {
  337. var href = this.linker.createUrl(this.parent, component, data) || '#';
  338. this.btn.updateHref(href);
  339. }
  340. };
  341. /**
  342. * @hidden
  343. */
  344. Tab.prototype.ngOnDestroy = function () {
  345. this.destroy();
  346. };
  347. /**
  348. * @hidden
  349. */
  350. Tab.prototype.getType = function () {
  351. return 'tab';
  352. };
  353. Tab.prototype.goToRoot = function (opts) {
  354. return this.setRoot(this.root, this.rootParams, opts, null);
  355. };
  356. Tab.decorators = [
  357. { type: core_1.Component, args: [{
  358. selector: 'ion-tab',
  359. template: '<div #viewport></div><div class="nav-decor"></div>',
  360. host: {
  361. '[attr.id]': '_tabId',
  362. '[attr.aria-labelledby]': '_btnId',
  363. 'role': 'tabpanel'
  364. },
  365. encapsulation: core_1.ViewEncapsulation.None,
  366. },] },
  367. ];
  368. /** @nocollapse */
  369. Tab.ctorParameters = function () { return [
  370. { type: tabs_1.Tabs, },
  371. { type: app_1.App, },
  372. { type: config_1.Config, },
  373. { type: platform_1.Platform, },
  374. { type: core_1.ElementRef, },
  375. { type: core_1.NgZone, },
  376. { type: core_1.Renderer, },
  377. { type: core_1.ComponentFactoryResolver, },
  378. { type: core_1.ChangeDetectorRef, },
  379. { type: gesture_controller_1.GestureController, },
  380. { type: transition_controller_1.TransitionController, },
  381. { type: deep_linker_1.DeepLinker, decorators: [{ type: core_1.Optional },] },
  382. { type: dom_controller_1.DomController, },
  383. { type: core_1.ErrorHandler, },
  384. ]; };
  385. Tab.propDecorators = {
  386. 'root': [{ type: core_1.Input },],
  387. 'rootParams': [{ type: core_1.Input },],
  388. 'tabUrlPath': [{ type: core_1.Input },],
  389. 'tabTitle': [{ type: core_1.Input },],
  390. 'tabIcon': [{ type: core_1.Input },],
  391. 'tabBadge': [{ type: core_1.Input },],
  392. 'tabBadgeStyle': [{ type: core_1.Input },],
  393. 'enabled': [{ type: core_1.Input },],
  394. 'show': [{ type: core_1.Input },],
  395. 'tabsHideOnSubPages': [{ type: core_1.Input },],
  396. 'ionSelect': [{ type: core_1.Output },],
  397. '_vp': [{ type: core_1.ViewChild, args: ['viewport', { read: core_1.ViewContainerRef },] },],
  398. };
  399. return Tab;
  400. }(nav_controller_base_1.NavControllerBase));
  401. exports.Tab = Tab;
  402. });
  403. //# sourceMappingURL=tab.js.map