From: saranya.r Date: Tue, 9 Sep 2014 13:17:06 +0000 (+0530) Subject: Fix tooltip misplacement with "auto top" X-Git-Tag: v3.3.0~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db9e8ee813d13546acc9663970c810c230ed026c;p=thirdparty%2Fbootstrap.git Fix tooltip misplacement with "auto top" Fixes #14322. Closes #14581. --- diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index c75924e9ff..cd239f0c6c 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -382,6 +382,56 @@ $(function () { $style.remove() }) + test('should position tip on top if viewport has enough space and placement is "auto top"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'auto top', + viewport: 'section' + }) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.top'), 'top positioned tooltip is dynamically positioned to top') + + $target.bootstrapTooltip('hide') + equal($('.tooltip').length, 0, 'tooltip removed from dom') + + $styles.remove() + }) + + test('should position tip on bottom if the tip\'s dimension exceeds the viewport area and placement is "auto top"', function () { + var styles = '' + var $styles = $(styles).appendTo('head') + + var $container = $('
').appendTo('#qunit-fixture') + var $target = $('
') + .appendTo($container) + .bootstrapTooltip({ + placement: 'auto top', + viewport: 'section' + }) + + $target.bootstrapTooltip('show') + ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned to bottom') + + $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 = '