From 6a9f169fd6cd2203dee3f6230cc78f5dbbeafdab Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Sun, 22 Jan 2012 12:06:59 +0100 Subject: Make the popove respect custom classes --- js/bootstrap-popover.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index e90899895..a0de0f08d 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -41,7 +41,7 @@ $tip.find('.title')[ $.type(title) == 'object' ? 'append' : 'html' ](title) $tip.find('.content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content) - $tip[0].className = 'popover' + $tip.removeClass('fade top bottom left right in') } , hasContent: function () { @@ -92,4 +92,4 @@ , template: '

' }) -}( window.jQuery ) \ No newline at end of file +}( window.jQuery ) -- cgit v1.2.3 From 05fdd43e41bae02c8d4006c075b6360599b4467c Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Sun, 22 Jan 2012 12:32:37 +0100 Subject: Add testcase to popover This test case verifies that custom classes are respected. --- js/tests/unit/bootstrap-popover.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 9180c043e..462db8b3e 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -70,5 +70,24 @@ $(function () { ok(!$('.popover').length, 'popover was removed') $('#qunit-fixture').empty() }) + + test("should respect custom classes", function() { + $.support.transition = false + var popover = $('@fat') + .appendTo('#qunit-fixture') + .popover({ + title: 'Test' + , content: 'Test' + , template: '

' + }) + + popover.popover('show') + console.log(popover) + ok($('.popover').length, 'popover was inserted') + ok($('.popover').hasClass('foobar'), 'custom class is present') + popover.popover('hide') + ok(!$('.popover').length, 'popover was removed') + $('#qunit-fixture').empty() + }) }) \ No newline at end of file -- cgit v1.2.3 From 4882e6da2f887c1e8baad96f777b151882adaed8 Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Sun, 22 Jan 2012 12:33:30 +0100 Subject: Rename the tooltip test file It had not been renamed when twipsys became tooltips. --- js/tests/unit/bootstrap-tooltip.js | 62 ++++++++++++++++++++++++++++++++++++++ js/tests/unit/bootstrap-twipsy.js | 62 -------------------------------------- 2 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 js/tests/unit/bootstrap-tooltip.js delete mode 100644 js/tests/unit/bootstrap-twipsy.js diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js new file mode 100644 index 000000000..8543162c6 --- /dev/null +++ b/js/tests/unit/bootstrap-tooltip.js @@ -0,0 +1,62 @@ +$(function () { + + module("bootstrap-tooltip") + + test("should be defined on jquery object", function () { + var div = $("
") + ok(div.tooltip, 'popover method is defined') + }) + + test("should return element", function () { + var div = $("
") + ok(div.tooltip() == div, 'document.body returned') + }) + + test("should expose default settings", function () { + ok(!!$.fn.tooltip.defaults, 'defaults is defined') + }) + + test("should remove title attribute", function () { + var tooltip = $('').tooltip() + ok(!tooltip.attr('title'), 'title tag was removed') + }) + + test("should add data attribute for referencing original title", function () { + var tooltip = $('').tooltip() + equals(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute') + }) + + test("should place tooltips relative to placement option", function () { + $.support.transition = false + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip({placement: 'bottom'}) + .tooltip('show') + + ok($(".tooltip").hasClass('fade bottom in'), 'has correct classes applied') + tooltip.tooltip('hide') + }) + + test("should always allow html entities", function () { + $.support.transition = false + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip('show') + + ok($('.tooltip b').length, 'b tag was inserted') + tooltip.tooltip('hide') + ok(!$(".tooltip").length, 'tooltip removed') + }) + + test("should respect custom classes", function () { + var tooltip = $('') + .appendTo('#qunit-fixture') + .tooltip({ template: '
'}) + .tooltip('show') + + ok($('.tooltip').hasClass('some-class'), 'custom class is present') + tooltip.tooltip('hide') + ok(!$(".tooltip").length, 'tooltip removed') + }) + +}) \ No newline at end of file diff --git a/js/tests/unit/bootstrap-twipsy.js b/js/tests/unit/bootstrap-twipsy.js deleted file mode 100644 index 8543162c6..000000000 --- a/js/tests/unit/bootstrap-twipsy.js +++ /dev/null @@ -1,62 +0,0 @@ -$(function () { - - module("bootstrap-tooltip") - - test("should be defined on jquery object", function () { - var div = $("
") - ok(div.tooltip, 'popover method is defined') - }) - - test("should return element", function () { - var div = $("
") - ok(div.tooltip() == div, 'document.body returned') - }) - - test("should expose default settings", function () { - ok(!!$.fn.tooltip.defaults, 'defaults is defined') - }) - - test("should remove title attribute", function () { - var tooltip = $('').tooltip() - ok(!tooltip.attr('title'), 'title tag was removed') - }) - - test("should add data attribute for referencing original title", function () { - var tooltip = $('').tooltip() - equals(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute') - }) - - test("should place tooltips relative to placement option", function () { - $.support.transition = false - var tooltip = $('') - .appendTo('#qunit-fixture') - .tooltip({placement: 'bottom'}) - .tooltip('show') - - ok($(".tooltip").hasClass('fade bottom in'), 'has correct classes applied') - tooltip.tooltip('hide') - }) - - test("should always allow html entities", function () { - $.support.transition = false - var tooltip = $('') - .appendTo('#qunit-fixture') - .tooltip('show') - - ok($('.tooltip b').length, 'b tag was inserted') - tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') - }) - - test("should respect custom classes", function () { - var tooltip = $('') - .appendTo('#qunit-fixture') - .tooltip({ template: '
'}) - .tooltip('show') - - ok($('.tooltip').hasClass('some-class'), 'custom class is present') - tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') - }) - -}) \ No newline at end of file -- cgit v1.2.3