Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ac3cd92b
Commit
ac3cd92b
authored
Jan 27, 2014
by
Anton Stupak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2315 from edx/anton/fix-imageresponse-offset-in-ff
Imageresponse: fix offset in FF.
parents
9d950436
2cee94ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
28 deletions
+15
-28
CHANGELOG.rst
+2
-0
common/lib/xmodule/xmodule/js/spec/capa/imageinput_spec.js
+5
-15
common/lib/xmodule/xmodule/js/src/capa/imageinput.js
+8
-13
No files found.
CHANGELOG.rst
View file @
ac3cd92b
...
@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
...
@@ -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
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.
the top. Include a label indicating the component affected.
Blades: Fix bug when image response in Firefox does not retain input. BLD-711.
Blades: Give numerical response tolerance as a range. BLD-25.
Blades: Give numerical response tolerance as a range. BLD-25.
Blades: Allow user with BetaTester role correctly use LTI. BLD-641.
Blades: Allow user with BetaTester role correctly use LTI. BLD-641.
...
...
common/lib/xmodule/xmodule/js/spec/capa/imageinput_spec.js
View file @
ac3cd92b
...
@@ -18,13 +18,9 @@
...
@@ -18,13 +18,9 @@
el
.
append
(
createTestImage
(
'cross_12345'
,
300
,
400
,
'red'
));
el
.
append
(
createTestImage
(
'cross_12345'
,
300
,
400
,
'red'
));
state
=
new
ImageInput
(
'12345'
);
state
=
new
ImageInput
(
'12345'
);
spyOn
(
state
,
'clickHandler'
).
andCallThrough
();
});
});
it
(
'initialization'
,
function
()
{
it
(
'initialization'
,
function
()
{
expect
(
state
.
elementId
).
toBe
(
'12345'
);
// Check that object's properties are present, and that the DOM
// Check that object's properties are present, and that the DOM
// elements they reference exist.
// elements they reference exist.
expect
(
state
.
el
).
toBeDefined
();
expect
(
state
.
el
).
toBeDefined
();
...
@@ -36,12 +32,7 @@
...
@@ -36,12 +32,7 @@
expect
(
state
.
inputEl
).
toBeDefined
();
expect
(
state
.
inputEl
).
toBeDefined
();
expect
(
state
.
inputEl
).
toExist
();
expect
(
state
.
inputEl
).
toExist
();
// Check that the click handler has been attached to the `state.el`
expect
(
state
.
el
).
toHandle
(
'click'
);
// element. Note that `state.clickHandler()` method is called from
// within the attached handler. That is why we can't use
// Jasmine-jQuery `toHandleWith()` method.
state
.
el
.
click
();
expect
(
state
.
clickHandler
).
toHaveBeenCalled
();
});
});
it
(
'cross becomes visible after first click'
,
function
()
{
it
(
'cross becomes visible after first click'
,
function
()
{
...
@@ -81,7 +72,8 @@
...
@@ -81,7 +72,8 @@
});
});
it
(
'coordinates are updated [offsetX is NOT set]'
,
function
()
{
it
(
'coordinates are updated [offsetX is NOT set]'
,
function
()
{
var
event
,
posX
,
posY
,
cssLeft
,
cssTop
;
var
offset
=
state
.
el
.
offset
(),
event
,
posX
,
posY
,
cssLeft
,
cssTop
;
// Set up of 'click' event.
// Set up of 'click' event.
event
=
jQuery
.
Event
(
event
=
jQuery
.
Event
(
...
@@ -91,12 +83,10 @@
...
@@ -91,12 +83,10 @@
pageX
:
35.3
,
pageY
:
42.7
pageX
:
35.3
,
pageY
:
42.7
}
}
);
);
state
.
el
[
0
].
offsetLeft
=
12
;
state
.
el
[
0
].
offsetTop
=
3
;
// Calculating the expected coordinates.
// Calculating the expected coordinates.
posX
=
event
.
pageX
-
state
.
el
[
0
].
offsetL
eft
;
posX
=
event
.
pageX
-
offset
.
l
eft
;
posY
=
event
.
pageY
-
state
.
el
[
0
].
offsetT
op
;
posY
=
event
.
pageY
-
offset
.
t
op
;
// Triggering 'click' event.
// Triggering 'click' event.
jQuery
(
state
.
el
).
trigger
(
event
);
jQuery
(
state
.
el
).
trigger
(
event
);
...
...
common/lib/xmodule/xmodule/js/src/capa/imageinput.js
View file @
ac3cd92b
...
@@ -24,24 +24,19 @@ window.ImageInput = (function ($, undefined) {
...
@@ -24,24 +24,19 @@ window.ImageInput = (function ($, undefined) {
return
ImageInput
;
return
ImageInput
;
function
ImageInputConstructor
(
elementId
)
{
function
ImageInputConstructor
(
elementId
)
{
var
_this
=
this
;
this
.
el
=
$
(
'#imageinput_'
+
elementId
);
this
.
crossEl
=
$
(
'#cross_'
+
elementId
);
this
.
inputEl
=
$
(
'#input_'
+
elementId
);
this
.
elementId
=
elementId
;
this
.
el
.
on
(
'click'
,
this
.
clickHandler
.
bind
(
this
));
this
.
el
=
$
(
'#imageinput_'
+
this
.
elementId
);
this
.
crossEl
=
$
(
'#cross_'
+
this
.
elementId
);
this
.
inputEl
=
$
(
'#input_'
+
this
.
elementId
);
this
.
el
.
on
(
'click'
,
function
(
event
)
{
_this
.
clickHandler
(
event
);
});
}
}
function
clickHandler
(
event
)
{
function
clickHandler
(
event
)
{
var
posX
=
event
.
offsetX
?
var
offset
=
this
.
el
.
offset
(),
event
.
offsetX
:
event
.
pageX
-
this
.
el
[
0
].
offsetLeft
,
posX
=
event
.
offsetX
?
event
.
offsetX
:
event
.
pageX
-
offset
.
left
,
posY
=
event
.
offsetY
?
posY
=
event
.
offsetY
?
event
.
offsetY
:
event
.
pageY
-
this
.
el
[
0
].
offsetT
op
,
event
.
offsetY
:
event
.
pageY
-
offset
.
t
op
,
// To reduce differences between values returned by different kinds
// To reduce differences between values returned by different kinds
// of browsers, we round `posX` and `posY`.
// of browsers, we round `posX` and `posY`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment