From 79519b7a073e23ee9f277f9dce281514551a8669 Mon Sep 17 00:00:00 2001 From: polesye Date: Wed, 11 Dec 2013 16:25:07 +0200 Subject: [PATCH] Address comments. --- CHANGELOG.rst | 2 ++ .../xmodule/xmodule/js/src/capa/imageinput.js | 31 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 374e95662d..73cfd9147c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, in roughly chronological order, most recent first. Add your entries at or near the top. Include a label indicating the component affected. +Blades: Fix bug when Image mapping problems are not working for students in IE. BLD-413. + Blades: Add template that displays the most up-to-date features of drag-and-drop. BLD-479. diff --git a/common/lib/xmodule/xmodule/js/src/capa/imageinput.js b/common/lib/xmodule/xmodule/js/src/capa/imageinput.js index 44910ff888..47b3b06c22 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/imageinput.js +++ b/common/lib/xmodule/xmodule/js/src/capa/imageinput.js @@ -4,19 +4,24 @@ // //////////////////////////////////////////////////////////////////////////////// -// click on image, return coordinates -// put a dot at location of click, on imag +// click on image, update coordinates +// put a dot at location of click, on image -window.image_input_click = function(id,event){ - iidiv = document.getElementById("imageinput_"+id); - pos_x = event.offsetX?(event.offsetX):event.pageX-iidiv.offsetLeft; - pos_y = event.offsetY?(event.offsetY):event.pageY-iidiv.offsetTop; - result = "[" + Math.round(pos_x) + "," + Math.round(pos_y) + "]"; - cx = (pos_x-15) +"px"; - cy = (pos_y-15) +"px"; +window.image_input_click = function (id, event) { + var iidiv = document.getElementById("imageinput_" + id), + pos_x = event.offsetX ? (event.offsetX) : event.pageX - iidiv.offsetLeft, + pos_y = event.offsetY ? (event.offsetY) : event.pageY - iidiv.offsetTop, + // To reduce differences between values returned by different kinds of + // browsers, we round `pos_x` and `pos_y`. + // IE10: `pos_x` and `pos_y` - float. + // Chrome, FF: `pos_x` and `pos_y` - integers. + result = "[" + Math.round(pos_x) + "," + Math.round(pos_y) + "]", + cx = (pos_x - 15) + "px", + cy = (pos_y - 15) + "px", + cross = document.getElementById("cross_" + id); - 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; + cross.style.left = cx; + cross.style.top = cy; + cross.style.visibility = "visible" ; + document.getElementById("input_" + id).value = result; };