Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
ef5ac02b
Commit
ef5ac02b
authored
Mar 24, 2012
by
Jacob Thornton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow prevent default for show and hide event in modal
parent
f9f03d89
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
14 deletions
+53
-14
docs/assets/bootstrap.zip
docs/assets/bootstrap.zip
+0
-0
docs/assets/js/bootstrap-modal.js
docs/assets/js/bootstrap-modal.js
+12
-7
js/bootstrap-modal.js
js/bootstrap-modal.js
+12
-7
js/tests/unit/bootstrap-modal.js
js/tests/unit/bootstrap-modal.js
+29
-0
No files found.
docs/assets/bootstrap.zip
View file @
ef5ac02b
No preview for this file type
docs/assets/js/bootstrap-modal.js
View file @
ef5ac02b
...
@@ -41,13 +41,15 @@
...
@@ -41,13 +41,15 @@
,
show
:
function
()
{
,
show
:
function
()
{
var
that
=
this
var
that
=
this
,
e
=
$
.
Event
(
'
show
'
)
if
(
this
.
isShown
)
return
this
.
$element
.
trigger
(
e
)
if
(
this
.
isShown
||
e
.
isDefaultPrevented
())
return
$
(
'
body
'
).
addClass
(
'
modal-open
'
)
$
(
'
body
'
).
addClass
(
'
modal-open
'
)
this
.
isShown
=
true
this
.
isShown
=
true
this
.
$element
.
trigger
(
'
show
'
)
escape
.
call
(
this
)
escape
.
call
(
this
)
backdrop
.
call
(
this
,
function
()
{
backdrop
.
call
(
this
,
function
()
{
...
@@ -74,18 +76,21 @@
...
@@ -74,18 +76,21 @@
,
hide
:
function
(
e
)
{
,
hide
:
function
(
e
)
{
e
&&
e
.
preventDefault
()
e
&&
e
.
preventDefault
()
if
(
!
this
.
isShown
)
return
var
that
=
this
var
that
=
this
e
=
$
.
Event
(
'
hide
'
)
this
.
$element
.
trigger
(
e
)
if
(
!
this
.
isShown
||
e
.
isDefaultPrevented
())
return
this
.
isShown
=
false
this
.
isShown
=
false
$
(
'
body
'
).
removeClass
(
'
modal-open
'
)
$
(
'
body
'
).
removeClass
(
'
modal-open
'
)
escape
.
call
(
this
)
escape
.
call
(
this
)
this
.
$element
this
.
$element
.
removeClass
(
'
in
'
)
.
trigger
(
'
hide
'
)
.
removeClass
(
'
in
'
)
$
.
support
.
transition
&&
this
.
$element
.
hasClass
(
'
fade
'
)
?
$
.
support
.
transition
&&
this
.
$element
.
hasClass
(
'
fade
'
)
?
hideWithTransition
.
call
(
this
)
:
hideWithTransition
.
call
(
this
)
:
...
...
js/bootstrap-modal.js
View file @
ef5ac02b
...
@@ -41,13 +41,15 @@
...
@@ -41,13 +41,15 @@
,
show
:
function
()
{
,
show
:
function
()
{
var
that
=
this
var
that
=
this
,
e
=
$
.
Event
(
'
show
'
)
if
(
this
.
isShown
)
return
this
.
$element
.
trigger
(
e
)
if
(
this
.
isShown
||
e
.
isDefaultPrevented
())
return
$
(
'
body
'
).
addClass
(
'
modal-open
'
)
$
(
'
body
'
).
addClass
(
'
modal-open
'
)
this
.
isShown
=
true
this
.
isShown
=
true
this
.
$element
.
trigger
(
'
show
'
)
escape
.
call
(
this
)
escape
.
call
(
this
)
backdrop
.
call
(
this
,
function
()
{
backdrop
.
call
(
this
,
function
()
{
...
@@ -74,18 +76,21 @@
...
@@ -74,18 +76,21 @@
,
hide
:
function
(
e
)
{
,
hide
:
function
(
e
)
{
e
&&
e
.
preventDefault
()
e
&&
e
.
preventDefault
()
if
(
!
this
.
isShown
)
return
var
that
=
this
var
that
=
this
e
=
$
.
Event
(
'
hide
'
)
this
.
$element
.
trigger
(
e
)
if
(
!
this
.
isShown
||
e
.
isDefaultPrevented
())
return
this
.
isShown
=
false
this
.
isShown
=
false
$
(
'
body
'
).
removeClass
(
'
modal-open
'
)
$
(
'
body
'
).
removeClass
(
'
modal-open
'
)
escape
.
call
(
this
)
escape
.
call
(
this
)
this
.
$element
this
.
$element
.
removeClass
(
'
in
'
)
.
trigger
(
'
hide
'
)
.
removeClass
(
'
in
'
)
$
.
support
.
transition
&&
this
.
$element
.
hasClass
(
'
fade
'
)
?
$
.
support
.
transition
&&
this
.
$element
.
hasClass
(
'
fade
'
)
?
hideWithTransition
.
call
(
this
)
:
hideWithTransition
.
call
(
this
)
:
...
...
js/tests/unit/bootstrap-modal.js
View file @
ef5ac02b
...
@@ -29,6 +29,35 @@ $(function () {
...
@@ -29,6 +29,35 @@ $(function () {
.
modal
(
"
show
"
)
.
modal
(
"
show
"
)
})
})
test
(
"
should fire show event
"
,
function
()
{
stop
()
$
.
support
.
transition
=
false
$
(
"
<div id='modal-test'></div>
"
)
.
bind
(
"
show
"
,
function
()
{
ok
(
true
,
"
show was called
"
)
})
.
bind
(
"
shown
"
,
function
()
{
$
(
this
).
remove
()
start
()
})
.
modal
(
"
show
"
)
})
test
(
"
should not fire shown when default prevented
"
,
function
()
{
stop
()
$
.
support
.
transition
=
false
$
(
"
<div id='modal-test'></div>
"
)
.
bind
(
"
show
"
,
function
(
e
)
{
e
.
preventDefault
()
ok
(
true
,
"
show was called
"
)
start
()
})
.
bind
(
"
shown
"
,
function
()
{
ok
(
false
,
"
shown was called
"
)
})
.
modal
(
"
show
"
)
})
test
(
"
should hide modal when hide is called
"
,
function
()
{
test
(
"
should hide modal when hide is called
"
,
function
()
{
stop
()
stop
()
$
.
support
.
transition
=
false
$
.
support
.
transition
=
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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