msqrt.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. Object.defineProperty(exports, "__esModule", { value: true });
  34. exports.CHTMLmsqrt = void 0;
  35. var Wrapper_js_1 = require("../Wrapper.js");
  36. var msqrt_js_1 = require("../../common/Wrappers/msqrt.js");
  37. var msqrt_js_2 = require("../../../core/MmlTree/MmlNodes/msqrt.js");
  38. var CHTMLmsqrt = (function (_super) {
  39. __extends(CHTMLmsqrt, _super);
  40. function CHTMLmsqrt() {
  41. return _super !== null && _super.apply(this, arguments) || this;
  42. }
  43. CHTMLmsqrt.prototype.toCHTML = function (parent) {
  44. var surd = this.childNodes[this.surd];
  45. var base = this.childNodes[this.base];
  46. var sbox = surd.getBBox();
  47. var bbox = base.getOuterBBox();
  48. var _a = __read(this.getPQ(sbox), 2), q = _a[1];
  49. var t = this.font.params.rule_thickness;
  50. var H = bbox.h + q + t;
  51. var CHTML = this.standardCHTMLnode(parent);
  52. var SURD, BASE, ROOT, root;
  53. if (this.root != null) {
  54. ROOT = this.adaptor.append(CHTML, this.html('mjx-root'));
  55. root = this.childNodes[this.root];
  56. }
  57. var SQRT = this.adaptor.append(CHTML, this.html('mjx-sqrt', {}, [
  58. SURD = this.html('mjx-surd'),
  59. BASE = this.html('mjx-box', { style: { paddingTop: this.em(q) } })
  60. ]));
  61. this.addRoot(ROOT, root, sbox, H);
  62. surd.toCHTML(SURD);
  63. base.toCHTML(BASE);
  64. if (surd.size < 0) {
  65. this.adaptor.addClass(SQRT, 'mjx-tall');
  66. }
  67. };
  68. CHTMLmsqrt.prototype.addRoot = function (_ROOT, _root, _sbox, _H) {
  69. };
  70. CHTMLmsqrt.kind = msqrt_js_2.MmlMsqrt.prototype.kind;
  71. CHTMLmsqrt.styles = {
  72. 'mjx-root': {
  73. display: 'inline-block',
  74. 'white-space': 'nowrap'
  75. },
  76. 'mjx-surd': {
  77. display: 'inline-block',
  78. 'vertical-align': 'top'
  79. },
  80. 'mjx-sqrt': {
  81. display: 'inline-block',
  82. 'padding-top': '.07em'
  83. },
  84. 'mjx-sqrt > mjx-box': {
  85. 'border-top': '.07em solid'
  86. },
  87. 'mjx-sqrt.mjx-tall > mjx-box': {
  88. 'padding-left': '.3em',
  89. 'margin-left': '-.3em'
  90. }
  91. };
  92. return CHTMLmsqrt;
  93. }((0, msqrt_js_1.CommonMsqrtMixin)(Wrapper_js_1.CHTMLWrapper)));
  94. exports.CHTMLmsqrt = CHTMLmsqrt;
  95. //# sourceMappingURL=msqrt.js.map