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
d12e173c
Commit
d12e173c
authored
Feb 06, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change TooltipManager API so we can remove fake event
parent
e833d9c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
11 deletions
+25
-11
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+2
-7
common/static/js/spec/tooltip_manager_spec.js
+5
-0
common/static/js/src/tooltip_manager.js
+18
-4
No files found.
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
d12e173c
...
@@ -37,14 +37,9 @@ class @Problem
...
@@ -37,14 +37,9 @@ class @Problem
# Accessibility helper for sighted keyboard users to show <clarification> tooltips on focus:
# Accessibility helper for sighted keyboard users to show <clarification> tooltips on focus:
@
$
(
'.clarification'
).
focus
(
ev
)
=>
@
$
(
'.clarification'
).
focus
(
ev
)
=>
icon
=
$
(
ev
.
target
).
children
"i"
icon
=
$
(
ev
.
target
).
children
"i"
iconPos
=
icon
.
offset
()
window
.
globalTooltipManager
.
openTooltip
icon
fakeEvent
=
jQuery
.
Event
"mouseover"
,
{
pageX
:
iconPos
.
left
+
icon
.
width
()
/
2
,
pageY
:
iconPos
.
top
+
icon
.
height
()
/
2
}
icon
.
trigger
(
fakeEvent
).
trigger
"click"
@
$
(
'.clarification'
).
blur
(
ev
)
=>
@
$
(
'.clarification'
).
blur
(
ev
)
=>
$
(
ev
.
target
).
children
(
"i"
).
trigger
"mouseout"
window
.
globalTooltipManager
.
hide
()
@
bindResetCorrectness
()
@
bindResetCorrectness
()
...
...
common/static/js/spec/tooltip_manager_spec.js
View file @
d12e173c
...
@@ -76,6 +76,11 @@ describe('TooltipManager', function () {
...
@@ -76,6 +76,11 @@ describe('TooltipManager', function () {
expect
(
$
(
'.tooltip'
)).
toBeVisible
();
expect
(
$
(
'.tooltip'
)).
toBeVisible
();
});
});
it
(
'can be be triggered manually'
,
function
()
{
this
.
tooltip
.
openTooltip
(
this
.
element
);
expect
(
$
(
'.tooltip'
)).
toBeVisible
();
});
it
(
'should moves correctly'
,
function
()
{
it
(
'should moves correctly'
,
function
()
{
showTooltip
(
this
.
element
);
showTooltip
(
this
.
element
);
expect
(
$
(
'.tooltip'
)).
toBeVisible
();
expect
(
$
(
'.tooltip'
)).
toBeVisible
();
...
...
common/static/js/src/tooltip_manager.js
View file @
d12e173c
...
@@ -46,15 +46,29 @@
...
@@ -46,15 +46,29 @@
},
},
showTooltip
:
function
(
event
)
{
showTooltip
:
function
(
event
)
{
var
tooltipText
=
$
(
event
.
currentTarget
).
attr
(
'data-tooltip'
);
this
.
prepareTooltip
(
event
.
currentTarget
,
event
.
pageX
,
event
.
pageY
);
if
(
this
.
tooltipTimer
)
{
clearTimeout
(
this
.
tooltipTimer
);
}
this
.
tooltipTimer
=
setTimeout
(
this
.
show
,
500
);
},
prepareTooltip
:
function
(
element
,
pageX
,
pageY
)
{
pageX
=
typeof
pageX
!==
'undefined'
?
pageX
:
element
.
offset
().
left
+
element
.
width
()
/
2
;
pageY
=
typeof
pageY
!==
'undefined'
?
pageY
:
element
.
offset
().
top
+
element
.
height
()
/
2
;
var
tooltipText
=
$
(
element
).
attr
(
'data-tooltip'
);
this
.
tooltip
this
.
tooltip
.
html
(
tooltipText
)
.
html
(
tooltipText
)
.
css
(
this
.
getCoords
(
event
.
pageX
,
event
.
pageY
));
.
css
(
this
.
getCoords
(
pageX
,
pageY
));
},
// To manually trigger a tooltip to reveal, other than through user mouse movement:
openTooltip
:
function
(
element
)
{
this
.
prepareTooltip
(
element
);
this
.
show
();
if
(
this
.
tooltipTimer
)
{
if
(
this
.
tooltipTimer
)
{
clearTimeout
(
this
.
tooltipTimer
);
clearTimeout
(
this
.
tooltipTimer
);
}
}
this
.
tooltipTimer
=
setTimeout
(
this
.
show
,
500
);
},
},
moveTooltip
:
function
(
event
)
{
moveTooltip
:
function
(
event
)
{
...
@@ -90,6 +104,6 @@
...
@@ -90,6 +104,6 @@
window
.
TooltipManager
=
TooltipManager
;
window
.
TooltipManager
=
TooltipManager
;
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
new
TooltipManager
(
document
.
body
);
window
.
globalTooltipManager
=
new
TooltipManager
(
document
.
body
);
});
});
}());
}());
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