Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
bootstrap
Commits
ef622549
Commit
ef622549
authored
May 23, 2014
by
Chris Rebert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13557 from bassettsj/aria-describedby-tooltip-13480
Aria describedby tooltip: #13480
parents
66bc4d1c
a70da16f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
+54
-0
dist/js/bootstrap.js
dist/js/bootstrap.js
+12
-0
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+30
-0
js/tooltip.js
js/tooltip.js
+12
-0
No files found.
dist/js/bootstrap.js
View file @
ef622549
...
...
@@ -1233,7 +1233,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var
$tip
=
this
.
tip
()
var
tipId
=
this
.
getUID
(
this
.
type
)
this
.
setContent
()
$tip
.
attr
(
'
id
'
,
tipId
)
this
.
$element
.
attr
(
'
aria-describedby
'
,
tipId
)
if
(
this
.
options
.
animation
)
$tip
.
addClass
(
'
fade
'
)
...
...
@@ -1356,6 +1360,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var
$tip
=
this
.
tip
()
var
e
=
$
.
Event
(
'
hide.bs.
'
+
this
.
type
)
this
.
$element
.
removeAttr
(
'
aria-describedby
'
)
function
complete
()
{
if
(
that
.
hoverState
!=
'
in
'
)
$tip
.
detach
()
that
.
$element
.
trigger
(
'
hidden.bs.
'
+
that
.
type
)
...
...
@@ -1447,6 +1453,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return
title
}
Tooltip
.
prototype
.
getUID
=
function
(
prefix
)
{
do
prefix
+=
~~
(
Math
.
random
()
*
1000000
)
while
(
document
.
getElementById
(
prefix
))
return
prefix
}
Tooltip
.
prototype
.
tip
=
function
()
{
return
this
.
$tip
=
this
.
$tip
||
$
(
this
.
options
.
template
)
}
...
...
js/tests/unit/tooltip.js
View file @
ef622549
...
...
@@ -41,6 +41,36 @@ $(function () {
equal
(
tooltip
.
attr
(
'
data-original-title
'
),
'
Another tooltip
'
,
'
original title preserved in data attribute
'
)
})
test
(
'
should add set set aria describedby to the element called on show
'
,
function
()
{
var
tooltip
=
$
(
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
).
bootstrapTooltip
()
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapTooltip
(
'
show
'
)
ok
(
tooltip
.
attr
(
'
aria-describedby
'
),
'
has the right attributes
'
)
var
id
=
$
(
'
.tooltip
'
).
attr
(
'
id
'
)
ok
(
$
(
'
#
'
+
id
).
length
==
1
,
'
has a unique id
'
)
ok
(
$
(
'
.tooltip
'
).
attr
(
'
aria-describedby
'
)
===
tooltip
.
attr
(
'
id
'
),
'
they match!
'
)
ok
(
tooltip
.
attr
(
'
aria-describedby
'
)
!==
undefined
,
'
has the right attributes
'
)
})
test
(
'
should remove the aria-describedby attributes on hide
'
,
function
()
{
var
tooltip
=
$
(
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
).
bootstrapTooltip
()
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapTooltip
(
'
show
'
)
ok
(
tooltip
.
attr
(
'
aria-describedby
'
),
'
has the right attributes
'
)
tooltip
.
bootstrapTooltip
(
'
hide
'
)
ok
(
!
tooltip
.
attr
(
'
aria-describedby
'
),
'
removed the attributes on hide
'
)
})
test
(
'
should assign a unique id tooltip element
'
,
function
()
{
$
(
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapTooltip
(
'
show
'
),
id
=
$
(
'
.tooltip
'
).
attr
(
'
id
'
)
ok
(
$
(
'
#
'
+
id
).
length
==
1
&&
id
.
indexOf
(
'
tooltip
'
)
===
0
,
'
generated prefixed and unique tooltip id
'
)
})
test
(
'
should place tooltips relative to placement option
'
,
function
()
{
$
.
support
.
transition
=
false
var
tooltip
=
$
(
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
)
...
...
js/tooltip.js
View file @
ef622549
...
...
@@ -150,7 +150,11 @@
var
$tip
=
this
.
tip
()
var
tipId
=
this
.
getUID
(
this
.
type
)
this
.
setContent
()
$tip
.
attr
(
'
id
'
,
tipId
)
this
.
$element
.
attr
(
'
aria-describedby
'
,
tipId
)
if
(
this
.
options
.
animation
)
$tip
.
addClass
(
'
fade
'
)
...
...
@@ -273,6 +277,8 @@
var
$tip
=
this
.
tip
()
var
e
=
$
.
Event
(
'
hide.bs.
'
+
this
.
type
)
this
.
$element
.
removeAttr
(
'
aria-describedby
'
)
function
complete
()
{
if
(
that
.
hoverState
!=
'
in
'
)
$tip
.
detach
()
that
.
$element
.
trigger
(
'
hidden.bs.
'
+
that
.
type
)
...
...
@@ -364,6 +370,12 @@
return
title
}
Tooltip
.
prototype
.
getUID
=
function
(
prefix
)
{
do
prefix
+=
~~
(
Math
.
random
()
*
1000000
)
while
(
document
.
getElementById
(
prefix
))
return
prefix
}
Tooltip
.
prototype
.
tip
=
function
()
{
return
this
.
$tip
=
this
.
$tip
||
$
(
this
.
options
.
template
)
}
...
...
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