123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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", "../../platform/dom-controller", "../../gestures/gesture-controller", "../ion", "../../util/util", "../item/item-sliding-gesture", "../../platform/platform"], 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 dom_controller_1 = require("../../platform/dom-controller");
  25. var gesture_controller_1 = require("../../gestures/gesture-controller");
  26. var ion_1 = require("../ion");
  27. var util_1 = require("../../util/util");
  28. var item_sliding_gesture_1 = require("../item/item-sliding-gesture");
  29. var platform_1 = require("../../platform/platform");
  30. /**
  31. * The List is a widely used interface element in almost any mobile app,
  32. * and can include content ranging from basic text all the way to
  33. * buttons, toggles, icons, and thumbnails.
  34. *
  35. * Both the list, which contains items, and the list items themselves
  36. * can be any HTML element.
  37. *
  38. * Using the List and Item components make it easy to support various
  39. * interaction modes such as swipe to edit, drag to reorder, and
  40. * removing items.
  41. *
  42. * @demo /docs/demos/src/list/
  43. * @see {@link /docs/components#lists List Component Docs}
  44. * @advanced
  45. *
  46. * Enable the sliding items.
  47. *
  48. * ```ts
  49. * import { Component, ViewChild } from '@angular/core';
  50. * import { List } from 'ionic-angular';
  51. *
  52. * @Component({...})
  53. * export class MyClass {
  54. * @ViewChild(List) list: List;
  55. *
  56. * constructor() { }
  57. *
  58. * stopSliding() {
  59. * this.list.enableSlidingItems(false);
  60. * }
  61. * }
  62. * ```
  63. *
  64. */
  65. var List = (function (_super) {
  66. __extends(List, _super);
  67. function List(config, elementRef, renderer, _plt, _gestureCtrl, _domCtrl) {
  68. var _this = _super.call(this, config, elementRef, renderer, 'list') || this;
  69. _this._plt = _plt;
  70. _this._gestureCtrl = _gestureCtrl;
  71. _this._domCtrl = _domCtrl;
  72. _this._enableSliding = true;
  73. _this._containsSlidingItems = false;
  74. return _this;
  75. }
  76. Object.defineProperty(List.prototype, "sliding", {
  77. /**
  78. * @input {boolean} If true, the sliding items will be enabled.
  79. */
  80. get: function () {
  81. return this._enableSliding;
  82. },
  83. set: function (val) {
  84. this._enableSliding = util_1.isTrueProperty(val);
  85. this._updateSlidingState();
  86. },
  87. enumerable: true,
  88. configurable: true
  89. });
  90. /**
  91. * @hidden
  92. */
  93. List.prototype.containsSlidingItem = function (contains) {
  94. this._containsSlidingItems = contains;
  95. this._updateSlidingState();
  96. };
  97. List.prototype._updateSlidingState = function () {
  98. var shouldSlide = this._enableSliding && this._containsSlidingItems;
  99. if (!shouldSlide) {
  100. this._slidingGesture && this._slidingGesture.destroy();
  101. this._slidingGesture = null;
  102. }
  103. else if (!this._slidingGesture) {
  104. (void 0) /* console.debug */;
  105. this._slidingGesture = new item_sliding_gesture_1.ItemSlidingGesture(this._plt, this, this._gestureCtrl, this._domCtrl);
  106. this._slidingGesture.listen();
  107. }
  108. };
  109. /**
  110. * Close any sliding items that are open.
  111. */
  112. List.prototype.closeSlidingItems = function () {
  113. this._slidingGesture && this._slidingGesture.closeOpened();
  114. };
  115. /**
  116. * @hidden
  117. */
  118. List.prototype.destroy = function () {
  119. this._slidingGesture && this._slidingGesture.destroy();
  120. };
  121. List.decorators = [
  122. { type: core_1.Directive, args: [{
  123. selector: 'ion-list',
  124. },] },
  125. ];
  126. /** @nocollapse */
  127. List.ctorParameters = function () { return [
  128. { type: config_1.Config, },
  129. { type: core_1.ElementRef, },
  130. { type: core_1.Renderer, },
  131. { type: platform_1.Platform, },
  132. { type: gesture_controller_1.GestureController, },
  133. { type: dom_controller_1.DomController, },
  134. ]; };
  135. List.propDecorators = {
  136. 'sliding': [{ type: core_1.Input },],
  137. };
  138. return List;
  139. }(ion_1.Ion));
  140. exports.List = List;
  141. });
  142. //# sourceMappingURL=list.js.map