mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 21:09:06 +02:00
force reflow instead of relying on eventloop (firefox)
listen to window for escape press
This commit is contained in:
33
js/bootstrap-modal.js
vendored
33
js/bootstrap-modal.js
vendored
@@ -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 = $('<div class="modal-backdrop ' + animate + '" />')
|
||||
.appendTo(document.body)
|
||||
|
||||
@@ -139,12 +143,15 @@
|
||||
this.$backdrop.click($.proxy(this.hide, this))
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
that.$backdrop && that.$backdrop.addClass('in')
|
||||
$.support.transition && that.$backdrop.hasClass('fade') ?
|
||||
that.$backdrop.one(transitionEnd, callback) :
|
||||
callback()
|
||||
}, 0)
|
||||
if ( doAnimate ) {
|
||||
that.$backdrop[0].offsetWidth // force reflow
|
||||
}
|
||||
|
||||
that.$backdrop && that.$backdrop.addClass('in')
|
||||
|
||||
doAnimate ?
|
||||
that.$backdrop.one(transitionEnd, callback) :
|
||||
callback()
|
||||
|
||||
} else if ( !this.isShown && this.$backdrop ) {
|
||||
this.$backdrop.removeClass('in')
|
||||
@@ -165,13 +172,13 @@
|
||||
function escape() {
|
||||
var that = this
|
||||
if ( this.isShown && this.settings.keyboard ) {
|
||||
$('body').bind('keyup.modal', function ( e ) {
|
||||
$(window).bind('keyup.modal', function ( e ) {
|
||||
if ( e.which == 27 ) {
|
||||
that.hide()
|
||||
}
|
||||
})
|
||||
} else if ( !this.isShown ) {
|
||||
$('body').unbind('keyup.modal')
|
||||
$(window).unbind('keyup.modal')
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user