Cleanup itex extension
Most of the DOM manipulations can be done before doing the AJAX call. This leaves just the insertion of the MathML nodes in the mrow for the AJAX callback function. Also, make the stroke-width for the connector tool default to 2.
This commit is contained in:
parent
d201f79766
commit
4cd626ef49
|
@ -305,7 +305,7 @@ $(function() {
|
||||||
"id": getNextId(),
|
"id": getNextId(),
|
||||||
"points": (x+','+y+' '+x+','+y+' '+start_x+','+start_y),
|
"points": (x+','+y+' '+x+','+y+' '+start_x+','+start_y),
|
||||||
"stroke": '#000',
|
"stroke": '#000',
|
||||||
"stroke-width": 3,
|
"stroke-width": 2,
|
||||||
"fill": "none",
|
"fill": "none",
|
||||||
"opacity": .5,
|
"opacity": .5,
|
||||||
"style": "pointer-events:none"
|
"style": "pointer-events:none"
|
||||||
|
|
|
@ -60,24 +60,27 @@ $(function() {
|
||||||
function setItexString(tex) {
|
function setItexString(tex) {
|
||||||
var elt = selElems[0];
|
var elt = selElems[0];
|
||||||
try {
|
try {
|
||||||
math = svgdoc.createElementNS(mathns, 'math');
|
var math = svgdoc.createElementNS(mathns, 'math');
|
||||||
|
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
|
||||||
|
math.setAttribute('display', 'inline');
|
||||||
|
var semantics = document.createElementNS(mathns, 'semantics');
|
||||||
|
var annotation = document.createElementNS(mathns, 'annotation');
|
||||||
|
annotation.setAttribute('encoding', 'application/x-tex');
|
||||||
|
annotation.textContent = tex;
|
||||||
|
var mrow = document.createElementNS(mathns, 'mrow');
|
||||||
|
semantics.appendChild(mrow);
|
||||||
|
semantics.appendChild(annotation);
|
||||||
|
math.appendChild(semantics);
|
||||||
// make an AJAX request to the server, to get the MathML
|
// make an AJAX request to the server, to get the MathML
|
||||||
$.post(ajaxEndpoint, {'tex': tex, 'display': 'inline'}, function(data){
|
$.post(ajaxEndpoint, {'tex': tex, 'display': 'inline'}, function(data){
|
||||||
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
|
|
||||||
math.setAttribute('display', 'inline');
|
|
||||||
var semantics = document.createElementNS(mathns, 'semantics');
|
|
||||||
var annotation = document.createElementNS(mathns, 'annotation');
|
|
||||||
annotation.setAttribute('encoding', 'application/x-tex');
|
|
||||||
annotation.textContent = tex;
|
|
||||||
var mrow = document.createElementNS(mathns, 'mrow');
|
|
||||||
var children = data.documentElement.childNodes;
|
var children = data.documentElement.childNodes;
|
||||||
while (children.length > 0) {
|
while (children.length > 0) {
|
||||||
mrow.appendChild(children[0]);
|
mrow.appendChild(children[0]);
|
||||||
}
|
}
|
||||||
semantics.appendChild(mrow);
|
|
||||||
semantics.appendChild(annotation);
|
|
||||||
math.appendChild(semantics);
|
|
||||||
S.sanitizeSvg(math);
|
S.sanitizeSvg(math);
|
||||||
|
//elt.setAttribute('width', math.clientWidth+5);
|
||||||
|
//elt.setAttribute('height', math.clientHeight+5);
|
||||||
|
S.call("changed", [elt]);
|
||||||
});
|
});
|
||||||
elt.replaceChild(math, elt.firstChild);
|
elt.replaceChild(math, elt.firstChild);
|
||||||
S.call("changed", [elt]);
|
S.call("changed", [elt]);
|
||||||
|
|
Loading…
Reference in a new issue