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
4b269037
Commit
4b269037
authored
Mar 06, 2015
by
Braden M. Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multiple tooltip triggers don't play well together
Fixes issue #16008
parent
421eacb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
6 deletions
+70
-6
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+38
-0
js/tooltip.js
js/tooltip.js
+32
-6
No files found.
js/tests/unit/tooltip.js
View file @
4b269037
...
@@ -1284,4 +1284,42 @@ $(function () {
...
@@ -1284,4 +1284,42 @@ $(function () {
},
new
Error
(
'
tooltip `template` option must consist of exactly 1 top-level element!
'
))
},
new
Error
(
'
tooltip `template` option must consist of exactly 1 top-level element!
'
))
})
})
QUnit
.
test
(
'
should not remove tooltip if multiple triggers are set and one is still active
'
,
function
(
assert
)
{
assert
.
expect
(
41
)
var
$el
=
$
(
'
<button>Trigger</button>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapTooltip
({
trigger
:
'
click hover focus
'
,
animation
:
false
})
var
tooltip
=
$el
.
data
(
'
bs.tooltip
'
)
var
$tooltip
=
tooltip
.
tip
()
function
showingTooltip
()
{
return
$tooltip
.
hasClass
(
'
in
'
)
||
tooltip
.
hoverState
==
'
in
'
}
var
tests
=
[
[
'
mouseenter
'
,
'
mouseleave
'
],
[
'
focusin
'
,
'
focusout
'
],
[
'
click
'
,
'
click
'
],
[
'
mouseenter
'
,
'
focusin
'
,
'
focusout
'
,
'
mouseleave
'
],
[
'
mouseenter
'
,
'
focusin
'
,
'
mouseleave
'
,
'
focusout
'
],
[
'
focusin
'
,
'
mouseenter
'
,
'
mouseleave
'
,
'
focusout
'
],
[
'
focusin
'
,
'
mouseenter
'
,
'
focusout
'
,
'
mouseleave
'
],
[
'
click
'
,
'
focusin
'
,
'
mouseenter
'
,
'
focusout
'
,
'
mouseleave
'
,
'
click
'
],
[
'
mouseenter
'
,
'
click
'
,
'
focusin
'
,
'
focusout
'
,
'
mouseleave
'
,
'
click
'
],
[
'
mouseenter
'
,
'
focusin
'
,
'
click
'
,
'
click
'
,
'
mouseleave
'
,
'
focusout
'
]
]
assert
.
ok
(
!
showingTooltip
())
$
.
each
(
tests
,
function
(
idx
,
triggers
)
{
for
(
var
i
=
0
,
len
=
triggers
.
length
;
i
<
len
;
i
++
)
{
$el
.
trigger
(
triggers
[
i
]);
assert
.
equal
(
i
<
(
len
-
1
),
showingTooltip
())
}
})
})
})
})
js/tooltip.js
View file @
4b269037
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
this
.
timeout
=
null
this
.
timeout
=
null
this
.
hoverState
=
null
this
.
hoverState
=
null
this
.
$element
=
null
this
.
$element
=
null
this
.
inState
=
null
this
.
init
(
'
tooltip
'
,
element
,
options
)
this
.
init
(
'
tooltip
'
,
element
,
options
)
}
}
...
@@ -51,6 +52,7 @@
...
@@ -51,6 +52,7 @@
this
.
$element
=
$
(
element
)
this
.
$element
=
$
(
element
)
this
.
options
=
this
.
getOptions
(
options
)
this
.
options
=
this
.
getOptions
(
options
)
this
.
$viewport
=
this
.
options
.
viewport
&&
$
(
$
.
isFunction
(
this
.
options
.
viewport
)
?
this
.
options
.
viewport
.
call
(
this
,
this
.
$element
)
:
(
this
.
options
.
viewport
.
selector
||
this
.
options
.
viewport
))
this
.
$viewport
=
this
.
options
.
viewport
&&
$
(
$
.
isFunction
(
this
.
options
.
viewport
)
?
this
.
options
.
viewport
.
call
(
this
,
this
.
$element
)
:
(
this
.
options
.
viewport
.
selector
||
this
.
options
.
viewport
))
this
.
inState
=
{
click
:
false
,
hover
:
false
,
focus
:
false
}
if
(
this
.
$element
[
0
]
instanceof
document
.
constructor
&&
!
this
.
options
.
selector
)
{
if
(
this
.
$element
[
0
]
instanceof
document
.
constructor
&&
!
this
.
options
.
selector
)
{
throw
new
Error
(
'
`selector` option must be specified when initializing
'
+
this
.
type
+
'
on the window.document object!
'
)
throw
new
Error
(
'
`selector` option must be specified when initializing
'
+
this
.
type
+
'
on the window.document object!
'
)
...
@@ -109,16 +111,20 @@
...
@@ -109,16 +111,20 @@
var
self
=
obj
instanceof
this
.
constructor
?
var
self
=
obj
instanceof
this
.
constructor
?
obj
:
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
)
obj
:
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
)
if
(
self
&&
self
.
$tip
&&
self
.
$tip
.
is
(
'
:visible
'
))
{
self
.
hoverState
=
'
in
'
return
}
if
(
!
self
)
{
if
(
!
self
)
{
self
=
new
this
.
constructor
(
obj
.
currentTarget
,
this
.
getDelegateOptions
())
self
=
new
this
.
constructor
(
obj
.
currentTarget
,
this
.
getDelegateOptions
())
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
,
self
)
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
,
self
)
}
}
if
(
obj
instanceof
$
.
Event
)
{
self
.
inState
[
obj
.
type
==
'
focusin
'
?
'
focus
'
:
'
hover
'
]
=
true
}
if
(
self
.
tip
().
hasClass
(
'
in
'
)
||
self
.
hoverState
==
'
in
'
)
{
self
.
hoverState
=
'
in
'
return
}
clearTimeout
(
self
.
timeout
)
clearTimeout
(
self
.
timeout
)
self
.
hoverState
=
'
in
'
self
.
hoverState
=
'
in
'
...
@@ -130,6 +136,14 @@
...
@@ -130,6 +136,14 @@
},
self
.
options
.
delay
.
show
)
},
self
.
options
.
delay
.
show
)
}
}
Tooltip
.
prototype
.
isInStateTrue
=
function
()
{
for
(
var
key
in
this
.
inState
)
{
if
(
this
.
inState
[
key
])
return
true
}
return
false
}
Tooltip
.
prototype
.
leave
=
function
(
obj
)
{
Tooltip
.
prototype
.
leave
=
function
(
obj
)
{
var
self
=
obj
instanceof
this
.
constructor
?
var
self
=
obj
instanceof
this
.
constructor
?
obj
:
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
)
obj
:
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
)
...
@@ -139,6 +153,12 @@
...
@@ -139,6 +153,12 @@
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
,
self
)
$
(
obj
.
currentTarget
).
data
(
'
bs.
'
+
this
.
type
,
self
)
}
}
if
(
obj
instanceof
$
.
Event
)
{
self
.
inState
[
obj
.
type
==
'
focusout
'
?
'
focus
'
:
'
hover
'
]
=
false
}
if
(
self
.
isInStateTrue
())
return
clearTimeout
(
self
.
timeout
)
clearTimeout
(
self
.
timeout
)
self
.
hoverState
=
'
out
'
self
.
hoverState
=
'
out
'
...
@@ -438,7 +458,13 @@
...
@@ -438,7 +458,13 @@
}
}
}
}
self
.
tip
().
hasClass
(
'
in
'
)
?
self
.
leave
(
self
)
:
self
.
enter
(
self
)
if
(
e
)
{
self
.
inState
.
click
=
!
self
.
inState
.
click
if
(
self
.
isInStateTrue
())
self
.
enter
(
self
)
else
self
.
leave
(
self
)
}
else
{
self
.
tip
().
hasClass
(
'
in
'
)
?
self
.
leave
(
self
)
:
self
.
enter
(
self
)
}
}
}
Tooltip
.
prototype
.
destroy
=
function
()
{
Tooltip
.
prototype
.
destroy
=
function
()
{
...
...
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