Skip to content

Commit

Permalink
#2526 Popup fluid width is now set by its parent DOM element, not its…
Browse files Browse the repository at this point in the history
… offsetContext (i.e. thing with position: relative)
  • Loading branch information
jlukic committed Jul 13, 2015
1 parent 9b2b159 commit 5d113c0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ $.fn.popup = function(parameters) {
}
};

// add in container if fluid
if( settings.setFluidWidth && module.is.fluid() ) {
calculations.container = {
width: $popup.parent().outerWidth()
};
calculations.popup.width = calculations.container.width;
}

// add in margins if inline
calculations.target.margin.top = (settings.inline)
? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
Expand Down Expand Up @@ -669,6 +677,7 @@ $.fn.popup = function(parameters) {
popupOffset,
distanceFromBoundary
;

calculations = calculations || module.get.calculations();
position = position || $module.data(metadata.position) || settings.position;

Expand Down Expand Up @@ -830,16 +839,17 @@ $.fn.popup = function(parameters) {
}
module.debug('Position is on stage', position);
module.remove.attempts();
module.set.fluidWidth(calculations);
module.remove.loading();
if( settings.setFluidWidth && module.is.fluid() ) {
module.set.fluidWidth(calculations);
}
return true;
},

fluidWidth: function(calculations) {
calculations = calculations || module.get.calculations();
if( settings.setFluidWidth && $popup.hasClass(className.fluid) ) {
$popup.css('width', calculations.parent.width);
}
module.debug('Automatically setting element width to parent width', calculations.parent.width);
$popup.css('width', calculations.container.width);
},

visible: function() {
Expand Down Expand Up @@ -980,6 +990,9 @@ $.fn.popup = function(parameters) {
animating: function() {
return ( $popup && $popup.hasClass(className.animating) );
},
fluid: function() {
return ( $popup && $popup.hasClass(className.fluid));
},
visible: function() {
return $popup && $popup.hasClass(className.visible);
},
Expand Down

0 comments on commit 5d113c0

Please sign in to comment.