Skip to content
GitLab
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
72ad89b0
Commit
72ad89b0
authored
10 years ago
by
Heinrich Fenkart
Browse files
Options
Download
Plain Diff
Merge pull request #14933 from twbs/center-modal-at-all-times
Center modal at all times
parents
425a9854
da74fba4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/modal.js
+33
-8
js/modal.js
with
33 additions
and
8 deletions
+33
-8
js/modal.js
+
33
-
8
View file @
72ad89b0
...
...
@@ -56,11 +56,11 @@
this
.
isShown
=
true
this
.
checkScrollbar
()
this
.
setScrollbar
()
this
.
$body
.
addClass
(
'
modal-open
'
)
this
.
setScrollbar
()
this
.
escape
()
if
(
this
.
options
.
backdrop
)
this
.
resize
()
this
.
resize
()
this
.
$element
.
on
(
'
click.dismiss.bs.modal
'
,
'
[data-dismiss="modal"]
'
,
$
.
proxy
(
this
.
hide
,
this
))
...
...
@@ -75,7 +75,8 @@
.
show
()
.
scrollTop
(
0
)
if
(
that
.
options
.
backdrop
)
that
.
setBackdropHeight
()
if
(
that
.
options
.
backdrop
)
that
.
adjustBackdrop
()
that
.
adjustDialog
()
if
(
transition
)
{
that
.
$element
[
0
].
offsetWidth
// force reflow
...
...
@@ -111,7 +112,7 @@
this
.
isShown
=
false
this
.
escape
()
if
(
this
.
options
.
backdrop
)
this
.
resize
()
this
.
resize
()
$
(
document
).
off
(
'
focusin.bs.modal
'
)
...
...
@@ -149,7 +150,7 @@
Modal
.
prototype
.
resize
=
function
()
{
if
(
this
.
isShown
)
{
$
(
window
).
on
(
'
resize.bs.modal
'
,
$
.
proxy
(
this
.
setBackdropHeight
,
this
))
$
(
window
).
on
(
'
resize.bs.modal
'
,
$
.
proxy
(
this
.
handleUpdate
,
this
))
}
else
{
$
(
window
).
off
(
'
resize.bs.modal
'
)
}
...
...
@@ -160,6 +161,7 @@
this
.
$element
.
hide
()
this
.
backdrop
(
function
()
{
that
.
$body
.
removeClass
(
'
modal-open
'
)
that
.
resetAdjustments
()
that
.
resetScrollbar
()
that
.
$element
.
trigger
(
'
hidden.bs.modal
'
)
})
...
...
@@ -216,19 +218,43 @@
}
}
Modal
.
prototype
.
setBackdropHeight
=
function
()
{
// these following methods are used to handle overflowing modals
Modal
.
prototype
.
handleUpdate
=
function
()
{
if
(
this
.
options
.
backdrop
)
this
.
adjustBackdrop
()
this
.
adjustDialog
()
}
Modal
.
prototype
.
adjustBackdrop
=
function
()
{
this
.
$backdrop
.
css
(
'
height
'
,
0
)
.
css
(
'
height
'
,
this
.
$element
[
0
].
scrollHeight
)
}
Modal
.
prototype
.
adjustDialog
=
function
()
{
var
modalIsOverflowing
=
this
.
$element
[
0
].
scrollHeight
>
document
.
documentElement
.
clientHeight
this
.
$element
.
css
({
paddingLeft
:
!
this
.
bodyIsOverflowing
&&
modalIsOverflowing
?
this
.
scrollbarWidth
:
''
,
paddingRight
:
this
.
bodyIsOverflowing
&&
!
modalIsOverflowing
?
this
.
scrollbarWidth
:
''
})
}
Modal
.
prototype
.
resetAdjustments
=
function
()
{
this
.
$element
.
css
({
paddingLeft
:
''
,
paddingRight
:
''
})
}
Modal
.
prototype
.
checkScrollbar
=
function
()
{
this
.
bodyIsOverflowing
=
document
.
body
.
scrollHeight
>
document
.
documentElement
.
clientHeight
this
.
scrollbarWidth
=
this
.
measureScrollbar
()
}
Modal
.
prototype
.
setScrollbar
=
function
()
{
var
bodyPad
=
parseInt
((
this
.
$body
.
css
(
'
padding-right
'
)
||
0
),
10
)
if
(
this
.
scrollbarWidth
)
this
.
$body
.
css
(
'
padding-right
'
,
bodyPad
+
this
.
scrollbarWidth
)
if
(
this
.
bodyIsOverflowing
)
this
.
$body
.
css
(
'
padding-right
'
,
bodyPad
+
this
.
scrollbarWidth
)
}
Modal
.
prototype
.
resetScrollbar
=
function
()
{
...
...
@@ -236,7 +262,6 @@
}
Modal
.
prototype
.
measureScrollbar
=
function
()
{
// thx walsh
if
(
document
.
body
.
clientWidth
>=
window
.
innerWidth
)
return
0
var
scrollDiv
=
document
.
createElement
(
'
div
'
)
scrollDiv
.
className
=
'
modal-scrollbar-measure
'
this
.
$body
.
append
(
scrollDiv
)
...
...
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