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
5e4db94c
Commit
5e4db94c
authored
Feb 05, 2013
by
fat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.0-wip' of
git://github.com/ghusse/bootstrap
into ghusse-2.3.0-wip
parents
a4b31d39
ee71fb49
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
8 deletions
+141
-8
js/bootstrap-tooltip.js
js/bootstrap-tooltip.js
+60
-3
js/tests/index.html
js/tests/index.html
+3
-0
js/tests/unit/bootstrap-tooltip.css
js/tests/unit/bootstrap-tooltip.css
+13
-0
js/tests/unit/bootstrap-tooltip.js
js/tests/unit/bootstrap-tooltip.js
+61
-0
less/tooltip.less
less/tooltip.less
+4
-5
No files found.
js/bootstrap-tooltip.js
View file @
5e4db94c
...
@@ -152,12 +152,65 @@
...
@@ -152,12 +152,65 @@
break
break
}
}
this
.
applyPlacement
(
tp
,
placement
)
this
.
$element
.
trigger
(
'
shown
'
)
}
}
,
applyPlacement
:
function
(
offset
,
placement
){
var
$tip
,
width
,
height
,
actualWidth
,
actualHeight
,
delta
,
replace
=
false
$tip
=
this
.
tip
()
width
=
$tip
[
0
].
offsetWidth
height
=
$tip
[
0
].
offsetHeight
$tip
$tip
.
offset
(
tp
)
.
offset
(
offset
)
.
addClass
(
placement
)
.
addClass
(
placement
)
.
addClass
(
'
in
'
)
.
addClass
(
'
in
'
)
this
.
$element
.
trigger
(
'
shown
'
)
actualWidth
=
$tip
[
0
].
offsetWidth
actualHeight
=
$tip
[
0
].
offsetHeight
if
(
placement
==
"
top
"
&&
actualHeight
!=
height
){
offset
.
top
=
offset
.
top
+
height
-
actualHeight
replace
=
true
}
if
(
placement
==
"
bottom
"
||
placement
==
"
top
"
){
delta
=
0
if
(
offset
.
left
<
0
){
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
"
)
}
else
{
this
.
replaceArrow
(
actualHeight
-
height
,
actualHeight
,
"
top
"
)
}
if
(
replace
)
$tip
.
offset
(
offset
)
}
,
replaceArrow
:
function
(
delta
,
dimension
,
position
){
var
$arrow
=
this
.
arrow
()
if
(
delta
!==
0
){
$arrow
.
css
(
position
,
50
*
(
1
-
delta
/
dimension
)
+
"
%
"
)
}
else
{
$arrow
.
css
(
position
,
""
)
}
}
}
}
...
@@ -233,6 +286,10 @@
...
@@ -233,6 +286,10 @@
return
this
.
$tip
=
this
.
$tip
||
$
(
this
.
options
.
template
)
return
this
.
$tip
=
this
.
$tip
||
$
(
this
.
options
.
template
)
}
}
,
arrow
:
function
(){
return
this
.
$arrow
=
this
.
$arrow
||
this
.
tip
().
find
(
"
.tooltip-arrow
"
)
}
,
validate
:
function
()
{
,
validate
:
function
()
{
if
(
!
this
.
$element
[
0
].
parentNode
)
{
if
(
!
this
.
$element
[
0
].
parentNode
)
{
this
.
hide
()
this
.
hide
()
...
...
js/tests/index.html
View file @
5e4db94c
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
<script
src=
"../../js/bootstrap-typeahead.js"
></script>
<script
src=
"../../js/bootstrap-typeahead.js"
></script>
<script
src=
"../../js/bootstrap-affix.js"
></script>
<script
src=
"../../js/bootstrap-affix.js"
></script>
<!-- Needed for testing -->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"unit/bootstrap-tooltip.css"
/>
<!-- unit tests -->
<!-- unit tests -->
<script
src=
"unit/bootstrap-transition.js"
></script>
<script
src=
"unit/bootstrap-transition.js"
></script>
<script
src=
"unit/bootstrap-alert.js"
></script>
<script
src=
"unit/bootstrap-alert.js"
></script>
...
...
js/tests/unit/bootstrap-tooltip.css
0 → 100644
View file @
5e4db94c
.tooltip
{
position
:
absolute
;
}
.tooltip-inner
{
max-width
:
200px
;
}
.tooltip.top
.tooltip-arrow
{
position
:
absolute
;
}
\ No newline at end of file
js/tests/unit/bootstrap-tooltip.js
View file @
5e4db94c
...
@@ -251,4 +251,65 @@ $(function () {
...
@@ -251,4 +251,65 @@ $(function () {
ok
(
!
$
(
"
#qunit-fixture > .tooltip
"
).
length
,
'
not found in parent
'
)
ok
(
!
$
(
"
#qunit-fixture > .tooltip
"
).
length
,
'
not found in parent
'
)
tooltip
.
tooltip
(
'
hide
'
)
tooltip
.
tooltip
(
'
hide
'
)
})
})
test
(
"
should place tooltip inside window
"
,
function
(){
var
container
=
$
(
"
<div />
"
).
appendTo
(
"
body
"
)
.
css
({
position
:
"
absolute
"
,
width
:
200
,
height
:
200
,
bottom
:
0
,
left
:
0
})
,
tooltip
=
$
(
"
<a href='#' title='Very very very very very very very very long tooltip'>Hover me</a>
"
)
.
css
({
position
:
"
absolute
"
,
top
:
0
,
left
:
0
})
.
appendTo
(
container
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
stop
()
setTimeout
(
function
(){
ok
(
$
(
"
.tooltip
"
).
offset
().
left
>=
0
)
start
()
container
.
remove
()
},
100
)
})
test
(
"
should place tooltip on top of element
"
,
function
(){
var
container
=
$
(
"
<div />
"
).
appendTo
(
"
body
"
)
.
css
({
position
:
"
absolute
"
,
bottom
:
0
,
left
:
0
,
textAlign
:
"
right
"
,
width
:
300
,
height
:
300
})
,
p
=
$
(
"
<p style='margin-top:200px' />
"
).
appendTo
(
container
)
,
tooltiped
=
$
(
"
<a href='#' title='very very very very very very very long tooltip'>Hover me</a>
"
)
.
css
({
marginTop
:
200
})
.
appendTo
(
p
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
stop
()
setTimeout
(
function
(){
var
tooltip
=
container
.
find
(
"
.tooltip
"
)
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
"
)
.
css
({
position
:
"
absolute
"
,
bottom
:
0
,
left
:
0
,
textAlign
:
"
right
"
,
width
:
300
,
height
:
300
})
,
p
=
$
(
"
<p style='margin-top:200px' />
"
).
appendTo
(
container
)
,
tooltiped
=
$
(
"
<a href='#' title='very very very very very very very long tooltip'>Hover me</a>
"
)
.
css
({
marginTop
:
200
})
.
appendTo
(
p
)
.
tooltip
({
placement
:
"
top
"
,
animate
:
false
})
.
tooltip
(
"
show
"
)
stop
()
setTimeout
(
function
(){
var
arrow
=
container
.
find
(
"
.tooltip-arrow
"
)
start
()
ok
(
Math
.
abs
(
arrow
.
offset
().
left
-
tooltiped
.
offset
().
left
-
tooltiped
.
outerWidth
()
/
2
)
<=
1
)
container
.
remove
()
},
100
)
})
})
})
less/tooltip.less
View file @
5e4db94c
...
@@ -9,15 +9,14 @@
...
@@ -9,15 +9,14 @@
z-index: @zindexTooltip;
z-index: @zindexTooltip;
display: block;
display: block;
visibility: visible;
visibility: visible;
padding: 5px;
font-size: 11px;
font-size: 11px;
line-height: 1.4;
line-height: 1.4;
.opacity(0);
.opacity(0);
&.in { .opacity(80); }
&.in { .opacity(80); }
&.top { margin-top: -3px; }
&.top { margin-top: -3px;
padding: 5px 0;
}
&.right { margin-left: 3px; }
&.right { margin-left: 3px;
padding: 0 5px;
}
&.bottom { margin-top: 3px; }
&.bottom { margin-top: 3px;
padding: 5px 0;
}
&.left { margin-left: -3px; }
&.left { margin-left: -3px;
padding: 0 5px;
}
}
}
// Wrapper for the tooltip content
// Wrapper for the tooltip content
...
...
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