From f07bcafd397dd39c5490e192ab7b52c49acd3d9b Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Fri, 6 Jan 2012 11:16:29 +0100 Subject: [PATCH 1/2] Make twipsy respect custom classes when using a custom template If you had a custom class to the root object twipsy would overwrite that class ($tip[0].className = 'twipsy'), now this has been changed so it removes only classes that twipsy adds. --- js/bootstrap-twipsy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-twipsy.js index a176f09088..1ce4ad85b6 100644 --- a/js/bootstrap-twipsy.js +++ b/js/bootstrap-twipsy.js @@ -155,7 +155,7 @@ , setContent: function () { var $tip = this.tip() $tip.find('.twipsy-inner').html(this.getTitle()) - $tip[0].className = 'twipsy' + $tip.removeClass('fade in top bottom left right') } , hide: function () { From 969fbe71504f6a8159688634cce774d7ffc7ac67 Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Giertz Date: Fri, 6 Jan 2012 11:32:11 +0100 Subject: [PATCH 2/2] Add a test case for issue #908 (twipsy doesn't respect custom classes) The test case verifies that a custom class is respected. --- js/tests/unit/bootstrap-twipsy.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/tests/unit/bootstrap-twipsy.js b/js/tests/unit/bootstrap-twipsy.js index 6623fc026e..08512ca979 100644 --- a/js/tests/unit/bootstrap-twipsy.js +++ b/js/tests/unit/bootstrap-twipsy.js @@ -48,4 +48,15 @@ $(function () { ok(!$(".twipsy").length, 'twipsy removed') }) + test("should respect custom classes", function () { + var twipsy = $('') + .appendTo('#qunit-fixture') + .twipsy({ template: '
'}) + .twipsy('show') + + ok($('.twipsy').hasClass('some-class'), 'custom class is present') + twipsy.twipsy('hide') + ok(!$(".twipsy").length, 'twipsy removed') + }) + }) \ No newline at end of file