Move imageinput.js to capa_module js includes

This commit is contained in:
Calen Pennington
2012-07-19 11:29:29 -04:00
parent 7e4d3c8b35
commit 6ea5f6a493
2 changed files with 2 additions and 1 deletions

View File

@@ -71,7 +71,8 @@ class CapaModule(XModule):
'''
icon_class = 'problem'
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')]}
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')],
'js': [resource_string(__name__, 'js/src/capa/imageinput.js')]}
js_module_name = "Problem"
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):

View File

@@ -0,0 +1,24 @@
/////////////////////////////////////////////////////////////////////////////
//
// Simple image input
//
////////////////////////////////////////////////////////////////////////////////
// click on image, return coordinates
// put a dot at location of click, on imag
// window.image_input_click = function(id,event){
function image_input_click(id,event){
iidiv = document.getElementById("imageinput_"+id);
pos_x = event.offsetX?(event.offsetX):event.pageX-document.iidiv.offsetLeft;
pos_y = event.offsetY?(event.offsetY):event.pageY-document.iidiv.offsetTop;
result = "[" + pos_x + "," + pos_y + "]";
cx = (pos_x-15) +"px";
cy = (pos_y-15) +"px" ;
// alert(result);
document.getElementById("cross_"+id).style.left = cx;
document.getElementById("cross_"+id).style.top = cy;
document.getElementById("cross_"+id).style.visibility = "visible" ;
document.getElementById("input_"+id).value =result;
}