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
094458dd
Commit
094458dd
authored
Mar 11, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified tooltip positioning on non-overlapping annotation spans.
parent
60b06026
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
+35
-0
No files found.
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
View file @
094458dd
...
@@ -75,6 +75,7 @@ class @Annotatable
...
@@ -75,6 +75,7 @@ class @Annotatable
classes
:
'ui-tooltip-annotatable'
classes
:
'ui-tooltip-annotatable'
events
:
events
:
show
:
@
onShowTip
show
:
@
onShowTip
move
:
@
onMoveTip
onClickToggleAnnotations
:
(
e
)
=>
@
toggleAnnotations
()
onClickToggleAnnotations
:
(
e
)
=>
@
toggleAnnotations
()
...
@@ -87,6 +88,40 @@ class @Annotatable
...
@@ -87,6 +88,40 @@ class @Annotatable
onShowTip
:
(
event
,
api
)
=>
onShowTip
:
(
event
,
api
)
=>
event
.
preventDefault
()
if
@
annotationsHidden
event
.
preventDefault
()
if
@
annotationsHidden
onMoveTip
:
(
event
,
api
,
position
)
=>
###
This method handles an edge case in which a tooltip is displayed above
a non-overlapping span like this:
(( TOOLTIP ))
\/
text text text ... text text text ...... <span span span>
<span span span>
The problem is that the tooltip looks disconnected from both spans, so
we should re-position the tooltip to appear above the span.
###
tip
=
api
.
elements
.
tooltip
adjust_y
=
api
.
options
.
position
?
.
adjust
?
.
y
||
0
target
=
api
.
elements
.
target
rects
=
$
(
target
).
get
(
0
).
getClientRects
()
is_non_overlapping
=
(
rects
?
.
length
==
2
and
rects
[
0
].
left
>
rects
[
1
].
right
)
if
is_non_overlapping
focus_rect
=
rects
[
0
]
rect_center
=
focus_rect
.
left
+
(
focus_rect
.
width
/
2
)
rect_top
=
focus_rect
.
top
tip_width
=
$
(
tip
).
width
()
tip_height
=
$
(
tip
).
height
()
tip_left
=
rect_center
-
(
tip_width
/
2
)
tip_top
=
window
.
pageYOffset
+
rect_top
-
tip_height
+
adjust_y
win_width
=
$
(
window
).
width
()
if
tip_left
+
tip_width
>
win_width
tip_left
=
win_width
-
tip_width
position
.
left
=
tip_left
position
.
top
=
tip_top
getSpanForProblemReturn
:
(
el
)
->
getSpanForProblemReturn
:
(
el
)
->
problem_id
=
$
(
@
problemReturnSelector
).
index
(
el
)
problem_id
=
$
(
@
problemReturnSelector
).
index
(
el
)
@
$
(
@
spanSelector
).
filter
(
"[data-problem-id='
#{
problem_id
}
']"
)
@
$
(
@
spanSelector
).
filter
(
"[data-problem-id='
#{
problem_id
}
']"
)
...
...
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