Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
37a10d37
Commit
37a10d37
authored
10 years ago
by
Adrien
Committed by
Chris Rebert
9 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Compare tooltip right offset to viewport right offset (and not width)
Closes #16142 by merging it.
parent
d0926f2d
4 merge requests
!28721
Hot test
,
!16605
Test pull please ignore
,
!22103
test
,
!25326
Adjust examples
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/tests/unit/tooltip.js
+27
-0
js/tests/unit/tooltip.js
js/tooltip.js
+1
-1
js/tooltip.js
with
28 additions
and
1 deletion
+28
-1
js/tests/unit/tooltip.js
+
27
-
0
View file @
37a10d37
...
...
@@ -764,6 +764,33 @@ $(function () {
$styles
.
remove
()
})
QUnit
.
test
(
'
should not misplace the tip when the right edge offset is greater or equal than the viewport width
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
var
styles
=
'
<style>
'
+
'
.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }
'
+
'
.tooltip, .tooltip .tooltip-inner { width: 50px; height: 50px; max-width: none; background: red; }
'
+
'
.container-viewport { padding: 100px; margin-left: 100px; width: 100px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
var
$container
=
$
(
'
<div class="container-viewport"/>
'
).
appendTo
(
document
.
body
)
var
$target
=
$
(
'
<a href="#" rel="tooltip" title="tip">foobar</a>
'
)
.
appendTo
(
$container
)
.
bootstrapTooltip
({
viewport
:
'
.container-viewport
'
})
$target
.
bootstrapTooltip
(
'
show
'
)
var
$tooltip
=
$container
.
find
(
'
.tooltip
'
)
assert
.
strictEqual
(
Math
.
round
(
$tooltip
.
offset
().
left
),
Math
.
round
(
$target
.
position
().
left
+
$target
.
width
()
/
2
-
$tooltip
[
0
].
offsetWidth
/
2
))
$target
.
bootstrapTooltip
(
'
hide
'
)
assert
.
strictEqual
(
$
(
'
.tooltip
'
).
length
,
0
,
'
tooltip removed from dom
'
)
$container
.
remove
()
$styles
.
remove
()
})
QUnit
.
test
(
'
should not error when trying to show an auto-placed tooltip that has been removed from the dom
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
var
passed
=
true
...
...
This diff is collapsed.
Click to expand it.
js/tooltip.js
+
1
-
1
View file @
37a10d37
...
...
@@ -378,7 +378,7 @@
var
rightEdgeOffset
=
pos
.
left
+
viewportPadding
+
actualWidth
if
(
leftEdgeOffset
<
viewportDimensions
.
left
)
{
// left overflow
delta
.
left
=
viewportDimensions
.
left
-
leftEdgeOffset
}
else
if
(
rightEdgeOffset
>
viewportDimensions
.
width
)
{
// right overflow
}
else
if
(
rightEdgeOffset
>
viewportDimensions
.
right
)
{
// right overflow
delta
.
left
=
viewportDimensions
.
left
+
viewportDimensions
.
width
-
rightEdgeOffset
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets