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
e2cfbd5f
Commit
e2cfbd5f
authored
Oct 10, 2014
by
saranya.r
Committed by
Heinrich Fenkart
Oct 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes tooltip misplacements in scrollable viewports with auto positioning
Fixes #14756. Closes #14767.
parent
2bc5277b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
4 deletions
+108
-4
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+104
-0
js/tooltip.js
js/tooltip.js
+4
-4
No files found.
js/tests/unit/tooltip.js
View file @
e2cfbd5f
...
@@ -432,6 +432,110 @@ $(function () {
...
@@ -432,6 +432,110 @@ $(function () {
$styles
.
remove
()
$styles
.
remove
()
})
})
test
(
'
should display the tip on top whenever scrollable viewport has enough room if the given placement is "auto top"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
#scrollable-div { height: 200px; overflow: auto; }
'
+
'
.tooltip-item { margin: 200px 0 400px; width: 150px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<div id="scrollable-div"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip" class="tooltip-item">Tooltip Item</div>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
top auto
'
,
viewport
:
'
#scrollable-div
'
})
$
(
'
#scrollable-div
'
).
scrollTop
(
100
)
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.fade.top.in
'
),
'
has correct classes applied
'
)
$target
.
bootstrapTooltip
(
'
hide
'
)
equal
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$styles
.
remove
()
})
test
(
'
should display the tip on bottom whenever scrollable viewport doesn
\'
t have enough room if the given placement is "auto top"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
#scrollable-div { height: 200px; overflow: auto; }
'
+
'
.tooltip-item { margin: 200px 0 400px; width: 150px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<div id="scrollable-div"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip" class="tooltip-item">Tooltip Item</div>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
top auto
'
,
viewport
:
'
#scrollable-div
'
})
$
(
'
#scrollable-div
'
).
scrollTop
(
200
)
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.fade.bottom.in
'
),
'
has correct classes applied
'
)
$target
.
bootstrapTooltip
(
'
hide
'
)
equal
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$styles
.
remove
()
})
test
(
'
should display the tip on bottom whenever scrollable viewport has enough room if the given placement is "auto bottom"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
#scrollable-div { height: 200px; overflow: auto; }
'
+
'
.tooltip-item { margin: 200px 0 400px; width: 150px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<div id="scrollable-div"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip" class="tooltip-item">Tooltip Item</div>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
bottom auto
'
,
viewport
:
'
#scrollable-div
'
})
$
(
'
#scrollable-div
'
).
scrollTop
(
200
)
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.fade.bottom.in
'
),
'
has correct classes applied
'
)
$target
.
bootstrapTooltip
(
'
hide
'
)
equal
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$styles
.
remove
()
})
test
(
'
should display the tip on top whenever scrollable viewport doesn
\'
t have enough room if the given placement is "auto bottom"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
#scrollable-div { height: 200px; overflow: auto; }
'
+
'
.tooltip-item { margin-top: 400px; width: 150px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<div id="scrollable-div"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip" class="tooltip-item">Tooltip Item</div>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
bottom auto
'
,
viewport
:
'
#scrollable-div
'
})
$
(
'
#scrollable-div
'
).
scrollTop
(
400
)
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.fade.top.in
'
),
'
has correct classes applied
'
)
$target
.
bootstrapTooltip
(
'
hide
'
)
equal
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$styles
.
remove
()
})
test
(
'
should adjust the tip
\'
s top position when up against the top of the viewport
'
,
function
()
{
test
(
'
should adjust the tip
\'
s top position when up against the top of the viewport
'
,
function
()
{
var
styles
=
'
<style>
'
var
styles
=
'
<style>
'
+
'
.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }
'
+
'
.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }
'
...
...
js/tooltip.js
View file @
e2cfbd5f
...
@@ -191,8 +191,8 @@
...
@@ -191,8 +191,8 @@
var
$container
=
this
.
options
.
container
?
$
(
this
.
options
.
container
)
:
this
.
$element
.
parent
()
var
$container
=
this
.
options
.
container
?
$
(
this
.
options
.
container
)
:
this
.
$element
.
parent
()
var
containerDim
=
this
.
getPosition
(
$container
)
var
containerDim
=
this
.
getPosition
(
$container
)
placement
=
placement
==
'
bottom
'
&&
pos
.
top
+
pos
.
height
+
actualHeight
-
containerDim
.
scroll
>
containerDim
.
height
?
'
top
'
:
placement
=
placement
==
'
bottom
'
&&
pos
.
bottom
+
actualHeight
>
containerDim
.
bottom
?
'
top
'
:
placement
==
'
top
'
&&
pos
.
top
-
containerDim
.
scroll
-
actualHeight
<
containerDim
.
top
?
'
bottom
'
:
placement
==
'
top
'
&&
pos
.
top
-
actualHeight
<
containerDim
.
top
?
'
bottom
'
:
placement
==
'
right
'
&&
pos
.
right
+
actualWidth
>
containerDim
.
width
?
'
left
'
:
placement
==
'
right
'
&&
pos
.
right
+
actualWidth
>
containerDim
.
width
?
'
left
'
:
placement
==
'
left
'
&&
pos
.
left
-
actualWidth
<
containerDim
.
left
?
'
right
'
:
placement
==
'
left
'
&&
pos
.
left
-
actualWidth
<
containerDim
.
left
?
'
right
'
:
placement
placement
...
...
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