dynamic math display - fix sequence of mathjax timing (mathml now
generated when Check is clicked)
This commit is contained in:
@@ -450,8 +450,9 @@ var AMsymbols = [
|
||||
{input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
|
||||
{input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
|
||||
{input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
|
||||
{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
|
||||
{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
|
||||
// not for edX (ichuang jun12)
|
||||
//{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
|
||||
//{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
|
||||
|
||||
//standard functions
|
||||
{input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
|
||||
|
||||
@@ -79,12 +79,10 @@ function DoUpdateMath(inputId) {
|
||||
}
|
||||
|
||||
</script>
|
||||
<%block name="headextra"/>
|
||||
|
||||
<!-- This must appear after all mathjax-config blocks, so it is after the imports from the other templates -->
|
||||
<!-- TODO: move to settings -->
|
||||
## <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.0-latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full">
|
||||
## <script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-AMS_HTML-full"></script>
|
||||
<script type="text/javascript" src="/static/js/mathjax-MathJax-c9db6ac/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script>
|
||||
</script>
|
||||
|
||||
</script>
|
||||
@@ -2,31 +2,27 @@ function ${ id }_content_updated() {
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
update_schematics();
|
||||
|
||||
// dynamic math display: add to jaxset for automatic rendering
|
||||
// for (var key in codemirror_set) {
|
||||
// codemirror_set[key].refresh();
|
||||
// }
|
||||
|
||||
$('#check_${ id }').unbind('click').click(function() {
|
||||
$("input.schematic").each(function(index,element){ element.schematic.update_value(); });
|
||||
$(".CodeMirror").each(function(index,element){ if (element.CodeMirror.save) element.CodeMirror.save(); });
|
||||
|
||||
// dynamic math display: generate MathML on click
|
||||
$.each($("[id^=input_${ id }_]"), function(index,value){
|
||||
theid = value.id.replace("input_",""); // ID of the response
|
||||
if (document.getElementById("display_" + theid)){
|
||||
MathJax.Hub.queue.Push(function () {
|
||||
math = MathJax.Hub.getAllJax("display_" + theid)[0];
|
||||
if (math){
|
||||
jaxset[theid] = math;
|
||||
math.Text(document.getElementById(value.id).defaultValue);
|
||||
x = document.getElementById("input_" + theid + "_dynamath");
|
||||
UpdateMathML(math,theid);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
$('#check_${ id }').unbind('click').click(function() {
|
||||
$("input.schematic").each(function(index,element){ element.schematic.update_value(); });
|
||||
$(".CodeMirror").each(function(index,element){ if (element.CodeMirror.save) element.CodeMirror.save(); });
|
||||
|
||||
// for (var key in codemirror_set) {
|
||||
// codemirror_set[key].refresh();
|
||||
// }
|
||||
|
||||
var submit_data={};
|
||||
$.each($("[id^=input_${ id }_]"), function(index,value){
|
||||
if (value.type==="checkbox"){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
### version of textline.html which does dynammic math
|
||||
###
|
||||
<section class="text-input-dynamath">
|
||||
<table><tr><td>
|
||||
<table style="display:inline; vertical-align:middle;"><tr><td>
|
||||
<input type="text" name="input_${id}" id="input_${id}" value="${value}"
|
||||
% if size:
|
||||
size="${size}"
|
||||
@@ -26,24 +26,23 @@
|
||||
</td></tr><tr><td>
|
||||
<span id="display_${id}">`{::}`</span>
|
||||
</td><td>
|
||||
<textarea style="display:none" id="input_${id}_dynamath" name="input_${id}_dynamath">none</textarea>
|
||||
<textarea style="display:none" id="input_${id}_dynamath" name="input_${id}_dynamath"> </textarea>
|
||||
</td></tr>
|
||||
</table>
|
||||
##
|
||||
## javascript for dynamic math: add this math element to the MathJax rendering queue
|
||||
## also adds to global jaxset js array
|
||||
##
|
||||
<script>
|
||||
MathJax.Hub.queue.Push(function () {
|
||||
<script type="text/javascript">
|
||||
MathJax.Hub.queue.Push(function () {
|
||||
math = MathJax.Hub.getAllJax("display_${id}")[0];
|
||||
if (math){
|
||||
jaxset["${id}"] = math;
|
||||
math.Text(document.getElementById("input_${id}_dynamath").defaultValue); // initial render
|
||||
UpdateMathML(math,"${id}"); // initial MathML
|
||||
math.Text(document.getElementById("input_${id}").value);
|
||||
// UpdateMathML(math,"${id}");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</script>
|
||||
% if msg:
|
||||
<br/>
|
||||
<span class="debug">${msg|n}</span>
|
||||
|
||||
Reference in New Issue
Block a user