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
4c985070
Commit
4c985070
authored
Jun 03, 2014
by
Peter West
Committed by
Heinrich Fenkart
Sep 13, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly selects arrow placement for a tooltip
Fixes #13696. Fixes #13696. Fixes #14197. Closes #13718.
parent
0a4c39dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
6 deletions
+39
-6
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+31
-0
js/tooltip.js
js/tooltip.js
+8
-6
No files found.
js/tests/unit/tooltip.js
View file @
4c985070
...
@@ -836,4 +836,35 @@ $(function () {
...
@@ -836,4 +836,35 @@ $(function () {
equal
(
currentUid
,
$
(
'
#tt-content
'
).
text
())
equal
(
currentUid
,
$
(
'
#tt-content
'
).
text
())
})
})
test
(
'
should position arrow correctly when tooltip is moved to not appear offscreen
'
,
function
()
{
stop
()
var
styles
=
'
<style>
'
+
'
.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }
'
+
'
.tooltip { position: absolute; }
'
+
'
.tooltip-arrow { position: absolute; width: 0; height: 0; }
'
+
'
.tooltip .tooltip-inner { max-width: 200px; padding: 3px 8px; }
'
+
'
</style>
'
var
$styles
=
$
(
styles
).
appendTo
(
'
head
'
)
$
(
'
<a href="#" title="tooltip title" style="position: absolute; bottom: 0; right: 0;">Foobar</a>
'
)
.
appendTo
(
'
body
'
)
.
on
(
'
shown.bs.tooltip
'
,
function
()
{
var
arrowStyles
=
$
(
this
).
data
(
'
bs.tooltip
'
).
$tip
.
find
(
'
.tooltip-arrow
'
).
attr
(
'
style
'
)
ok
(
/left/i
.
test
(
arrowStyles
)
&&
!
/top/i
.
test
(
arrowStyles
),
'
arrow positioned correctly
'
)
$
(
this
).
bootstrapTooltip
(
'
hide
'
)
})
.
on
(
'
hidden.bs.tooltip
'
,
function
()
{
$styles
.
remove
()
$
(
this
).
remove
()
start
()
})
.
bootstrapTooltip
({
container
:
'
body
'
,
placement
:
'
top
'
,
trigger
:
'
manual
'
})
.
bootstrapTooltip
(
'
show
'
)
})
})
})
js/tooltip.js
View file @
4c985070
...
@@ -261,16 +261,18 @@
...
@@ -261,16 +261,18 @@
if
(
delta
.
left
)
offset
.
left
+=
delta
.
left
if
(
delta
.
left
)
offset
.
left
+=
delta
.
left
else
offset
.
top
+=
delta
.
top
else
offset
.
top
+=
delta
.
top
var
arrowDelta
=
delta
.
left
?
delta
.
left
*
2
-
width
+
actualWidth
:
delta
.
top
*
2
-
height
+
actualHeight
var
isVertical
=
/top|bottom/
.
test
(
placement
)
var
arrow
Position
=
delta
.
left
?
'
left
'
:
'
top
'
var
arrow
Delta
=
isVertical
?
delta
.
left
*
2
-
width
+
actualWidth
:
delta
.
top
*
2
-
height
+
actualHeight
var
arrowOffsetPosition
=
delta
.
left
?
'
offsetWidth
'
:
'
offsetHeight
'
var
arrowOffsetPosition
=
isVertical
?
'
offsetWidth
'
:
'
offsetHeight
'
$tip
.
offset
(
offset
)
$tip
.
offset
(
offset
)
this
.
replaceArrow
(
arrowDelta
,
$tip
[
0
][
arrowOffsetPosition
],
arrowPosition
)
this
.
replaceArrow
(
arrowDelta
,
$tip
[
0
][
arrowOffsetPosition
],
isVertical
)
}
}
Tooltip
.
prototype
.
replaceArrow
=
function
(
delta
,
dimension
,
position
)
{
Tooltip
.
prototype
.
replaceArrow
=
function
(
delta
,
dimension
,
isHorizontal
)
{
this
.
arrow
().
css
(
position
,
delta
?
(
50
*
(
1
-
delta
/
dimension
)
+
'
%
'
)
:
''
)
this
.
arrow
()
.
css
(
isHorizontal
?
'
left
'
:
'
top
'
,
50
*
(
1
-
delta
/
dimension
)
+
'
%
'
)
.
css
(
isHorizontal
?
'
top
'
:
'
left
'
,
''
)
}
}
Tooltip
.
prototype
.
setContent
=
function
()
{
Tooltip
.
prototype
.
setContent
=
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