@ -132,7 +132,7 @@ $.fn.modal = function(parameters) {
$dimmer = $dimmable . dimmer ( 'get dimmer' ) ;
} ,
id : function ( ) {
id = ( Math . random ( ) . toString ( 16 ) + '000000000' ) . substr ( 2 , 8 ) ;
id = ( Math . random ( ) . toString ( 16 ) + '000000000' ) . substr ( 2 , 8 ) ;
elementEventNamespace = '.' + id ;
module . verbose ( 'Creating unique id for element' , id ) ;
}
@ -167,6 +167,9 @@ $.fn.modal = function(parameters) {
refresh : function ( ) {
module . remove . scrolling ( ) ;
module . cacheSizes ( ) ;
if ( ! module . can . useFlex ( ) ) {
module . set . modalOffset ( ) ;
}
module . set . screenHeight ( ) ;
module . set . type ( ) ;
} ,
@ -212,7 +215,7 @@ $.fn.modal = function(parameters) {
get : {
id : function ( ) {
return ( Math . random ( ) . toString ( 16 ) + '000000000' ) . substr ( 2 , 8 ) ;
return ( Math . random ( ) . toString ( 16 ) + '000000000' ) . substr ( 2 , 8 ) ;
}
} ,
@ -322,9 +325,16 @@ $.fn.modal = function(parameters) {
: function ( ) { }
;
if ( module . is . animating ( ) || ! module . is . active ( ) ) {
module . showDimmer ( ) ;
module . cacheSizes ( ) ;
if ( module . can . useFlex ( ) ) {
module . remove . legacy ( ) ;
}
else {
module . set . legacy ( ) ;
module . set . modalOffset ( ) ;
module . debug ( 'Using non-flex legacy modal positioning.' ) ;
}
module . set . screenHeight ( ) ;
module . set . type ( ) ;
module . set . clickaway ( ) ;
@ -513,6 +523,9 @@ $.fn.modal = function(parameters) {
active : function ( ) {
$module . removeClass ( className . active ) ;
} ,
legacy : function ( ) {
$module . removeClass ( className . legacy ) ;
} ,
clickaway : function ( ) {
$dimmer
. off ( 'click' + elementEventNamespace )
@ -546,11 +559,13 @@ $.fn.modal = function(parameters) {
$module . addClass ( className . loading ) ;
var
scrollHeight = $module . prop ( 'scrollHeight' ) ,
modalWidth = $module . outerWidth ( ) ,
modalHeight = $module . outerHeight ( )
;
if ( module . cache === undefined || modalHeight !== 0 ) {
module . cache = {
pageHeight : $ ( document ) . outerHeight ( ) ,
width : modalWidth ,
height : modalHeight + settings . offset ,
scrollHeight : scrollHeight + settings . offset ,
contextHeight : ( settings . context == 'body' )
@ -564,6 +579,12 @@ $.fn.modal = function(parameters) {
} ,
can : {
useFlex : function ( ) {
return ( settings . useFlex == 'auto' )
? settings . detachable && ! module . is . ie ( )
: settings . useFlex
;
} ,
fit : function ( ) {
var
contextHeight = module . cache . contextHeight ,
@ -585,6 +606,13 @@ $.fn.modal = function(parameters) {
active : function ( ) {
return $module . hasClass ( className . active ) ;
} ,
ie : function ( ) {
var
isIE11 = ( ! ( window . ActiveXObject ) && 'ActiveXObject' in window ) ,
isIE = ( 'ActiveXObject' in window )
;
return ( isIE11 || isIE ) ;
} ,
animating : function ( ) {
return $module . transition ( 'is supported' )
? $module . transition ( 'is animating' )
@ -596,7 +624,7 @@ $.fn.modal = function(parameters) {
} ,
modernBrowser : function ( ) {
// appName for IE11 reports 'Netscape' can no longer use
return ! ( window . ActiveXObject || "ActiveXObject " in window ) ;
return ! ( window . ActiveXObject || 'ActiveXObject ' in window ) ;
}
} ,
@ -628,10 +656,10 @@ $.fn.modal = function(parameters) {
debug : settings . debug ,
dimmerName : 'modals' ,
closable : 'auto' ,
useFlex : module . can . useFlex ( ) ,
variation : settings . centered
? false
: 'top aligned'
,
: 'top aligned' ,
duration : {
show : settings . duration ,
hide : settings . duration
@ -657,6 +685,19 @@ $.fn.modal = function(parameters) {
}
$context . dimmer ( 'setting' , dimmerSettings ) ;
} ,
modalOffset : function ( ) {
var
width = module . cache . width ,
height = module . cache . height
;
$module
. css ( {
marginTop : - ( height / 2 ) ,
marginLeft : - ( width / 2 )
} )
;
module . verbose ( 'Setting modal offset for legacy mode' ) ;
} ,
screenHeight : function ( ) {
if ( module . can . fit ( ) ) {
$body . css ( 'height' , '' ) ;
@ -675,6 +716,9 @@ $.fn.modal = function(parameters) {
$dimmable . addClass ( className . scrolling ) ;
$module . addClass ( className . scrolling ) ;
} ,
legacy : function ( ) {
$module . addClass ( className . legacy ) ;
} ,
type : function ( ) {
if ( module . can . fit ( ) ) {
module . verbose ( 'Modal fits on screen' ) ;
@ -880,6 +924,9 @@ $.fn.modal.settings = {
name : 'Modal' ,
namespace : 'modal' ,
useFlex : 'auto' ,
offset : 0 ,
silent : false ,
debug : false ,
verbose : false ,
@ -909,7 +956,6 @@ $.fn.modal.settings = {
queue : false ,
duration : 500 ,
offset : 0 ,
transition : 'scale' ,
// padding with edge of page
@ -949,6 +995,7 @@ $.fn.modal.settings = {
animating : 'animating' ,
blurring : 'blurring' ,
inverted : 'inverted' ,
legacy : 'legacy' ,
loading : 'loading' ,
scrolling : 'scrolling' ,
undetached : 'undetached'