aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJacob <[email protected]>2014-10-09 20:56:21 -0700
committerJacob <[email protected]>2014-10-09 20:56:21 -0700
commit42311c86c1bc25f4c0e32a5855e48754b20f3b63 (patch)
tree1e3a765d97e3bd5e5c83ac7c7e8d3c2f42c4c336 /js
parent9299f5dfa25d6fbf0933f7de7db58b50c868ab47 (diff)
parent4bbe80658a9d32df131e5fb13bc20688b99a70d5 (diff)
downloadbootstrap-42311c86c1bc25f4c0e32a5855e48754b20f3b63.tar.xz
bootstrap-42311c86c1bc25f4c0e32a5855e48754b20f3b63.zip
Merge pull request #14724 from twbs/fat-13816
fixes #13816 Modal dialog closes when dragging and releasing mouse button outside dialog
Diffstat (limited to 'js')
-rw-r--r--js/modal.js15
-rw-r--r--js/tests/unit/modal.js4
2 files changed, 9 insertions, 10 deletions
diff --git a/js/modal.js b/js/modal.js
index cef013a56..6e2ac7e74 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -166,14 +166,13 @@
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
- .appendTo(this.$body)
-
- this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
- if (e.target !== e.currentTarget) return
- this.options.backdrop == 'static'
- ? this.$element[0].focus.call(this.$element[0])
- : this.hide.call(this)
- }, this))
+ .prependTo(this.$element)
+ .on('click.dismiss.bs.modal', $.proxy(function (e) {
+ if (e.target !== e.currentTarget) return
+ this.options.backdrop == 'static'
+ ? this.$element[0].focus.call(this.$element[0])
+ : this.hide.call(this)
+ }, this))
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 2262465a4..efd478b20 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -141,7 +141,7 @@ $(function () {
notEqual($('#modal-test').length, 0, 'modal insterted into dom')
$('.contents').click()
ok($('#modal-test').is(':visible'), 'modal visible')
- $('#modal-test').click()
+ $('#modal-test .modal-backdrop').click()
})
.on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
@@ -196,7 +196,7 @@ $(function () {
$('<div id="modal-test"><div class="contents"/></div>')
.on('shown.bs.modal', function () {
triggered = 0
- $('#modal-test').click()
+ $('#modal-test .modal-backdrop').click()
})
.on('hide.bs.modal', function () {
triggered += 1