diff options
author | Peter West <pete@whiteoctober.co.uk> | 2014-06-03 19:02:06 +0400 |
---|---|---|
committer | Heinrich Fenkart <hnrch02@gmail.com> | 2014-09-13 06:25:34 +0400 |
commit | 4c9850701069954375b19e19bd1513654130eacf (patch) | |
tree | 7b71019c94ba99c73bbe7ac24962a80e1d30e247 /js/tests/unit/tooltip.js | |
parent | 0a4c39dc40e16a3aa18721bf78935e77ac11f097 (diff) |
Correctly selects arrow placement for a tooltip
Fixes #13696.
Fixes #13696.
Fixes #14197.
Closes #13718.
Diffstat (limited to 'js/tests/unit/tooltip.js')
-rw-r--r-- | js/tests/unit/tooltip.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index c0c6284852..b578704af4 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -836,4 +836,35 @@ $(function () { equal(currentUid, $('#tt-content').text()) }) + test('should position arrow correctly when tooltip is moved to not appear offscreen', function () { + stop() + + var styles = '<style>' + + '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }' + + '.tooltip { position: absolute; }' + + '.tooltip-arrow { position: absolute; width: 0; height: 0; }' + + '.tooltip .tooltip-inner { max-width: 200px; padding: 3px 8px; }' + + '</style>' + var $styles = $(styles).appendTo('head') + + $('<a href="#" title="tooltip title" style="position: absolute; bottom: 0; right: 0;">Foobar</a>') + .appendTo('body') + .on('shown.bs.tooltip', function () { + var arrowStyles = $(this).data('bs.tooltip').$tip.find('.tooltip-arrow').attr('style') + ok(/left/i.test(arrowStyles) && !/top/i.test(arrowStyles), 'arrow positioned correctly') + $(this).bootstrapTooltip('hide') + }) + .on('hidden.bs.tooltip', function () { + $styles.remove() + $(this).remove() + start() + }) + .bootstrapTooltip({ + container: 'body', + placement: 'top', + trigger: 'manual' + }) + .bootstrapTooltip('show') + }) + }) |