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
0a7c8401
Commit
0a7c8401
authored
Dec 23, 2012
by
fat-kun
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6375 from tkawachi/tooltip-events-2.3.0
Tooltips fires show, shown, hide, hidden events
parents
48211ad9
defe85bb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
+88
-0
js/bootstrap-tooltip.js
js/bootstrap-tooltip.js
+11
-0
js/tests/unit/bootstrap-tooltip.js
js/tests/unit/bootstrap-tooltip.js
+77
-0
No files found.
js/bootstrap-tooltip.js
View file @
0a7c8401
...
...
@@ -110,8 +110,11 @@
,
actualHeight
,
placement
,
tp
,
e
=
$
.
Event
(
'
show
'
)
if
(
this
.
hasContent
()
&&
this
.
enabled
)
{
this
.
$element
.
trigger
(
e
)
if
(
e
.
isDefaultPrevented
())
return
$tip
=
this
.
tip
()
this
.
setContent
()
...
...
@@ -152,6 +155,8 @@
.
offset
(
tp
)
.
addClass
(
placement
)
.
addClass
(
'
in
'
)
this
.
$element
.
trigger
(
'
shown
'
)
}
}
...
...
@@ -166,6 +171,10 @@
,
hide
:
function
()
{
var
that
=
this
,
$tip
=
this
.
tip
()
,
e
=
$
.
Event
(
'
hide
'
)
this
.
$element
.
trigger
(
e
)
if
(
e
.
isDefaultPrevented
())
return
$tip
.
removeClass
(
'
in
'
)
...
...
@@ -184,6 +193,8 @@
removeWithAnimation
()
:
$tip
.
detach
()
this
.
$element
.
trigger
(
'
hidden
'
)
return
this
}
...
...
js/tests/unit/bootstrap-tooltip.js
View file @
0a7c8401
...
...
@@ -66,6 +66,83 @@ $(function () {
ok
(
!
$
(
"
.tooltip
"
).
length
,
'
tooltip removed
'
)
})
test
(
"
should fire show event
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
show
"
,
function
()
{
ok
(
true
,
"
show was called
"
)
start
()
})
.
tooltip
(
'
show
'
)
})
test
(
"
should fire shown event
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
shown
"
,
function
()
{
ok
(
true
,
"
shown was called
"
)
start
()
})
.
tooltip
(
'
show
'
)
})
test
(
"
should not fire shown event when default prevented
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
show
"
,
function
(
e
)
{
e
.
preventDefault
()
ok
(
true
,
"
show was called
"
)
start
()
})
.
bind
(
"
shown
"
,
function
()
{
ok
(
false
,
"
shown was called
"
)
})
.
tooltip
(
'
show
'
)
})
test
(
"
should fire hide event
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
shown
"
,
function
()
{
$
(
this
).
tooltip
(
'
hide
'
)
})
.
bind
(
"
hide
"
,
function
()
{
ok
(
true
,
"
hide was called
"
)
start
()
})
.
tooltip
(
'
show
'
)
})
test
(
"
should fire hidden event
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
shown
"
,
function
()
{
$
(
this
).
tooltip
(
'
hide
'
)
})
.
bind
(
"
hidden
"
,
function
()
{
ok
(
true
,
"
hidden was called
"
)
start
()
})
.
tooltip
(
'
show
'
)
})
test
(
"
should not fire hidden event when default prevented
"
,
function
()
{
stop
()
var
tooltip
=
$
(
'
<div title="tooltip title"></div>
'
)
.
bind
(
"
shown
"
,
function
()
{
$
(
this
).
tooltip
(
'
hide
'
)
})
.
bind
(
"
hide
"
,
function
(
e
)
{
e
.
preventDefault
()
ok
(
true
,
"
hide was called
"
)
start
()
})
.
bind
(
"
hidden
"
,
function
()
{
ok
(
false
,
"
hidden was called
"
)
})
.
tooltip
(
'
show
'
)
})
test
(
"
should not show tooltip if leave event occurs before delay expires
"
,
function
()
{
var
tooltip
=
$
(
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
...
...
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