From 971fe53deced6a660de45b8e4a29e02e0a393b79 Mon Sep 17 00:00:00 2001 From: kimth Date: Mon, 10 Sep 2012 17:42:15 -0400 Subject: [PATCH] Another step towards Javascriptinput-style script loading --- .../capa/templates/textinput_dynamath.html | 41 ++++++++++--------- .../xmodule/js/src/capa/display.coffee | 19 ++++++--- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/common/lib/capa/capa/templates/textinput_dynamath.html b/common/lib/capa/capa/templates/textinput_dynamath.html index c6d0ac347f..be37af481c 100644 --- a/common/lib/capa/capa/templates/textinput_dynamath.html +++ b/common/lib/capa/capa/templates/textinput_dynamath.html @@ -2,6 +2,10 @@ ### version of textline.html which does dynamic math ###
+ +
+
+ % if state == 'unsubmitted':
% elif state == 'correct': @@ -15,27 +19,26 @@
% endif - -
-

- % if state == 'unsubmitted': - unanswered - % elif state == 'correct': - correct - % elif state == 'incorrect': - incorrect - % elif state == 'incomplete': - incomplete - % endif -

+ +

+ % if state == 'unsubmitted': + unanswered + % elif state == 'correct': + correct + % elif state == 'incorrect': + incorrect + % elif state == 'incomplete': + incomplete + % endif +

-

+

-
`{::}`
+
`{::}`
diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index 43633bb713..a589179240 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -297,12 +297,17 @@ class @Problem refreshMath: (event, element) => element = event.target unless element - target = "display_#{element.id.replace(/^input_/, '')}" + elid = element.id.replace(/^input_/,'') + + target = "display_" + elid + + preprocessor_tag = "inputtype_" + elid + mathjax_preprocessor = @inputtypeDisplays[preprocessor_tag] if jax = MathJax.Hub.getAllJax(target)[0] eqn = $(element).val() - if @mathjax_preprocessor - eqn = @mathjax_preprocessor(eqn) + if mathjax_preprocessor + eqn = mathjax_preprocessor(eqn) MathJax.Hub.Queue ['Text', jax, eqn], [@updateMathML, jax, element] @@ -324,9 +329,13 @@ class @Problem inputtypeSetupMethods: textinputdynamath: (element) => - preprocessorClass = window['MathjaxPreprocessorFor6002x'] + data = $(element).find('.textinputdynamath_data') + + preprocessorClassName = data.data('preprocessor') + preprocessorClass = window[preprocessorClassName] + preprocessor = new preprocessorClass() - alert preprocessor.fn + return preprocessor.fn javascriptinput: (element) =>