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
db9e8ee8
Commit
db9e8ee8
authored
Sep 09, 2014
by
saranya.r
Committed by
Heinrich Fenkart
Sep 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tooltip misplacement with "auto top"
Fixes #14322. Closes #14581.
parent
c5c67d0f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+50
-0
js/tooltip.js
js/tooltip.js
+1
-1
No files found.
js/tests/unit/tooltip.js
View file @
db9e8ee8
...
@@ -382,6 +382,56 @@ $(function () {
...
@@ -382,6 +382,56 @@ $(function () {
$style
.
remove
()
$style
.
remove
()
})
})
test
(
'
should position tip on top if viewport has enough space and placement is "auto top"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
body { padding-top: 100px; }
'
+
'
section { height: 300px; border: 1px solid red; padding-top: 50px }
'
+
'
div[rel="tooltip"] { width: 150px; border: 1px solid blue; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<section/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip"/>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
auto top
'
,
viewport
:
'
section
'
})
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.top
'
),
'
top positioned tooltip is dynamically positioned to top
'
)
$target
.
bootstrapTooltip
(
'
hide
'
)
equal
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$styles
.
remove
()
})
test
(
'
should position tip on bottom if the tip
\'
s dimension exceeds the viewport area and placement is "auto top"
'
,
function
()
{
var
styles
=
'
<style>
'
+
'
body { padding-top: 100px; }
'
+
'
section { height: 300px; border: 1px solid red; }
'
+
'
div[rel="tooltip"] { width: 150px; border: 1px solid blue; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<section/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$target
=
$
(
'
<div rel="tooltip" title="tip"/>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
placement
:
'
auto top
'
,
viewport
:
'
section
'
})
$target
.
bootstrapTooltip
(
'
show
'
)
ok
(
$
(
'
.tooltip
'
).
is
(
'
.bottom
'
),
'
top positioned tooltip is dynamically positioned to bottom
'
)
$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 @
db9e8ee8
...
@@ -192,7 +192,7 @@
...
@@ -192,7 +192,7 @@
var
parentDim
=
this
.
getPosition
(
$parent
)
var
parentDim
=
this
.
getPosition
(
$parent
)
placement
=
placement
==
'
bottom
'
&&
pos
.
top
+
pos
.
height
+
actualHeight
-
parentDim
.
scroll
>
parentDim
.
height
?
'
top
'
:
placement
=
placement
==
'
bottom
'
&&
pos
.
top
+
pos
.
height
+
actualHeight
-
parentDim
.
scroll
>
parentDim
.
height
?
'
top
'
:
placement
==
'
top
'
&&
pos
.
top
-
parentDim
.
scroll
-
actualHeight
<
0
?
'
bottom
'
:
placement
==
'
top
'
&&
pos
.
top
-
parentDim
.
scroll
-
actualHeight
<
parentDim
.
top
?
'
bottom
'
:
placement
==
'
right
'
&&
pos
.
right
+
actualWidth
>
parentDim
.
width
?
'
left
'
:
placement
==
'
right
'
&&
pos
.
right
+
actualWidth
>
parentDim
.
width
?
'
left
'
:
placement
==
'
left
'
&&
pos
.
left
-
actualWidth
<
parentDim
.
left
?
'
right
'
:
placement
==
'
left
'
&&
pos
.
left
-
actualWidth
<
parentDim
.
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