TreeExplorer.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. exports.TreeColorer = exports.FlameColorer = exports.AbstractTreeExplorer = void 0;
  22. var Explorer_js_1 = require("./Explorer.js");
  23. var sre_js_1 = __importDefault(require("../sre.js"));
  24. var AbstractTreeExplorer = (function (_super) {
  25. __extends(AbstractTreeExplorer, _super);
  26. function AbstractTreeExplorer(document, region, node, mml) {
  27. var _this = _super.call(this, document, null, node) || this;
  28. _this.document = document;
  29. _this.region = region;
  30. _this.node = node;
  31. _this.mml = mml;
  32. _this.stoppable = false;
  33. return _this;
  34. }
  35. AbstractTreeExplorer.prototype.Attach = function () {
  36. _super.prototype.Attach.call(this);
  37. this.Start();
  38. };
  39. AbstractTreeExplorer.prototype.Detach = function () {
  40. this.Stop();
  41. _super.prototype.Detach.call(this);
  42. };
  43. return AbstractTreeExplorer;
  44. }(Explorer_js_1.AbstractExplorer));
  45. exports.AbstractTreeExplorer = AbstractTreeExplorer;
  46. var FlameColorer = (function (_super) {
  47. __extends(FlameColorer, _super);
  48. function FlameColorer() {
  49. return _super !== null && _super.apply(this, arguments) || this;
  50. }
  51. FlameColorer.prototype.Start = function () {
  52. if (this.active)
  53. return;
  54. this.active = true;
  55. this.highlighter.highlightAll(this.node);
  56. };
  57. FlameColorer.prototype.Stop = function () {
  58. if (this.active) {
  59. this.highlighter.unhighlightAll();
  60. }
  61. this.active = false;
  62. };
  63. return FlameColorer;
  64. }(AbstractTreeExplorer));
  65. exports.FlameColorer = FlameColorer;
  66. var TreeColorer = (function (_super) {
  67. __extends(TreeColorer, _super);
  68. function TreeColorer() {
  69. return _super !== null && _super.apply(this, arguments) || this;
  70. }
  71. TreeColorer.prototype.Start = function () {
  72. if (this.active)
  73. return;
  74. this.active = true;
  75. var generator = sre_js_1.default.getSpeechGenerator('Color');
  76. if (!this.node.hasAttribute('hasforegroundcolor')) {
  77. generator.generateSpeech(this.node, this.mml);
  78. this.node.setAttribute('hasforegroundcolor', 'true');
  79. }
  80. this.highlighter.colorizeAll(this.node);
  81. };
  82. TreeColorer.prototype.Stop = function () {
  83. if (this.active) {
  84. this.highlighter.uncolorizeAll(this.node);
  85. }
  86. this.active = false;
  87. };
  88. return TreeColorer;
  89. }(AbstractTreeExplorer));
  90. exports.TreeColorer = TreeColorer;
  91. //# sourceMappingURL=TreeExplorer.js.map