version 1.2, 2015/02/24 15:20:44
|
version 1.4, 2017/01/05 13:55:35
|
Line 79 var handleChange = function(math_object)
|
Line 79 var handleChange = function(math_object)
|
output_node.appendChild(document.createTextNode(txt.substring(0, e.from))); |
output_node.appendChild(document.createTextNode(txt.substring(0, e.from))); |
var span = document.createElement('span'); |
var span = document.createElement('span'); |
span.appendChild(document.createTextNode(txt.substring(e.from, e.to + 1))); |
span.appendChild(document.createTextNode(txt.substring(e.from, e.to + 1))); |
span.className = 'math-error'; |
span.style.border = 'solid 1px red';// this used to be CSS "math-error", but using CSS caused too many problems |
|
span.style.minWidth = '1px'; |
output_node.appendChild(span); |
output_node.appendChild(span); |
if (e.to < txt.length - 1) { |
if (e.to < txt.length - 1) { |
output_node.appendChild(document.createTextNode(txt.substring(e.to + 1))); |
output_node.appendChild(document.createTextNode(txt.substring(e.to + 1))); |
Line 155 var initEditors = function() {
|
Line 156 var initEditors = function() {
|
var x = 0; |
var x = 0; |
var y = 0; |
var y = 0; |
while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) { |
while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) { |
x += el.offsetLeft - el.scrollLeft; |
var scrollLeft; |
|
if (el.nodeName == 'INPUT') |
|
scrollLeft = 0; |
|
else |
|
scrollLeft = el.scrollLeft; |
|
x += el.offsetLeft - scrollLeft; |
y += el.offsetTop - el.scrollTop; |
y += el.offsetTop - el.scrollTop; |
el = el.offsetParent; |
el = el.offsetParent; |
if (el) { |
if (el) { |
Line 190 var initEditors = function() {
|
Line 196 var initEditors = function() {
|
an_output_node.style.display = "none"; |
an_output_node.style.display = "none"; |
}; |
}; |
} |
} |
|
var hide_node_if_no_error = function(an_output_node) { |
|
return function(e) { |
|
if (!an_output_node.hasAttribute('title')) |
|
an_output_node.style.display = "none"; |
|
}; |
|
} |
var focus = function(a_ta, an_output_node) { |
var focus = function(a_ta, an_output_node) { |
return function(e) { |
return function(e) { |
if (a_ta.value != '') { |
if (a_ta.value != '') { |
Line 200 var initEditors = function() {
|
Line 212 var initEditors = function() {
|
}; |
}; |
ta.addEventListener("blur", hide_node(output_node), false); |
ta.addEventListener("blur", hide_node(output_node), false); |
ta.addEventListener("focus", focus(ta, output_node), false); |
ta.addEventListener("focus", focus(ta, output_node), false); |
output_node.addEventListener("mouseenter", hide_node(output_node), false); |
output_node.addEventListener("mouseenter", hide_node_if_no_error(output_node), false); |
ind_math = math_objects.length; |
ind_math = math_objects.length; |
var oldtxt = ""; |
var oldtxt = ""; |
math_objects[ind_math] = { |
math_objects[ind_math] = { |