2014-01-24 13:24:23 +04:00
|
|
|
$(function () {
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
module('tooltip')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should provide no conflict', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $.fn.tooltip.noConflict()
|
|
|
|
ok(!$.fn.tooltip, 'tooltip was set back to undefined (org value)')
|
|
|
|
$.fn.tooltip = tooltip
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should be defined on jquery object', function () {
|
|
|
|
var div = $('<div></div>')
|
2014-01-24 13:24:23 +04:00
|
|
|
ok(div.tooltip, 'popover method is defined')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should return element', function () {
|
|
|
|
var div = $('<div></div>')
|
2014-01-24 13:24:23 +04:00
|
|
|
ok(div.tooltip() == div, 'document.body returned')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should expose default settings', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should empty title attribute', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').tooltip()
|
|
|
|
ok(tooltip.attr('title') === '', 'title attribute was emptied')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should add data attribute for referencing original title', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').tooltip()
|
|
|
|
equal(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should place tooltips relative to placement option', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$.support.transition = false
|
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({placement: 'bottom'})
|
|
|
|
.tooltip('show')
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.tooltip('hide')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should allow html entities', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$.support.transition = false
|
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="<b>@fat</b>"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({html: true})
|
|
|
|
.tooltip('show')
|
|
|
|
|
|
|
|
ok($('.tooltip b').length, 'b tag was inserted')
|
|
|
|
tooltip.tooltip('hide')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').length, 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should respect custom classes', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ template: '<div class="tooltip some-class"><div class="tooltip-arrow"/><div class="tooltip-inner"/></div>'})
|
|
|
|
.tooltip('show')
|
|
|
|
|
|
|
|
ok($('.tooltip').hasClass('some-class'), 'custom class is present')
|
|
|
|
tooltip.tooltip('hide')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').length, 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should fire show event', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('show.bs.tooltip', function () {
|
|
|
|
ok(true, 'show was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should fire shown event', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('shown.bs.tooltip', function () {
|
|
|
|
ok(true, 'shown was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not fire shown event when default prevented', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('show.bs.tooltip', function (e) {
|
2014-01-24 13:24:23 +04:00
|
|
|
e.preventDefault()
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(true, 'show was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('shown.bs.tooltip', function () {
|
|
|
|
ok(false, 'shown was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should fire hide event', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('shown.bs.tooltip', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$(this).tooltip('hide')
|
|
|
|
})
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('hide.bs.tooltip', function () {
|
|
|
|
ok(true, 'hide was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should fire hidden event', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('shown.bs.tooltip', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$(this).tooltip('hide')
|
|
|
|
})
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('hidden.bs.tooltip', function () {
|
|
|
|
ok(true, 'hidden was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not fire hidden event when default prevented', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
stop()
|
|
|
|
var tooltip = $('<div title="tooltip title"></div>')
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('shown.bs.tooltip', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$(this).tooltip('hide')
|
|
|
|
})
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('hide.bs.tooltip', function (e) {
|
2014-01-24 13:24:23 +04:00
|
|
|
e.preventDefault()
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(true, 'hide was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
})
|
2014-04-17 22:36:17 +04:00
|
|
|
.on('hidden.bs.tooltip', function () {
|
|
|
|
ok(false, 'hidden was called')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not show tooltip if leave event occurs before delay expires', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: 200 })
|
|
|
|
|
|
|
|
stop()
|
|
|
|
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseout')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 200)
|
|
|
|
}, 100)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: { show: 200, hide: 0} })
|
|
|
|
|
|
|
|
stop()
|
|
|
|
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseout')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 200)
|
|
|
|
}, 100)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should wait 200 ms before hiding the tooltip', 3, function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: { show: 0, hide: 200} })
|
|
|
|
|
|
|
|
stop()
|
|
|
|
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseout')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.in'), 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 150)
|
|
|
|
}, 100)
|
|
|
|
}, 1)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not hide tooltip if leave event occurs, then tooltip is show immediately again', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: { show: 0, hide: 200} })
|
|
|
|
|
|
|
|
stop()
|
|
|
|
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseout')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.in'), 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 150)
|
|
|
|
}, 100)
|
|
|
|
}, 1)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should not show tooltip if leave event occurs before delay expires', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: 100 })
|
|
|
|
stop()
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.trigger('mouseout')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 100)
|
|
|
|
}, 50)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should show tooltip if leave event hasn\'t occured before delay expires', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ delay: 150 })
|
|
|
|
stop()
|
|
|
|
tooltip.trigger('mouseenter')
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
}, 100)
|
|
|
|
setTimeout(function () {
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), 'tooltip has faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
start()
|
|
|
|
}, 200)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should destroy tooltip', function () {
|
|
|
|
var tooltip = $('<div/>').tooltip().on('click.foo', function () {})
|
2014-01-24 13:24:23 +04:00
|
|
|
ok(tooltip.data('bs.tooltip'), 'tooltip has data')
|
|
|
|
ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
|
|
|
|
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
|
|
|
|
tooltip.tooltip('show')
|
|
|
|
tooltip.tooltip('destroy')
|
|
|
|
ok(!tooltip.hasClass('in'), 'tooltip is hidden')
|
|
|
|
ok(!$._data(tooltip[0], 'bs.tooltip'), 'tooltip does not have data')
|
|
|
|
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
|
|
|
|
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should show tooltip with delegate selector on click', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var div = $('<div><a href="#" rel="tooltip" title="Another tooltip"></a></div>')
|
|
|
|
var tooltip = div.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({ selector: 'a[rel=tooltip]',
|
|
|
|
trigger: 'click' })
|
|
|
|
div.find('a').trigger('click')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should show tooltip when toggle is called', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="tooltip on toggle"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({trigger: 'manual'})
|
|
|
|
.tooltip('toggle')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should place tooltips inside the body', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
2014-04-17 22:36:17 +04:00
|
|
|
.tooltip({container: 'body'})
|
2014-01-24 13:24:23 +04:00
|
|
|
.tooltip('show')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('body > .tooltip').length, 'inside the body')
|
|
|
|
ok(!$('#qunit-fixture > .tooltip').length, 'not found in parent')
|
2014-01-24 13:24:23 +04:00
|
|
|
tooltip.tooltip('hide')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should place tooltip inside window', function () {
|
|
|
|
var container = $('<div />').appendTo('body')
|
|
|
|
.css({position: 'absolute', width: 200, height: 200, bottom: 0, left: 0}),
|
|
|
|
tooltip = $('<a href="#" title="Very very very very very very very very long tooltip">Hover me</a>')
|
|
|
|
.css({position: 'absolute', top: 0, left: 0})
|
2014-01-24 13:24:23 +04:00
|
|
|
.appendTo(container)
|
2014-04-17 22:36:17 +04:00
|
|
|
.tooltip({placement: 'top', animate: false})
|
|
|
|
.tooltip('show')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
stop()
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
setTimeout(function () {
|
|
|
|
ok($('.tooltip').offset().left >= 0)
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
start()
|
|
|
|
container.remove()
|
|
|
|
}, 100)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('should place tooltip on top of element', function () {
|
|
|
|
var container = $('<div />').appendTo('body')
|
|
|
|
.css({position: 'absolute', bottom: 0, left: 0, textAlign: 'right', width: 300, height: 300}),
|
|
|
|
p = $('<p style="margin-top:200px" />').appendTo(container),
|
|
|
|
tooltiped = $('<a href="#" title="very very very very very very very long tooltip">Hover me</a>')
|
|
|
|
.css({marginTop: 200})
|
|
|
|
.appendTo(p)
|
|
|
|
.tooltip({placement: 'top', animate: false})
|
|
|
|
.tooltip('show')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
stop()
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
setTimeout(function () {
|
|
|
|
var tooltip = container.find('.tooltip')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
start()
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(Math.round(tooltip.offset().top + tooltip.outerHeight()) <= Math.round(tooltiped.offset().top))
|
2014-01-24 13:24:23 +04:00
|
|
|
container.remove()
|
|
|
|
}, 100)
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
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>')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
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>')
|
2014-01-24 13:24:23 +04:00
|
|
|
.appendTo(container)
|
|
|
|
.tooltip({placement: 'right'})
|
2014-04-17 22:36:17 +04:00
|
|
|
.tooltip('show'),
|
|
|
|
tooltip = container.find('.tooltip')
|
|
|
|
|
|
|
|
// this is some dumb hack shit because sub pixels in firefox
|
|
|
|
var top = Math.round(target.offset().top + (target[0].offsetHeight / 2) - (tooltip[0].offsetHeight / 2))
|
|
|
|
var top2 = Math.round(tooltip.offset().top)
|
|
|
|
var topDiff = top - top2
|
|
|
|
ok(topDiff <= 1 && topDiff >= -1)
|
2014-01-24 13:24:23 +04:00
|
|
|
target.tooltip('hide')
|
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('tooltip title test #1', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set')
|
|
|
|
tooltip.tooltip('hide')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').length, 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('tooltip title test #2', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({
|
|
|
|
title: 'This is a tooltip with some content'
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while prefered over title option')
|
|
|
|
tooltip.tooltip('hide')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').length, 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('tooltip title test #3', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
var tooltip = $('<a href="#" rel="tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>')
|
|
|
|
.appendTo('#qunit-fixture')
|
|
|
|
.tooltip({
|
|
|
|
title: 'This is a tooltip with some content'
|
|
|
|
})
|
|
|
|
.tooltip('show')
|
|
|
|
equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set')
|
|
|
|
tooltip.tooltip('hide')
|
2014-04-17 22:36:17 +04:00
|
|
|
ok(!$('.tooltip').length, 'tooltip removed')
|
2014-01-24 13:24:23 +04:00
|
|
|
})
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
test('tooltips should be placed dynamically, with the dynamic placement option', function () {
|
2014-01-24 13:24:23 +04:00
|
|
|
$.support.transition = false
|
|
|
|
var ttContainer = $('<div id="dynamic-tt-test"/>').css({
|
2014-04-17 22:36:17 +04:00
|
|
|
'height' : 400,
|
|
|
|
'overflow' : 'hidden',
|
|
|
|
'position' : 'absolute',
|
|
|
|
'top' : 0,
|
|
|
|
'left' : 0,
|
|
|
|
'width' : 600})
|
|
|
|
.appendTo('body')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
var topTooltip = $('<div style="display: inline-block; position: absolute; left: 0; top: 0;" rel="tooltip" title="Top tooltip">Top Dynamic Tooltip</div>')
|
|
|
|
.appendTo('#dynamic-tt-test')
|
|
|
|
.tooltip({placement: 'auto'})
|
|
|
|
.tooltip('show')
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned bottom')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
|
|
|
topTooltip.tooltip('hide')
|
|
|
|
|
|
|
|
var rightTooltip = $('<div style="display: inline-block; position: absolute; right: 0;" rel="tooltip" title="Right tooltip">Right Dynamic Tooltip</div>')
|
|
|
|
.appendTo('#dynamic-tt-test')
|
|
|
|
.tooltip({placement: 'right auto'})
|
|
|
|
.tooltip('show')
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
|
2014-01-24 13:24:23 +04:00
|
|
|
rightTooltip.tooltip('hide')
|
|
|
|
|
|
|
|
var leftTooltip = $('<div style="display: inline-block; position: absolute; left: 0;" rel="tooltip" title="Left tooltip">Left Dynamic Tooltip</div>')
|
|
|
|
.appendTo('#dynamic-tt-test')
|
|
|
|
.tooltip({placement: 'auto left'})
|
|
|
|
.tooltip('show')
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
|
2014-01-24 13:24:23 +04:00
|
|
|
leftTooltip.tooltip('hide')
|
|
|
|
|
|
|
|
ttContainer.remove()
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|