mtr.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __values = (this && this.__values) || function(o) {
  18. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  19. if (m) return m.call(o);
  20. if (o && typeof o.length === "number") return {
  21. next: function () {
  22. if (o && i >= o.length) o = void 0;
  23. return { value: o && o[i++], done: !o };
  24. }
  25. };
  26. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  27. };
  28. Object.defineProperty(exports, "__esModule", { value: true });
  29. exports.CommonMlabeledtrMixin = exports.CommonMtrMixin = void 0;
  30. function CommonMtrMixin(Base) {
  31. return (function (_super) {
  32. __extends(class_1, _super);
  33. function class_1() {
  34. return _super !== null && _super.apply(this, arguments) || this;
  35. }
  36. Object.defineProperty(class_1.prototype, "fixesPWidth", {
  37. get: function () {
  38. return false;
  39. },
  40. enumerable: false,
  41. configurable: true
  42. });
  43. Object.defineProperty(class_1.prototype, "numCells", {
  44. get: function () {
  45. return this.childNodes.length;
  46. },
  47. enumerable: false,
  48. configurable: true
  49. });
  50. Object.defineProperty(class_1.prototype, "labeled", {
  51. get: function () {
  52. return false;
  53. },
  54. enumerable: false,
  55. configurable: true
  56. });
  57. Object.defineProperty(class_1.prototype, "tableCells", {
  58. get: function () {
  59. return this.childNodes;
  60. },
  61. enumerable: false,
  62. configurable: true
  63. });
  64. class_1.prototype.getChild = function (i) {
  65. return this.childNodes[i];
  66. };
  67. class_1.prototype.getChildBBoxes = function () {
  68. return this.childNodes.map(function (cell) { return cell.getBBox(); });
  69. };
  70. class_1.prototype.stretchChildren = function (HD) {
  71. var e_1, _a, e_2, _b, e_3, _c;
  72. if (HD === void 0) { HD = null; }
  73. var stretchy = [];
  74. var children = (this.labeled ? this.childNodes.slice(1) : this.childNodes);
  75. try {
  76. for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
  77. var mtd = children_1_1.value;
  78. var child = mtd.childNodes[0];
  79. if (child.canStretch(1)) {
  80. stretchy.push(child);
  81. }
  82. }
  83. }
  84. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  85. finally {
  86. try {
  87. if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
  88. }
  89. finally { if (e_1) throw e_1.error; }
  90. }
  91. var count = stretchy.length;
  92. var nodeCount = this.childNodes.length;
  93. if (count && nodeCount > 1) {
  94. if (HD === null) {
  95. var H = 0, D = 0;
  96. var all = (count > 1 && count === nodeCount);
  97. try {
  98. for (var children_2 = __values(children), children_2_1 = children_2.next(); !children_2_1.done; children_2_1 = children_2.next()) {
  99. var mtd = children_2_1.value;
  100. var child = mtd.childNodes[0];
  101. var noStretch = (child.stretch.dir === 0);
  102. if (all || noStretch) {
  103. var _d = child.getBBox(noStretch), h = _d.h, d = _d.d;
  104. if (h > H) {
  105. H = h;
  106. }
  107. if (d > D) {
  108. D = d;
  109. }
  110. }
  111. }
  112. }
  113. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  114. finally {
  115. try {
  116. if (children_2_1 && !children_2_1.done && (_b = children_2.return)) _b.call(children_2);
  117. }
  118. finally { if (e_2) throw e_2.error; }
  119. }
  120. HD = [H, D];
  121. }
  122. try {
  123. for (var stretchy_1 = __values(stretchy), stretchy_1_1 = stretchy_1.next(); !stretchy_1_1.done; stretchy_1_1 = stretchy_1.next()) {
  124. var child = stretchy_1_1.value;
  125. child.coreMO().getStretchedVariant(HD);
  126. }
  127. }
  128. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  129. finally {
  130. try {
  131. if (stretchy_1_1 && !stretchy_1_1.done && (_c = stretchy_1.return)) _c.call(stretchy_1);
  132. }
  133. finally { if (e_3) throw e_3.error; }
  134. }
  135. }
  136. };
  137. return class_1;
  138. }(Base));
  139. }
  140. exports.CommonMtrMixin = CommonMtrMixin;
  141. function CommonMlabeledtrMixin(Base) {
  142. return (function (_super) {
  143. __extends(class_2, _super);
  144. function class_2() {
  145. return _super !== null && _super.apply(this, arguments) || this;
  146. }
  147. Object.defineProperty(class_2.prototype, "numCells", {
  148. get: function () {
  149. return Math.max(0, this.childNodes.length - 1);
  150. },
  151. enumerable: false,
  152. configurable: true
  153. });
  154. Object.defineProperty(class_2.prototype, "labeled", {
  155. get: function () {
  156. return true;
  157. },
  158. enumerable: false,
  159. configurable: true
  160. });
  161. Object.defineProperty(class_2.prototype, "tableCells", {
  162. get: function () {
  163. return this.childNodes.slice(1);
  164. },
  165. enumerable: false,
  166. configurable: true
  167. });
  168. class_2.prototype.getChild = function (i) {
  169. return this.childNodes[i + 1];
  170. };
  171. class_2.prototype.getChildBBoxes = function () {
  172. return this.childNodes.slice(1).map(function (cell) { return cell.getBBox(); });
  173. };
  174. return class_2;
  175. }(Base));
  176. }
  177. exports.CommonMlabeledtrMixin = CommonMlabeledtrMixin;
  178. //# sourceMappingURL=mtr.js.map