From: saranya.r Date: Fri, 10 Oct 2014 06:19:45 +0000 (+0530) Subject: Fixes tooltip misplacements in scrollable viewports with auto positioning X-Git-Tag: v3.3.0~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2cfbd5f2df12cb207a66663925f5ee7e5cb2320;p=thirdparty%2Fbootstrap.git Fixes tooltip misplacements in scrollable viewports with auto positioning Fixes #14756. Closes #14767. --- diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 3eb3c7b85c..7b5f8adf72 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -432,6 +432,110 @@ $(function () { $styles.remove() }) + test('should display the tip on top whenever scrollable viewport has enough room if the given placement is "auto top"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
Tooltip Item
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'top auto', + viewport: '#scrollable-div' + }) + + $('#scrollable-div').scrollTop(100) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied') + + $target.bootstrapTooltip('hide') + equal($('.tooltip').length, 0, 'tooltip removed from dom') + + $styles.remove() + }) + + test('should display the tip on bottom whenever scrollable viewport doesn\'t have enough room if the given placement is "auto top"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
Tooltip Item
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'top auto', + viewport: '#scrollable-div' + }) + + $('#scrollable-div').scrollTop(200) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied') + + $target.bootstrapTooltip('hide') + equal($('.tooltip').length, 0, 'tooltip removed from dom') + + $styles.remove() + }) + + test('should display the tip on bottom whenever scrollable viewport has enough room if the given placement is "auto bottom"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
Tooltip Item
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'bottom auto', + viewport: '#scrollable-div' + }) + + $('#scrollable-div').scrollTop(200) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied') + + $target.bootstrapTooltip('hide') + equal($('.tooltip').length, 0, 'tooltip removed from dom') + + $styles.remove() + }) + + test('should display the tip on top whenever scrollable viewport doesn\'t have enough room if the given placement is "auto bottom"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
Tooltip Item
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'bottom auto', + viewport: '#scrollable-div' + }) + + $('#scrollable-div').scrollTop(400) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.fade.top.in'), 'has correct classes applied') + + $target.bootstrapTooltip('hide') + equal($('.tooltip').length, 0, 'tooltip removed from dom') + + $styles.remove() + }) + test('should adjust the tip\'s top position when up against the top of the viewport', function () { var styles = '