From 9c76070cbddfd02c034cba9e15960906844b76d0 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 10 Sep 2011 18:13:37 -0700 Subject: rework the transitions for the modal a bit --- js/bootstrap-modal.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'js/bootstrap-modal.js') diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index de972a8aa1..81f265710d 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -59,16 +59,17 @@ this.isShown = true _.escape.call(this) - _.backdrop.call(this) + _.backdrop.call(this, function () { - this.$element - .appendTo(document.body) - .show() + that.$element + .appendTo(document.body) + .show() - setTimeout(function () { - that.$element.addClass('in').trigger('modal:shown') - that.$backdrop && that.$backdrop.addClass('in') - }, 1) + setTimeout(function () { + that.$element.addClass('in').trigger('modal:shown') + }, 1) + + }) return this } @@ -81,19 +82,19 @@ this.isShown = false _.escape.call(this) - _.backdrop.call(this) this.$element.removeClass('in') function removeElement () { + _.backdrop.call(that) + that.$element - .unbind(transitionEnd) .detach() .trigger('modal:hidden') } $.support.transition && this.$element.hasClass('fade') ? - this.$element.bind(transitionEnd, removeElement) : + this.$element.one(transitionEnd, removeElement) : removeElement() return this @@ -107,13 +108,21 @@ var _ = { - backdrop: function () { + backdrop: function ( callback ) { var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' if ( this.isShown && this.settings.backdrop ) { this.$backdrop = $('