From 0adb4e35f0d773caa6cff65a6f760001089c5ffb Mon Sep 17 00:00:00 2001 From: Lukasz Fiszer Date: Mon, 26 Aug 2013 20:57:47 +0200 Subject: [PATCH 01/67] Fix hidden.bs.tooltip and shown.bs.tooltip events firing too early in tooltip.js * events fire only after the CSS animation is completed * this fixes also events in popover.js (as it inherits from tooltip.js) --- js/tooltip.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js/tooltip.js b/js/tooltip.js index 89802287a3..533f19b315 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -139,6 +139,7 @@ this.$element.trigger(e) if (e.isDefaultPrevented()) return + var that = this; var $tip = this.tip() @@ -188,7 +189,17 @@ var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) this.applyPlacement(calculatedOffset, placement) - this.$element.trigger('shown.bs.' + this.type) + + var complete = function() { + that.$element.trigger('shown.bs.' + that.type) + } + + $.support.transition && this.$tip.hasClass('fade') ? + $tip + .one($.support.transition.end, complete) + .emulateTransitionEnd(150) : + complete() + } } @@ -262,6 +273,7 @@ function complete() { if (that.hoverState != 'in') $tip.detach() + that.$element.trigger('hidden.bs.' + that.type) } this.$element.trigger(e) @@ -276,8 +288,6 @@ .emulateTransitionEnd(150) : complete() - this.$element.trigger('hidden.bs.' + this.type) - return this } From ed1bd2b150dd645c11f92126a12183985ddbbc15 Mon Sep 17 00:00:00 2001 From: Roland Warmerdam Date: Sat, 31 Aug 2013 18:03:09 +1200 Subject: [PATCH 02/67] carousel: correctly reset when the slide event is prevented --- js/carousel.js | 14 ++++++-------- js/tests/unit/carousel.js | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/js/carousel.js b/js/carousel.js index d8c4c243ca..08d53b893d 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -111,14 +111,16 @@ $next = this.$element.find('.item')[fallback]() } + if ($next.hasClass('active')) return + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + this.sliding = true isCycling && this.pause() - var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) - - if ($next.hasClass('active')) return - if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') this.$element.one('slid', function () { @@ -128,8 +130,6 @@ } if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $next.addClass(type) $next[0].offsetWidth // force reflow $active.addClass(direction) @@ -143,8 +143,6 @@ }) .emulateTransitionEnd(600) } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return $active.removeClass('active') $next.addClass('active') this.sliding = false diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index badf0886d3..e1e34afaf6 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -16,7 +16,7 @@ $(function () { ok($(document.body).carousel()[0] == document.body, 'document.body returned') }) - test("should not fire sliden when slide is prevented", function () { + test("should not fire slid when slide is prevented", function () { $.support.transition = false stop() $('