Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a keyboard trap in firefox when using iframe #945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions dist/jquery.magnific-popup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Magnific Popup - v1.1.0 - 2016-02-20
/*! Magnific Popup - v1.1.0 - 2017-01-24
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2016 Dmitry Semenov; */
* Copyright (c) 2017 Dmitry Semenov; */
;(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
Expand All @@ -16,9 +16,9 @@ if (typeof define === 'function' && define.amd) {

/*>>core*/
/**
*
*
* Magnific Popup Core JS file
*
*
*/


Expand All @@ -40,7 +40,7 @@ var CLOSE_EVENT = 'Close',


/**
* Private vars
* Private vars
*/
/*jshint -W079 */
var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
Expand Down Expand Up @@ -109,15 +109,15 @@ var _mfpOn = function(name, f) {
v = ['ms','O','Moz','Webkit']; // 'v' for vendor

if( s['transition'] !== undefined ) {
return true;
return true;
}

while( v.length ) {
if( v.pop() + 'Transition' in s ) {
return true;
}
}

return false;
};

Expand All @@ -131,7 +131,7 @@ MagnificPopup.prototype = {
constructor: MagnificPopup,

/**
* Initializes Magnific Popup plugin.
* Initializes Magnific Popup plugin.
* This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed
*/
init: function() {
Expand All @@ -157,7 +157,7 @@ MagnificPopup.prototype = {

var i;

if(data.isObj === false) {
if(data.isObj === false) {
// convert jQuery collection to array to avoid conflicts later
mfp.items = data.items.toArray();

Expand All @@ -184,8 +184,8 @@ MagnificPopup.prototype = {
mfp.updateItemHTML();
return;
}
mfp.types = [];

mfp.types = [];
_wrapClasses = '';
if(data.mainEl && data.mainEl.length) {
mfp.ev = data.mainEl.eq(0);
Expand All @@ -204,7 +204,7 @@ MagnificPopup.prototype = {



mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;

if(mfp.st.modal) {
Expand All @@ -213,7 +213,7 @@ MagnificPopup.prototype = {
mfp.st.showCloseBtn = false;
mfp.st.enableEscapeKey = false;
}


// Building markup
// main containers are created only once
Expand Down Expand Up @@ -265,7 +265,7 @@ MagnificPopup.prototype = {
_wrapClasses += ' mfp-align-top';
}



if(mfp.fixedContentPos) {
mfp.wrap.css({
Expand All @@ -274,7 +274,7 @@ MagnificPopup.prototype = {
overflowY: mfp.st.overflowY
});
} else {
mfp.wrap.css({
mfp.wrap.css({
top: _window.scrollTop(),
position: 'absolute'
});
Expand All @@ -286,7 +286,7 @@ MagnificPopup.prototype = {
});
}



if(mfp.st.enableEscapeKey) {
// Close on ESC key
Expand All @@ -305,15 +305,15 @@ MagnificPopup.prototype = {
if(!mfp.st.closeOnContentClick) {
_wrapClasses += ' mfp-auto-cursor';
}

if(_wrapClasses)
mfp.wrap.addClass(_wrapClasses);


// this triggers recalculation of layout, so we get it once to not to trigger twice
var windowHeight = mfp.wH = _window.height();


var windowStyles = {};

if( mfp.fixedContentPos ) {
Expand All @@ -334,8 +334,8 @@ MagnificPopup.prototype = {
}
}



var classesToadd = mfp.st.mainClass;
if(mfp.isIE7) {
classesToadd += ' mfp-ie7';
Expand All @@ -351,24 +351,24 @@ MagnificPopup.prototype = {

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

// add everything to DOM
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );

// Save last focused element
mfp._lastFocusedEl = document.activeElement;

// Wait for next cycle to allow CSS transition
setTimeout(function() {

if(mfp.content) {
mfp._addClassToMFP(READY_CLASS);
mfp._setFocus();
} else {
// if content is not defined (not loaded e.t.c) we add class only for BG
mfp.bgOverlay.addClass(READY_CLASS);
}

// Trap the focus in popup
_document.on('focusin' + EVENT_NS, mfp._onFocusIn);

Expand Down Expand Up @@ -427,7 +427,7 @@ MagnificPopup.prototype = {
}
$('html').css(windowStyles);
}

_document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS);
mfp.ev.off(EVENT_NS);

Expand All @@ -447,14 +447,14 @@ MagnificPopup.prototype = {
if(mfp.st.autoFocusLast && mfp._lastFocusedEl) {
$(mfp._lastFocusedEl).focus(); // put tab focus back
}
mfp.currItem = null;
mfp.currItem = null;
mfp.content = null;
mfp.currTemplate = null;
mfp.prevHeight = 0;

_mfpTrigger(AFTER_CLOSE_EVENT);
},

updateSize: function(winHeight) {

if(mfp.isIOS) {
Expand Down Expand Up @@ -758,7 +758,7 @@ MagnificPopup.prototype = {
(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
},
_onFocusIn: function(e) {
if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
if( (e.target !== mfp.wrap[0] && e.target !== document) && !$.contains(mfp.wrap[0], e.target) ) {
mfp._setFocus();
return false;
}
Expand Down Expand Up @@ -955,6 +955,7 @@ $.fn.magnificPopup = function(options) {
return jqEl;
};


/*>>core*/

/*>>inline*/
Expand Down
Loading