diff options
| author | Jacob Thornton <[email protected]> | 2013-07-24 20:10:16 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2013-07-24 20:10:16 -0700 |
| commit | eaefed517a960893204cade3525bda100454e13f (patch) | |
| tree | 6227f06e1e88cd0321975a43a9b9cc9dbd9e5138 /js | |
| parent | 930c75e5dd0f2ae861a505bda740f289570c9b8a (diff) | |
| download | bootstrap-eaefed517a960893204cade3525bda100454e13f.tar.xz bootstrap-eaefed517a960893204cade3525bda100454e13f.zip | |
fixes #8399 w/ tests
Diffstat (limited to 'js')
| -rw-r--r-- | js/carousel.js | 2 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 45 | ||||
| -rw-r--r-- | js/tooltip.js | 4 |
3 files changed, 48 insertions, 3 deletions
diff --git a/js/carousel.js b/js/carousel.js index 2e5d97853..e5a83f094 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -130,7 +130,7 @@ $next[0].offsetWidth // force reflow $active.addClass(direction) $next.addClass(direction) - this.$element.find('.item') + $active .one($.support.transition.end, function () { $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index ecb41c453..ed1bf54b3 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -181,6 +181,51 @@ $(function () { }, 100) }) + test("should wait 200 ms before hiding the tooltip", 3, function () { + 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 () { + ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + tooltip.trigger('mouseout') + setTimeout(function () { + ok($(".tooltip").is('.fade.in'), '100ms:tooltip is still faded in') + setTimeout(function () { + ok(!$(".tooltip").is('.in'), 'tooltip removed') + start() + }, 150) + }, 100) + }, 1) + }) + + test("should not hide tooltip if leave event occurs, then tooltip is show immediately again", function () { + 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 () { + ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + tooltip.trigger('mouseout') + setTimeout(function () { + ok($(".tooltip").is('.fade.in'), '100ms:tooltip is still faded in') + tooltip.trigger('mouseenter') + setTimeout(function () { + ok($(".tooltip").is('.in'), 'tooltip removed') + start() + }, 150) + }, 100) + }, 1) + }) + test("should not show tooltip if leave event occurs before delay expires", function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') diff --git a/js/tooltip.js b/js/tooltip.js index 7e3fa8098..897a44517 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -102,10 +102,10 @@ var self = obj instanceof this.constructor ? obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type) - if (!self.options.delay || !self.options.delay.show) return self.show() - clearTimeout(self.timeout) + if (!self.options.delay || !self.options.delay.show) return self.show() + self.hoverState = 'in' self.timeout = setTimeout(function () { if (self.hoverState == 'in') self.show() |
