maction.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 __read = (this && this.__read) || function (o, n) {
  18. var m = typeof Symbol === "function" && o[Symbol.iterator];
  19. if (!m) return o;
  20. var i = m.call(o), r, ar = [], e;
  21. try {
  22. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  23. }
  24. catch (error) { e = { error: error }; }
  25. finally {
  26. try {
  27. if (r && !r.done && (m = i["return"])) m.call(i);
  28. }
  29. finally { if (e) throw e.error; }
  30. }
  31. return ar;
  32. };
  33. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  34. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  35. if (ar || !(i in from)) {
  36. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  37. ar[i] = from[i];
  38. }
  39. }
  40. return to.concat(ar || Array.prototype.slice.call(from));
  41. };
  42. Object.defineProperty(exports, "__esModule", { value: true });
  43. exports.CommonMactionMixin = exports.TooltipData = void 0;
  44. var string_js_1 = require("../../../util/string.js");
  45. exports.TooltipData = {
  46. dx: '.2em',
  47. dy: '.1em',
  48. postDelay: 600,
  49. clearDelay: 100,
  50. hoverTimer: new Map(),
  51. clearTimer: new Map(),
  52. stopTimers: function (node, data) {
  53. if (data.clearTimer.has(node)) {
  54. clearTimeout(data.clearTimer.get(node));
  55. data.clearTimer.delete(node);
  56. }
  57. if (data.hoverTimer.has(node)) {
  58. clearTimeout(data.hoverTimer.get(node));
  59. data.hoverTimer.delete(node);
  60. }
  61. }
  62. };
  63. function CommonMactionMixin(Base) {
  64. return (function (_super) {
  65. __extends(class_1, _super);
  66. function class_1() {
  67. var args = [];
  68. for (var _i = 0; _i < arguments.length; _i++) {
  69. args[_i] = arguments[_i];
  70. }
  71. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  72. var actions = _this.constructor.actions;
  73. var action = _this.node.attributes.get('actiontype');
  74. var _a = __read(actions.get(action) || [(function (_node, _data) { }), {}], 2), handler = _a[0], data = _a[1];
  75. _this.action = handler;
  76. _this.data = data;
  77. _this.getParameters();
  78. return _this;
  79. }
  80. Object.defineProperty(class_1.prototype, "selected", {
  81. get: function () {
  82. var selection = this.node.attributes.get('selection');
  83. var i = Math.max(1, Math.min(this.childNodes.length, selection)) - 1;
  84. return this.childNodes[i] || this.wrap(this.node.selected);
  85. },
  86. enumerable: false,
  87. configurable: true
  88. });
  89. class_1.prototype.getParameters = function () {
  90. var offsets = this.node.attributes.get('data-offsets');
  91. var _a = __read((0, string_js_1.split)(offsets || ''), 2), dx = _a[0], dy = _a[1];
  92. this.dx = this.length2em(dx || exports.TooltipData.dx);
  93. this.dy = this.length2em(dy || exports.TooltipData.dy);
  94. };
  95. class_1.prototype.computeBBox = function (bbox, recompute) {
  96. if (recompute === void 0) { recompute = false; }
  97. bbox.updateFrom(this.selected.getOuterBBox());
  98. this.selected.setChildPWidths(recompute);
  99. };
  100. return class_1;
  101. }(Base));
  102. }
  103. exports.CommonMactionMixin = CommonMactionMixin;
  104. //# sourceMappingURL=maction.js.map