Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltip self-reference to address #12320 #13593

Merged
merged 1 commit into from
May 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions js/tests/unit/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ $(function () {
ok(!!popover.data('bs.popover'), 'popover instance exists')
})

test('should store popover trigger in popover instance data object', function () {
$.support.transition = false
var popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover()
popover.bootstrapPopover('show')
ok(!!$('.popover').data('bs.popover'), 'popover trigger stored in instance data')
$('#qunit-fixture').empty()
})

test('should get title and content from options', function () {
$.support.transition = false
var popover = $('<a href="#">@fat</a>')
Expand Down
11 changes: 11 additions & 0 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,17 @@ $(function () {
ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in')
})

test('should hide shown tooltip when toggle is called on tooltip', function () {
var tooltip = $('<a href="#" rel="tooltip" title="tooltip on toggle">@ResentedHook</a>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({trigger: 'manual'})
.bootstrapTooltip('toggle')
$('.tooltip', '#qunit-fixture').bootstrapTooltip('toggle')
ok($('.tooltip').not('.fade.in'), 'tooltip should be toggled out')
tooltip.bootstrapTooltip('hide')
$('#qunit-fixture').empty()
})

test('should place tooltips inside the body', function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
Expand Down
1 change: 1 addition & 0 deletions js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement)
.data('bs.' + this.type, this)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the modal.js call to $this.data('bs.modal', ...), the tooltip has to accommodate the type - tooltip, popover, etc.


this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)

Expand Down