]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix hidden.bs.tooltip and shown.bs.tooltip events firing too early in tooltip.js 10199/head
authorLukasz Fiszer <lukasz.fiszer@gmail.com>
Mon, 26 Aug 2013 18:57:47 +0000 (20:57 +0200)
committerLukasz Fiszer <lukasz.fiszer@gmail.com>
Mon, 26 Aug 2013 18:57:47 +0000 (20:57 +0200)
* 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

index 89802287a32cece7dcfd0d2543f652d3b7918d55..533f19b3157ceeabc34a8bebfbc61bf4ebf3db90 100644 (file)
       this.$element.trigger(e)
 
       if (e.isDefaultPrevented()) return
+      var that = this;
 
       var $tip = this.tip()
 
       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()
+
     }
   }
 
 
     function complete() {
       if (that.hoverState != 'in') $tip.detach()
+      that.$element.trigger('hidden.bs.' + that.type)
     }
 
     this.$element.trigger(e)
         .emulateTransitionEnd(150) :
       complete()
 
-    this.$element.trigger('hidden.bs.' + this.type)
-
     return this
   }