@ -14,6 +14,7 @@
$ . fn . popup = function ( parameters ) {
$ . fn . popup = function ( parameters ) {
var
var
$allModules = $ ( this ) ,
$allModules = $ ( this ) ,
$document = $ ( document ) ,
settings = ( $ . isPlainObject ( parameters ) )
settings = ( $ . isPlainObject ( parameters ) )
? $ . extend ( true , { } , $ . fn . popup . settings , parameters )
? $ . extend ( true , { } , $ . fn . popup . settings , parameters )
@ -204,6 +205,7 @@ $.fn.popup = function(parameters) {
left : ( popup . position . left < boundary . left )
left : ( popup . position . left < boundary . left )
} ;
} ;
}
}
module . verbose ( 'Checking if outside viewable area' , popup . position ) ;
// return only boundaries that have been surpassed
// return only boundaries that have been surpassed
$ . each ( offstage , function ( direction , isOffstage ) {
$ . each ( offstage , function ( direction , isOffstage ) {
if ( isOffstage ) {
if ( isOffstage ) {
@ -259,7 +261,7 @@ $.fn.popup = function(parameters) {
module . show ( ) ;
module . show ( ) ;
}
}
else {
else {
module . hide ( ) ;
// module.hide();
}
}
} ,
} ,
@ -291,9 +293,10 @@ $.fn.popup = function(parameters) {
switch ( position ) {
switch ( position ) {
case 'top left' :
case 'top left' :
positioning = {
positioning = {
top : 'auto' ,
bottom : parentHeight - offset . top + settings . distanceAway ,
bottom : parentHeight - offset . top + settings . distanceAway ,
left : offset . left + arrowOffset
right : parentWidth - offset . left - width - arrowOffset ,
top : 'auto' ,
left : 'auto'
} ;
} ;
break ;
break ;
case 'top center' :
case 'top center' :
@ -306,10 +309,9 @@ $.fn.popup = function(parameters) {
break ;
break ;
case 'top right' :
case 'top right' :
positioning = {
positioning = {
bottom : parentHeight - offset . top + settings . distanceAway ,
right : parentWidth - offset . left - width - arrowOffset ,
top : 'auto' ,
top : 'auto' ,
left : 'auto'
bottom : parentHeight - offset . top + settings . distanceAway ,
left : offset . left + arrowOffset
} ;
} ;
break ;
break ;
case 'left center' :
case 'left center' :
@ -331,9 +333,9 @@ $.fn.popup = function(parameters) {
case 'bottom left' :
case 'bottom left' :
positioning = {
positioning = {
top : offset . top + height + settings . distanceAway ,
top : offset . top + height + settings . distanceAway ,
left : offset . left + arrowOffset ,
bottom : 'auto' ,
right : 'auto'
right : parentWidth - offset . left - width - arrowOffset ,
left : 'auto' ,
bottom : 'auto'
} ;
} ;
break ;
break ;
case 'bottom center' :
case 'bottom center' :
@ -347,9 +349,9 @@ $.fn.popup = function(parameters) {
case 'bottom right' :
case 'bottom right' :
positioning = {
positioning = {
top : offset . top + height + settings . distanceAway ,
top : offset . top + height + settings . distanceAway ,
right : parentWidth - offset . left - width - arrowOffset ,
left : 'auto' ,
bottom : 'auto'
left : offset . left + arrowOffset ,
bottom : 'auto' ,
right : 'auto'
} ;
} ;
break ;
break ;
}
}
@ -359,11 +361,8 @@ $.fn.popup = function(parameters) {
} ) ;
} ) ;
// tentatively place on stage
// tentatively place on stage
$popup
$popup
. removeAttr ( 'style' )
. removeClass ( 'top right bottom left center' )
. attr ( 'class' , position + ' ' + className . popup + ' ' + className . loading )
. css ( positioning )
. css ( positioning )
. addClass ( position )
. addClass ( className . loading )
;
;
// check if is offstage
// check if is offstage
offstagePosition = module . get . offstagePosition ( ) ;
offstagePosition = module . get . offstagePosition ( ) ;
@ -414,7 +413,7 @@ $.fn.popup = function(parameters) {
}
}
if ( settings . on == 'click' && settings . clicktoClose ) {
if ( settings . on == 'click' && settings . clicktoClose ) {
module . debug ( 'Binding popup close event' ) ;
module . debug ( 'Binding popup close event' ) ;
$ ( document )
$document
. on ( 'click.' + namespace , module . gracefully . hide )
. on ( 'click.' + namespace , module . gracefully . hide )
;
;
}
}
@ -436,18 +435,18 @@ $.fn.popup = function(parameters) {
module . debug ( 'Hiding pop-up' ) ;
module . debug ( 'Hiding pop-up' ) ;
if ( settings . transition && $ . fn . transition !== undefined ) {
if ( settings . transition && $ . fn . transition !== undefined ) {
$popup
$popup
. transition ( settings . transition + ' out' , settings . duration )
. transition ( settings . transition + ' out' , settings . duration , module . reset )
;
;
}
}
else {
else {
$popup
$popup
. stop ( )
. stop ( )
. fadeOut ( settings . duration , settings . easing )
. fadeOut ( settings . duration , settings . easing , module . reset )
;
;
}
}
}
}
if ( settings . on == 'click' && settings . clicktoClose ) {
if ( settings . on == 'click' && settings . clicktoClose ) {
$ ( document )
$document
. off ( 'click.' + namespace )
. off ( 'click.' + namespace )
;
;
}
}
@ -457,6 +456,14 @@ $.fn.popup = function(parameters) {
}
}
} ,
} ,
reset : function ( ) {
module . verbose ( 'Resetting inline styles' ) ;
$popup
. attr ( 'style' , '' )
. removeAttr ( 'style' )
;
} ,
gracefully : {
gracefully : {
hide : function ( event ) {
hide : function ( event ) {
// don't close on clicks inside popup
// don't close on clicks inside popup