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
37a10d37
Commit
37a10d37
authored
Mar 24, 2015
by
Adrien
Committed by
Chris Rebert
Apr 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compare tooltip right offset to viewport right offset (and not width)
Closes #16142 by merging it.
parent
d0926f2d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+27
-0
js/tooltip.js
js/tooltip.js
+1
-1
No files found.
js/tests/unit/tooltip.js
View file @
37a10d37
...
@@ -764,6 +764,33 @@ $(function () {
...
@@ -764,6 +764,33 @@ $(function () {
$styles
.
remove
()
$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
)
{
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
)
assert
.
expect
(
1
)
var
passed
=
true
var
passed
=
true
...
...
js/tooltip.js
View file @
37a10d37
...
@@ -378,7 +378,7 @@
...
@@ -378,7 +378,7 @@
var
rightEdgeOffset
=
pos
.
left
+
viewportPadding
+
actualWidth
var
rightEdgeOffset
=
pos
.
left
+
viewportPadding
+
actualWidth
if
(
leftEdgeOffset
<
viewportDimensions
.
left
)
{
// left overflow
if
(
leftEdgeOffset
<
viewportDimensions
.
left
)
{
// left overflow
delta
.
left
=
viewportDimensions
.
left
-
leftEdgeOffset
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
delta
.
left
=
viewportDimensions
.
left
+
viewportDimensions
.
width
-
rightEdgeOffset
}
}
}
}
...
...
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