From 90ae611485d322ad2d29ceb6467f7e3dcaf26940 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 17 Nov 2014 13:16:00 -0500 Subject: [PATCH] Fixes #1256, issues with offsetParent as 'html', should account for padding added to 'body' --- src/definitions/modules/popup.js | 25 +++++++++++++++---------- src/definitions/modules/popup.less | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index 82e793e17..ee0fb09a0 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -408,8 +408,9 @@ $.fn.popup = function(parameters) { } return false; }, - offstagePosition: function() { + offstagePosition: function(position) { var + position = position || false, boundary = { top : $(window).scrollTop(), bottom : $(window).scrollTop() + $(window).height(), @@ -418,13 +419,14 @@ $.fn.popup = function(parameters) { }, popup = { width : $popup.width(), - height : $popup.outerHeight(), + height : $popup.height(), offset : $popup.offset() }, offstage = {}, offstagePositions = [] ; - if(popup.offset) { + if(popup.offset && position) { + module.verbose('Checking if outside viewable area', popup.offset); offstage = { top : (popup.offset.top < boundary.top), bottom : (popup.offset.top + popup.height > boundary.bottom), @@ -432,7 +434,6 @@ $.fn.popup = function(parameters) { left : (popup.offset.left < boundary.left) }; } - module.verbose('Checking if outside viewable area', popup.offset); // return only boundaries that have been surpassed $.each(offstage, function(direction, isOffstage) { if(isOffstage) { @@ -487,17 +488,22 @@ $.fn.popup = function(parameters) { popupWidth = $popup.outerWidth(), popupHeight = $popup.outerHeight(), - parentWidth = $offsetParent.outerWidth(), - parentHeight = $offsetParent.outerHeight(), + parentWidth = ( $offsetParent.is('html') ) + ? $offsetParent.find('body').width() + : $offsetParent.outerWidth(), + + parentHeight = ( $offsetParent.is('html') ) + ? $offsetParent.find('body').height() + : $offsetParent.outerHeight(), distanceAway = settings.distanceAway, targetElement = $target[0], - marginTop = (settings.inline) + marginTop = (settings.inline) ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10) : 0, - marginLeft = (settings.inline) + marginLeft = (settings.inline) ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10) : 0, @@ -510,7 +516,6 @@ $.fn.popup = function(parameters) { ; position = position || $module.data(metadata.position) || settings.position; arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset; - if(settings.inline) { module.debug('Adding targets margin to calculation'); if(position == 'left center' || position == 'right center') { @@ -604,7 +609,7 @@ $.fn.popup = function(parameters) { .addClass(className.loading) ; // check if is offstage - offstagePosition = module.get.offstagePosition(); + offstagePosition = module.get.offstagePosition(position); // recursively find new positioning if(offstagePosition) { module.debug('Element is outside boundaries', offstagePosition); diff --git a/src/definitions/modules/popup.less b/src/definitions/modules/popup.less index ad63be0ad..ff02683b2 100755 --- a/src/definitions/modules/popup.less +++ b/src/definitions/modules/popup.less @@ -236,7 +236,7 @@ .ui.fluid.popup { width: 100%; - max-width: 99999px; + max-width: none; } @@ -265,7 +265,7 @@ ---------------*/ .ui.flowing.popup { - max-width: 9999px; + max-width: none; }