From ac8001190a4dda635a5df72f88e638759511bfd8 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sun, 18 Sep 2011 21:03:52 -0700 Subject: [PATCH] force reflow instead of relying on eventloop (firefox) listen to window for escape press --- docs/javascript.html | 2 +- js/bootstrap-modal.js | 33 ++-- js/tests/unit/bootstrap-modal.js | 274 +++++++++++++++---------------- 3 files changed, 158 insertions(+), 151 deletions(-) diff --git a/docs/javascript.html b/docs/javascript.html index 61b0c8dc02..9f153c0bf6 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -12,7 +12,7 @@ - + diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 8b0ac2d02f..4201d843c2 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -85,11 +85,13 @@ .appendTo(document.body) .show() - setTimeout(function () { - that.$element - .addClass('in') - .trigger('shown') - }, 0) + if ($.support.transition && that.$element.hasClass('fade')) { + that.$backdrop[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .trigger('shown') }) return this @@ -132,6 +134,8 @@ var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' if ( this.isShown && this.settings.backdrop ) { + var doAnimate = $.support.transition && animate + this.$backdrop = $('