diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/alert.js | 4 | ||||
| -rw-r--r-- | js/carousel.js | 14 | ||||
| -rw-r--r-- | js/collapse.js | 6 | ||||
| -rw-r--r-- | js/dropdown.js | 3 | ||||
| -rw-r--r-- | js/modal.js | 31 | ||||
| -rw-r--r-- | js/tab.js | 4 | ||||
| -rw-r--r-- | js/tooltip.js | 15 | ||||
| -rw-r--r-- | js/transition.js | 8 |
8 files changed, 44 insertions, 41 deletions
diff --git a/js/alert.js b/js/alert.js index d9f64767c..6f3d072e9 100644 --- a/js/alert.js +++ b/js/alert.js @@ -56,7 +56,9 @@ } $.support.transition && $parent.hasClass('fade') ? - $parent.on($.support.transition.end, removeElement) : + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : removeElement() } diff --git a/js/carousel.js b/js/carousel.js index 78e878546..4def0cec2 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -130,12 +130,14 @@ $next[0].offsetWidth // force reflow $active.addClass(direction) $next.addClass(direction) - this.$element.find('.item').one($.support.transition.end, function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) - }) + this.$element.find('.item') + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) } else { this.$element.trigger(e) if (e.isDefaultPrevented()) return diff --git a/js/collapse.js b/js/collapse.js index f3486e9df..7bc65b3e2 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -50,7 +50,7 @@ var dimension = this.dimension() var scroll = $.camelCase(['scroll', dimension].join('-')) - var actives = this.$parent && this.$parent.find('.collapse.in') + var actives = this.$parent && this.$parent.find('> .accordion-group > .in') if (actives && actives.length) { var hasData = actives.data('bs.collapse') @@ -104,7 +104,9 @@ this.$element[method]('in') $.support.transition && this.$element.hasClass('collapse') ? - this.$element.one($.support.transition.end, complete) : + this.$element + .one($.support.transition.end, complete) + .emulateTransitionEnd(350) : complete() } diff --git a/js/dropdown.js b/js/dropdown.js index 2bb789a79..8aee574fa 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -92,7 +92,7 @@ function clearMenus() { $(backdrop).remove() - $(toggle).each(function (e) { + $(toggle).each(function (e) { var $parent = getParent($(this)) if (!$parent.hasClass('open')) return $parent.trigger(e = $.Event('hide.bs.dropdown')) @@ -145,7 +145,6 @@ // APPLY TO STANDARD DROPDOWN ELEMENTS // =================================== - $(document) .on('click.bs.dropdown.data-api', clearMenus) .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) diff --git a/js/modal.js b/js/modal.js index 50ebd7b56..5a234146e 100644 --- a/js/modal.js +++ b/js/modal.js @@ -74,7 +74,11 @@ that.enforceFocus() transition ? - that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown.bs.modal') }) : + that.$element + .one($.support.transition.end, function () { + that.$element.focus().trigger('shown.bs.modal') + }) + .emulateTransitionEnd(300) : that.$element.focus().trigger('shown.bs.modal') }) } @@ -99,7 +103,9 @@ .attr('aria-hidden', true) $.support.transition && this.$element.hasClass('fade') ? - this.hideWithTransition() : + this.$element + .one($.support.transition.end, $.proxy(this.hideModal, this)) + .emulateTransitionEnd(300) : this.hideModal() } @@ -123,19 +129,6 @@ } } - Modal.prototype.hideWithTransition = function () { - var that = this - var timeout = setTimeout(function () { - that.$element.off($.support.transition.end) - that.hideModal() - }, 500) - - this.$element.one($.support.transition.end, function () { - clearTimeout(timeout) - that.hideModal() - }) - } - Modal.prototype.hideModal = function () { var that = this this.$element.hide() @@ -174,14 +167,18 @@ if (!callback) return doAnimate ? - this.$backdrop.one($.support.transition.end, callback) : + this.$backdrop + .one($.support.transition.end, callback) + .emulateTransitionEnd(150) : callback() } else if (!this.isShown && this.$backdrop) { this.$backdrop.removeClass('in') $.support.transition && this.$element.hasClass('fade')? - this.$backdrop.one($.support.transition.end, callback) : + this.$backdrop + .one($.support.transition.end, callback) + .emulateTransitionEnd(150) : callback() } else if (callback) { @@ -88,7 +88,9 @@ } transition ? - $active.one($.support.transition.end, next) : + $active + .one($.support.transition.end, next) + .emulateTransitionEnd(150) : next() $active.removeClass('in') diff --git a/js/tooltip.js b/js/tooltip.js index 1f84b5cf5..f8ba0aacb 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -238,19 +238,10 @@ $tip.removeClass('in') - function removeWithAnimation() { - var timeout = setTimeout(function () { - $tip.off($.support.transition.end).detach() - }, 500) - - $tip.one($.support.transition.end, function () { - clearTimeout(timeout) - $tip.detach() - }) - } - $.support.transition && this.$tip.hasClass('fade') ? - removeWithAnimation() : + $tip + .one($.support.transition.end, $tip.detach) + .emulateTransitionEnd(150) : $tip.detach() this.$element.trigger('hidden.bs.' + this.type) diff --git a/js/transition.js b/js/transition.js index 2ad53234a..c38460c15 100644 --- a/js/transition.js +++ b/js/transition.js @@ -40,6 +40,14 @@ } } + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one('webkitTransitionEnd', function () { called = true }) + var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') } + setTimeout(callback, duration) + } + $(function () { $.support.transition = transitionEnd() }) |
