Add a chemicalequationinput with live preview

- architecturally slightly questionable: the preview ajax calls goes to an LMS view instead of an input type specific one.  This needs to be fixed during the grand capa re-org, but there isn't time to do it right now.
- also, I kind of like having a generic turn-a-formula-into-a-preview service available
This commit is contained in:
Victor Shnayder
2012-10-12 13:52:48 -04:00
parent c420c67b82
commit 19d3cb3870
9 changed files with 214 additions and 22 deletions

View File

@@ -0,0 +1 @@
These files really should be in the capa module, but we don't have a way to load js from there at the moment. (TODO)

View File

@@ -0,0 +1,12 @@
(function () {
var preview_div = $('.chemicalequationinput .equation');
$('.chemicalequationinput input').bind("input", function(eventObject) {
$.get("/preview/chemcalc/", {"formula" : this.value}, function(response) {
if (response.error) {
preview_div.html("<span class='error'>" + response.error + "</span>");
} else {
preview_div.html(response.preview);
}
});
});
}).call(this);