2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-08 17:22:31 +03:00

Adding flag to prevent backdrop click hiding modal

This commit is contained in:
Nick Veys
2011-09-17 14:47:38 -05:00
parent 732ff9ed1c
commit 2cb233319d
3 changed files with 74 additions and 3 deletions
+63 -1
View File
@@ -86,4 +86,66 @@ $(function () {
})
.modal("toggle")
})
})
test("should add backdrop when desired", function () {
stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
div
.modal({backdrop:true})
.modal("show")
.bind("shown", function () {
equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom')
start()
div.remove()
$('.modal-backdrop').remove()
})
})
test("should not add backdrop when not desired", function () {
stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
div
.modal({backdrop:false})
.modal("show")
.bind("shown", function () {
equal($('.modal-backdrop').length, 0, 'modal backdrop not inserted into dom')
start()
div.remove()
})
})
test("should close backdrop when clicked", function () {
stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
div
.modal({backdrop:true})
.modal("show")
.bind("shown", function () {
equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom')
$('.modal-backdrop').click()
equal($('.modal-backdrop').length, 0, 'modal backdrop removed from dom')
start()
div.remove()
})
})
test("should not close backdrop when click disabled", function () {
stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
div
.modal({backdrop:true, backdropClickHides:false})
.modal("show")
.bind("shown", function () {
equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom')
$('.modal-backdrop').click()
equal($('.modal-backdrop').length, 1, 'modal backdrop still in dom')
start()
div.remove()
$('.modal-backdrop').remove()
})
})
})