Skip to content

Commit

Permalink
fix: body element is null when popup is initialized outside of it, cl…
Browse files Browse the repository at this point in the history
  • Loading branch information
dimsemenov committed Dec 4, 2013
1 parent 7ddf368 commit bcffd5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions dist/jquery.magnific-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ MagnificPopup.prototype = {
// We disable fixed positioned lightbox on devices that don't handle it nicely.
// If you know a better way of detecting this - let me know.
mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
_body = $(document.body);
_document = $(document);

mfp.popupsCache = {};
Expand All @@ -146,6 +145,10 @@ MagnificPopup.prototype = {
*/
open: function(data) {

if(!_body) {
_body = $(document.body);
}

var i;

if(data.isObj === false) {
Expand Down Expand Up @@ -340,14 +343,11 @@ MagnificPopup.prototype = {

_mfpTrigger('BuildControls');


// remove scrollbar, add margin e.t.c
$('html').css(windowStyles);

// add everything to DOM
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo );


mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || _body );

// Save last focused element
mfp._lastFocusedEl = document.activeElement;
Expand Down Expand Up @@ -887,7 +887,7 @@ $.magnificPopup = {

removalDelay: 0,

prependTo: document.body,
prependTo: null,

fixedContentPos: 'auto',

Expand Down
Loading

0 comments on commit bcffd5e

Please sign in to comment.