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
ee71fb49
Commit
ee71fb49
authored
12 years ago
by
Guillaume Gautreau
Browse files
Options
Download
Email Patches
Plain Diff
No semicolumns
parent
5b0f956a
2 merge requests
!6821
Typeahead updater
,
!6713
Positioning tooltip on edge case
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/bootstrap-tooltip.js
+23
-23
js/bootstrap-tooltip.js
js/tests/unit/bootstrap-tooltip.js
+21
-21
js/tests/unit/bootstrap-tooltip.js
with
44 additions
and
44 deletions
+44
-44
js/bootstrap-tooltip.js
+
23
-
23
View file @
ee71fb49
...
...
@@ -152,7 +152,7 @@
break
}
this
.
applyPlacement
(
tp
,
placement
)
;
this
.
applyPlacement
(
tp
,
placement
)
this
.
$element
.
trigger
(
'
shown
'
)
}
...
...
@@ -165,52 +165,52 @@
,
actualWidth
,
actualHeight
,
delta
,
replace
=
false
;
,
replace
=
false
$tip
=
this
.
tip
()
;
$tip
=
this
.
tip
()
width
=
$tip
[
0
].
offsetWidth
;
height
=
$tip
[
0
].
offsetHeight
;
width
=
$tip
[
0
].
offsetWidth
height
=
$tip
[
0
].
offsetHeight
$tip
.
offset
(
offset
)
.
addClass
(
placement
)
.
addClass
(
'
in
'
)
;
.
addClass
(
'
in
'
)
actualWidth
=
$tip
[
0
].
offsetWidth
;
actualHeight
=
$tip
[
0
].
offsetHeight
;
actualWidth
=
$tip
[
0
].
offsetWidth
actualHeight
=
$tip
[
0
].
offsetHeight
if
(
placement
==
"
top
"
&&
actualHeight
!=
height
){
offset
.
top
=
offset
.
top
+
height
-
actualHeight
;
replace
=
true
;
offset
.
top
=
offset
.
top
+
height
-
actualHeight
replace
=
true
}
if
(
placement
==
"
bottom
"
||
placement
==
"
top
"
){
delta
=
0
;
delta
=
0
if
(
offset
.
left
<
0
){
delta
=
-
offset
.
left
*
2
;
offset
.
left
=
0
;
$tip
.
offset
(
offset
)
;
actualWidth
=
$tip
[
0
].
offsetWidth
;
actualHeight
=
$tip
[
0
].
offsetHeight
;
delta
=
-
offset
.
left
*
2
offset
.
left
=
0
$tip
.
offset
(
offset
)
actualWidth
=
$tip
[
0
].
offsetWidth
actualHeight
=
$tip
[
0
].
offsetHeight
}
this
.
replaceArrow
(
delta
-
width
+
actualWidth
,
actualWidth
,
"
left
"
)
;
this
.
replaceArrow
(
delta
-
width
+
actualWidth
,
actualWidth
,
"
left
"
)
}
else
{
this
.
replaceArrow
(
actualHeight
-
height
,
actualHeight
,
"
top
"
)
;
this
.
replaceArrow
(
actualHeight
-
height
,
actualHeight
,
"
top
"
)
}
if
(
replace
)
$tip
.
offset
(
offset
)
;
if
(
replace
)
$tip
.
offset
(
offset
)
}
,
replaceArrow
:
function
(
delta
,
dimension
,
position
){
var
$arrow
=
this
.
arrow
()
;
var
$arrow
=
this
.
arrow
()
if
(
delta
!==
0
){
$arrow
.
css
(
position
,
50
*
(
1
-
delta
/
dimension
)
+
"
%
"
)
;
$arrow
.
css
(
position
,
50
*
(
1
-
delta
/
dimension
)
+
"
%
"
)
}
else
{
$arrow
.
css
(
position
,
""
)
;
$arrow
.
css
(
position
,
""
)
}
}
...
...
@@ -287,7 +287,7 @@
}
,
arrow
:
function
(){
return
this
.
$arrow
=
this
.
$arrow
||
this
.
tip
().
find
(
"
.tooltip-arrow
"
)
;
return
this
.
$arrow
=
this
.
$arrow
||
this
.
tip
().
find
(
"
.tooltip-arrow
"
)
}
,
validate
:
function
()
{
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-tooltip.js
+
21
-
21
View file @
ee71fb49
...
...
@@ -259,17 +259,17 @@ $(function () {
.
css
({
position
:
"
absolute
"
,
top
:
0
,
left
:
0
})
.
appendTo
(
container
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
;
.
tooltip
(
"
show
"
)
stop
()
;
stop
()
setTimeout
(
function
(){
ok
(
$
(
"
.tooltip
"
).
offset
().
left
>=
0
)
;
ok
(
$
(
"
.tooltip
"
).
offset
().
left
>=
0
)
start
()
;
container
.
remove
()
;
start
()
container
.
remove
()
},
100
)
})
;
})
test
(
"
should place tooltip on top of element
"
,
function
(){
var
container
=
$
(
"
<div />
"
).
appendTo
(
"
body
"
)
...
...
@@ -279,18 +279,18 @@ $(function () {
.
css
({
marginTop
:
200
})
.
appendTo
(
p
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
;
.
tooltip
(
"
show
"
)
stop
()
;
stop
()
setTimeout
(
function
(){
var
tooltip
=
container
.
find
(
"
.tooltip
"
)
;
var
tooltip
=
container
.
find
(
"
.tooltip
"
)
start
()
;
ok
(
tooltip
.
offset
().
top
+
tooltip
.
outerHeight
()
<=
tooltiped
.
offset
().
top
)
;
container
.
remove
()
;
start
()
ok
(
tooltip
.
offset
().
top
+
tooltip
.
outerHeight
()
<=
tooltiped
.
offset
().
top
)
container
.
remove
()
},
100
)
})
;
})
test
(
"
arrow should point to element
"
,
function
(){
var
container
=
$
(
"
<div />
"
).
appendTo
(
"
body
"
)
...
...
@@ -300,16 +300,16 @@ $(function () {
.
css
({
marginTop
:
200
})
.
appendTo
(
p
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
;
.
tooltip
(
"
show
"
)
stop
()
;
stop
()
setTimeout
(
function
(){
var
arrow
=
container
.
find
(
"
.tooltip-arrow
"
)
;
var
arrow
=
container
.
find
(
"
.tooltip-arrow
"
)
start
()
;
ok
(
Math
.
abs
(
arrow
.
offset
().
left
-
tooltiped
.
offset
().
left
-
tooltiped
.
outerWidth
()
/
2
)
<=
1
)
;
container
.
remove
()
;
},
100
)
;
})
;
start
()
ok
(
Math
.
abs
(
arrow
.
offset
().
left
-
tooltiped
.
offset
().
left
-
tooltiped
.
outerWidth
()
/
2
)
<=
1
)
container
.
remove
()
},
100
)
})
})
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