Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
2cb23331
Commit
2cb23331
authored
13 years ago
by
Nick Veys
Browse files
Options
Download
Email Patches
Plain Diff
Adding flag to prevent backdrop click hiding modal
parent
732ff9ed
2 merge requests
!631
Responsive design
,
!231
Adding flag to prevent backdrop click hiding modal
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/javascript.html
+6
-0
docs/javascript.html
js/bootstrap-modal.js
+5
-2
js/bootstrap-modal.js
js/tests/unit/bootstrap-modal.js
+63
-1
js/tests/unit/bootstrap-modal.js
with
74 additions
and
3 deletions
+74
-3
docs/javascript.html
+
6
-
0
View file @
2cb23331
...
@@ -105,6 +105,12 @@
...
@@ -105,6 +105,12 @@
<td>
false
</td>
<td>
false
</td>
<td>
Includes a modal-backdrop element
</td>
<td>
Includes a modal-backdrop element
</td>
</tr>
</tr>
<tr>
<td>
backdropClickHides
</td>
<td>
boolean
</td>
<td>
true
</td>
<td>
A click on the modal-backdrop element hides the modal
</td>
</tr>
<tr>
<tr>
<td>
keyboard
</td>
<td>
keyboard
</td>
<td>
boolean
</td>
<td>
boolean
</td>
...
...
This diff is collapsed.
Click to expand it.
js/bootstrap-modal.js
+
5
-
2
View file @
2cb23331
...
@@ -133,8 +133,10 @@
...
@@ -133,8 +133,10 @@
,
animate
=
this
.
$element
.
hasClass
(
'
fade
'
)
?
'
fade
'
:
''
,
animate
=
this
.
$element
.
hasClass
(
'
fade
'
)
?
'
fade
'
:
''
if
(
this
.
isShown
&&
this
.
settings
.
backdrop
)
{
if
(
this
.
isShown
&&
this
.
settings
.
backdrop
)
{
this
.
$backdrop
=
$
(
'
<div class="modal-backdrop
'
+
animate
+
'
" />
'
)
this
.
$backdrop
=
$
(
'
<div class="modal-backdrop
'
+
animate
+
'
" />
'
)
.
click
(
$
.
proxy
(
this
.
hide
,
this
))
if
(
this
.
settings
.
backdropClickHides
)
{
.
appendTo
(
document
.
body
)
this
.
$backdrop
.
click
(
$
.
proxy
(
this
.
hide
,
this
))
}
this
.
$backdrop
.
appendTo
(
document
.
body
)
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
$backdrop
&&
that
.
$backdrop
.
addClass
(
'
in
'
)
that
.
$backdrop
&&
that
.
$backdrop
.
addClass
(
'
in
'
)
...
@@ -208,6 +210,7 @@
...
@@ -208,6 +210,7 @@
$
.
fn
.
modal
.
defaults
=
{
$
.
fn
.
modal
.
defaults
=
{
backdrop
:
false
backdrop
:
false
,
backdropClickHides
:
true
,
keyboard
:
false
,
keyboard
:
false
,
show
:
true
,
show
:
true
}
}
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/bootstrap-modal.js
+
63
-
1
View file @
2cb23331
...
@@ -86,4 +86,66 @@ $(function () {
...
@@ -86,4 +86,66 @@ $(function () {
})
})
.
modal
(
"
toggle
"
)
.
modal
(
"
toggle
"
)
})
})
})
\ No newline at end of file
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
()
})
})
})
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets