1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 16:14:04 +02:00

Merge branch 'bo-tooltip-viewport' of https://github.com/benogle/bootstrap into benogle-bo-tooltip-viewport

Conflicts:
	docs/javascript.html
This commit is contained in:
Mark Otto
2014-01-16 20:01:28 -08:00
4 changed files with 203 additions and 30 deletions

View File

@@ -338,10 +338,10 @@ $(function () {
})
test('should add position class before positioning so that position-specific styles are taken into account', function () {
$('head').append('<style> .tooltip.right { white-space: nowrap; } .tooltip.right .tooltip-inner { max-width: none; } </style>')
$('head').append('<style id="test"> .tooltip.right { white-space: nowrap; } .tooltip.right .tooltip-inner { max-width: none; } </style>')
var container = $('<div />').appendTo('body'),
target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line"></a>')
target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line" style="position: fixed; top: 10px; left: 0px;"></a>')
.appendTo(container)
.tooltip({placement: 'right'})
.tooltip('show'),
@@ -353,6 +353,67 @@ $(function () {
var topDiff = top - top2
ok(topDiff <= 1 && topDiff >= -1)
target.tooltip('hide')
$('head #test').remove()
})
test('should adjust the tip\'s top when up against the top of the viewport', function () {
$('head').append('<style id="test"> .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; } </style>')
var container = $('<div />').appendTo('body'),
target = $('<a href="#" rel="tooltip" title="tip" style="position: fixed; top: 0px; left: 0px;"></a>')
.appendTo(container)
.tooltip({placement: 'right', viewportPadding: 12})
.tooltip('show'),
tooltip = container.find('.tooltip')
ok( Math.round(tooltip.offset().top) === 12 )
target.tooltip('hide')
$('head #test').remove()
})
test('should adjust the tip\'s top when up against the bottom of the viewport', function () {
$('head').append('<style id="test"> .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; } </style>')
var container = $('<div />').appendTo('body'),
target = $('<a href="#" rel="tooltip" title="tip" style="position: fixed; bottom: 0px; left: 0px;"></a>')
.appendTo(container)
.tooltip({placement: 'right', viewportPadding: 12})
.tooltip('show'),
tooltip = container.find('.tooltip')
ok( Math.round(tooltip.offset().top) === Math.round($(window).height() - 12 - tooltip[0].offsetHeight) )
target.tooltip('hide')
$('head #test').remove()
})
test('should adjust the tip\'s left when up against the left of the viewport', function () {
$('head').append('<style id="test"> .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; } </style>')
var container = $('<div />').appendTo('body'),
target = $('<a href="#" rel="tooltip" title="tip" style="position: fixed; top: 0px; left: 0px;"></a>')
.appendTo(container)
.tooltip({placement: 'bottom', viewportPadding: 12})
.tooltip('show'),
tooltip = container.find('.tooltip')
ok( Math.round(tooltip.offset().left) === 12 )
target.tooltip('hide')
$('head #test').remove()
})
test('should adjust the tip\'s left when up against the right of the viewport', function () {
$('head').append('<style id="test"> .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; } </style>')
var container = $('<div />').appendTo('body'),
target = $('<a href="#" rel="tooltip" title="tip" style="position: fixed; top: 0px; right: 0px;"></a>')
.appendTo(container)
.tooltip({placement: 'bottom', viewportPadding: 12})
.tooltip('show'),
tooltip = container.find('.tooltip')
ok( Math.round(tooltip.offset().left) === Math.round($(window).width() - 12 - tooltip[0].offsetWidth) )
target.tooltip('hide')
$('head #test').remove()
})
test('tooltip title test #1', function () {