Update Magnific Popup to version 0.8.9

This commit is contained in:
Michael Rose 2013-06-04 11:19:59 -04:00
parent 34a15e5ea7
commit 94b9385c12
6 changed files with 174 additions and 98 deletions

View file

@ -32,8 +32,8 @@ Apply the `half` class like so to display two images side by side that share the
And you'll get something that looks like this:
<figure class="half">
<img src="http://placehold.it/600x300.jpg">
<img src="http://placehold.it/600x300.jpg">
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg"></a>
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg"></a>
<figcaption>Two images.</figcaption>
</figure>

View file

@ -2237,6 +2237,20 @@ html {
width: 100%;
cursor: auto;
}
.mfp-inline-holder .mfp-content:after,
.mfp-ajax-holder .mfp-content:after {
content: '';
display: block;
width: auto;
height: auto;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: -1;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}
.mfp-ajax-cur {
cursor: progress;
}
@ -2427,12 +2441,12 @@ button::-moz-focus-inner {
}
.mfp-arrow-left:after,
.mfp-arrow-left .mfp-a {
border-right: 12px solid white;
border-right: 12px solid #fff;
left: 5px;
}
.mfp-arrow-left:before,
.mfp-arrow-left .mfp-b {
border-right: 20px solid white;
border-right: 20px solid #fff;
}
.mfp-arrow-right {
right: 0;
@ -2454,12 +2468,12 @@ button::-moz-focus-inner {
}
.mfp-arrow-right:after,
.mfp-arrow-right .mfp-a {
border-left: 12px solid white;
border-left: 12px solid #fff;
left: 3px;
}
.mfp-arrow-right:before,
.mfp-arrow-right .mfp-b {
border-left: 20px solid white;
border-left: 20px solid #fff;
}
.mfp-iframe-holder {
padding-top: 40px;
@ -2478,7 +2492,8 @@ button::-moz-focus-inner {
}
.mfp-iframe-scaler iframe {
position: absolute;
top: -3px;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
@ -2486,7 +2501,7 @@ button::-moz-focus-inner {
background: black;
}
.mfp-iframe-holder .mfp-close {
top: -43px;
top: -40px;
}
/* Main image in popup */
img.mfp-img {

View file

@ -80,7 +80,7 @@
};
})( jQuery );
/*! Magnific Popup - v0.8.5 - 2013-05-15
/*! Magnific Popup - v0.8.9 - 2013-06-04
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; */
;(function($) {
@ -97,6 +97,7 @@
* Private static constants
*/
var CLOSE_EVENT = 'Close',
AFTER_CLOSE_EVENT = 'AfterClose',
BEFORE_APPEND_EVENT = 'BeforeAppend',
MARKUP_PARSE_EVENT = 'MarkupParse',
OPEN_EVENT = 'Open',
@ -223,7 +224,7 @@ MagnificPopup.prototype = {
init: function() {
var appVersion = navigator.appVersion;
mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1;
mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1,
mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1;
mfp.isLowIE = mfp.isIE7 || mfp.isIE8;
mfp.isAndroid = (/android/gi).test(appVersion);
mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
@ -242,23 +243,12 @@ MagnificPopup.prototype = {
*/
open: function(data) {
mfp.items = data.items.length ? data.items : [data.items];
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
var i;
mfp.types = [];
_wrapClasses = '';
mfp.ev = data.el || _document;
if(data.isObj === false) {
// convert jQuery collection to array to avoid conflicts later
mfp.items = data.items.toArray();
if(data.isObj) {
mfp.index = data.index || 0;
} else {
mfp.index = 0;
var items = data.items,
item;
@ -272,8 +262,20 @@ MagnificPopup.prototype = {
break;
}
}
} else {
mfp.items = $.isArray(data.items) ? data.items : [data.items];
mfp.index = data.index || 0;
}
// if popup is already opened - we just update the content
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
mfp.types = [];
_wrapClasses = '';
mfp.ev = data.mainEl || _document;
if(data.key) {
if(!mfp.popupsCache[data.key]) {
@ -308,7 +310,7 @@ MagnificPopup.prototype = {
mfp.container = _getEl('container', mfp.wrap);
}
mfp.contentContainer = _getEl('content');
if(mfp.st.preloader) {
mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
@ -389,11 +391,13 @@ MagnificPopup.prototype = {
var bodyStyles = {};
if( mfp.fixedContentPos ) {
var s = mfp._getScrollbarSize();
if(s) {
bodyStyles.paddingRight = s;
}
}
if(mfp._hasScrollBar(windowHeight)){
var s = mfp._getScrollbarSize();
if(s) {
bodyStyles.paddingRight = s;
}
}
}
if(mfp.fixedContentPos) {
if(!mfp.isIE7) {
@ -494,11 +498,11 @@ MagnificPopup.prototype = {
mfp._removeClassFromMFP(classesToRemove);
if(mfp.fixedContentPos) {
var bodyStyles = {paddingRight: 0};
var bodyStyles = {paddingRight: ''};
if(mfp.isIE7) {
$('body, html').css('overflow', 'auto');
$('body, html').css('overflow', '');
} else {
bodyStyles.overflow = 'visible';
bodyStyles.overflow = '';
}
_body.css(bodyStyles);
}
@ -525,6 +529,8 @@ MagnificPopup.prototype = {
mfp.content = null;
mfp.currTemplate = null;
mfp.prevHeight = 0;
_mfpTrigger(AFTER_CLOSE_EVENT);
},
updateSize: function(winHeight) {
@ -538,6 +544,10 @@ MagnificPopup.prototype = {
} else {
mfp.wH = winHeight || _window.height();
}
// Fixes #84: popup incorrectly positioned with position:relative on body
if(!mfp.fixedContentPos) {
mfp.wrap.css('height', mfp.wH);
}
_mfpTrigger('Resize');
@ -639,7 +649,6 @@ MagnificPopup.prototype = {
parseEl: function(index) {
var item = mfp.items[index],
type = item.type;
if(item.tagName) {
item = { el: $(item) };
@ -720,9 +729,16 @@ MagnificPopup.prototype = {
}
}
if(e.type)
if(e.type) {
e.preventDefault();
// This will prevent popup from closing if element is inside and popup is already opened
if(mfp.isOpen) {
e.stopPropagation();
}
}
options.el = $(e.mfpEl);
if(options.delegate) {
options.items = el.find(options.delegate);
@ -780,12 +796,8 @@ MagnificPopup.prototype = {
mfp.wrap.removeClass(cName);
},
_hasScrollBar: function(winHeight) {
if(document.body.clientHeight > (winHeight || _window.height()) ) {
return true;
}
return false;
return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) )
},
_parseMarkup: function(template, values, item) {
var arr;
if(item.data) {
@ -983,6 +995,7 @@ for(i = 0; i < rounds; i++) {
console.log('Test #2:', performance.now() - start);
*/
/*>>core*/
/*>>inline*/
@ -1025,7 +1038,8 @@ $.magnificPopup.registerModule(INLINE_NS, {
if(el.length) {
// If target element has parent - we replace it with placeholder and put it back after popup is closed
if(el[0].parentNode !== null) {
var parent = el[0].parentNode;
if(parent && parent.tagName) {
if(!_inlinePlaceholder) {
_hiddenClass = inlineSt.hiddenClass;
_inlinePlaceholder = _getEl(_hiddenClass);
@ -1094,10 +1108,14 @@ $.magnificPopup.registerModule(AJAX_NS, {
var opts = $.extend({
url: item.src,
success: function(data, textStatus, jqXHR) {
var temp = {
data:data,
xhr:jqXHR
};
_mfpTrigger('ParseAjax', jqXHR);
_mfpTrigger('ParseAjax', temp);
mfp.appendContent( $(jqXHR.responseText), AJAX_NS );
mfp.appendContent( $(temp.data), AJAX_NS );
item.finished = true;
@ -1111,6 +1129,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
mfp.updateStatus('ready');
_mfpTrigger('AjaxContentAdded');
},
error: function() {
_removeAjaxCursor();
@ -1435,7 +1454,9 @@ $.magnificPopup.registerModule(IFRAME_NS, {
//}
});
_mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, _fixIframeBugs);
_mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
_fixIframeBugs();
});
},
getIframe: function(item, template) {
@ -1521,8 +1542,10 @@ $.magnificPopup.registerModule('gallery', {
if(gSt.navigateByImgClick) {
mfp.wrap.on('click'+ns, '.mfp-img', function() {
mfp.next();
return false;
if(mfp.items.length > 1) {
mfp.next();
return false;
}
});
}
@ -1543,11 +1566,11 @@ $.magnificPopup.registerModule('gallery', {
_mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
var l = mfp.items.length;
values.counter = l ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
});
_mfpOn('BuildControls' + ns, function() {
if(gSt.arrows && !mfp.arrowLeft) {
if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
var markup = gSt.arrowMarkup,
arrowLeft = mfp.arrowLeft = $( markup.replace('%title%', gSt.tPrev).replace('%dir%', 'left') ).addClass(PREVENT_CLOSE_CLASS),
arrowRight = mfp.arrowRight = $( markup.replace('%title%', gSt.tNext).replace('%dir%', 'right') ).addClass(PREVENT_CLOSE_CLASS);
@ -1586,7 +1609,7 @@ $.magnificPopup.registerModule('gallery', {
_document.off(ns);
mfp.wrap.off('click'+ns);
if(supportsFastClick) {
if(mfp.arrowLeft && supportsFastClick) {
mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
}
mfp.arrowRight = mfp.arrowLeft = null;

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
/*! Magnific Popup - v0.8.5 - 2013-05-15
/*! Magnific Popup - v0.8.9 - 2013-06-04
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; */
;(function($) {
@ -15,6 +15,7 @@
* Private static constants
*/
var CLOSE_EVENT = 'Close',
AFTER_CLOSE_EVENT = 'AfterClose',
BEFORE_APPEND_EVENT = 'BeforeAppend',
MARKUP_PARSE_EVENT = 'MarkupParse',
OPEN_EVENT = 'Open',
@ -141,7 +142,7 @@ MagnificPopup.prototype = {
init: function() {
var appVersion = navigator.appVersion;
mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1;
mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1,
mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1;
mfp.isLowIE = mfp.isIE7 || mfp.isIE8;
mfp.isAndroid = (/android/gi).test(appVersion);
mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
@ -160,23 +161,12 @@ MagnificPopup.prototype = {
*/
open: function(data) {
mfp.items = data.items.length ? data.items : [data.items];
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
var i;
mfp.types = [];
_wrapClasses = '';
mfp.ev = data.el || _document;
if(data.isObj === false) {
// convert jQuery collection to array to avoid conflicts later
mfp.items = data.items.toArray();
if(data.isObj) {
mfp.index = data.index || 0;
} else {
mfp.index = 0;
var items = data.items,
item;
@ -190,8 +180,20 @@ MagnificPopup.prototype = {
break;
}
}
} else {
mfp.items = $.isArray(data.items) ? data.items : [data.items];
mfp.index = data.index || 0;
}
// if popup is already opened - we just update the content
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
mfp.types = [];
_wrapClasses = '';
mfp.ev = data.mainEl || _document;
if(data.key) {
if(!mfp.popupsCache[data.key]) {
@ -226,7 +228,7 @@ MagnificPopup.prototype = {
mfp.container = _getEl('container', mfp.wrap);
}
mfp.contentContainer = _getEl('content');
if(mfp.st.preloader) {
mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
@ -307,11 +309,13 @@ MagnificPopup.prototype = {
var bodyStyles = {};
if( mfp.fixedContentPos ) {
var s = mfp._getScrollbarSize();
if(s) {
bodyStyles.paddingRight = s;
}
}
if(mfp._hasScrollBar(windowHeight)){
var s = mfp._getScrollbarSize();
if(s) {
bodyStyles.paddingRight = s;
}
}
}
if(mfp.fixedContentPos) {
if(!mfp.isIE7) {
@ -412,11 +416,11 @@ MagnificPopup.prototype = {
mfp._removeClassFromMFP(classesToRemove);
if(mfp.fixedContentPos) {
var bodyStyles = {paddingRight: 0};
var bodyStyles = {paddingRight: ''};
if(mfp.isIE7) {
$('body, html').css('overflow', 'auto');
$('body, html').css('overflow', '');
} else {
bodyStyles.overflow = 'visible';
bodyStyles.overflow = '';
}
_body.css(bodyStyles);
}
@ -443,6 +447,8 @@ MagnificPopup.prototype = {
mfp.content = null;
mfp.currTemplate = null;
mfp.prevHeight = 0;
_mfpTrigger(AFTER_CLOSE_EVENT);
},
updateSize: function(winHeight) {
@ -456,6 +462,10 @@ MagnificPopup.prototype = {
} else {
mfp.wH = winHeight || _window.height();
}
// Fixes #84: popup incorrectly positioned with position:relative on body
if(!mfp.fixedContentPos) {
mfp.wrap.css('height', mfp.wH);
}
_mfpTrigger('Resize');
@ -557,7 +567,6 @@ MagnificPopup.prototype = {
parseEl: function(index) {
var item = mfp.items[index],
type = item.type;
if(item.tagName) {
item = { el: $(item) };
@ -638,9 +647,16 @@ MagnificPopup.prototype = {
}
}
if(e.type)
if(e.type) {
e.preventDefault();
// This will prevent popup from closing if element is inside and popup is already opened
if(mfp.isOpen) {
e.stopPropagation();
}
}
options.el = $(e.mfpEl);
if(options.delegate) {
options.items = el.find(options.delegate);
@ -698,12 +714,8 @@ MagnificPopup.prototype = {
mfp.wrap.removeClass(cName);
},
_hasScrollBar: function(winHeight) {
if(document.body.clientHeight > (winHeight || _window.height()) ) {
return true;
}
return false;
return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) )
},
_parseMarkup: function(template, values, item) {
var arr;
if(item.data) {
@ -901,6 +913,7 @@ for(i = 0; i < rounds; i++) {
console.log('Test #2:', performance.now() - start);
*/
/*>>core*/
/*>>inline*/
@ -943,7 +956,8 @@ $.magnificPopup.registerModule(INLINE_NS, {
if(el.length) {
// If target element has parent - we replace it with placeholder and put it back after popup is closed
if(el[0].parentNode !== null) {
var parent = el[0].parentNode;
if(parent && parent.tagName) {
if(!_inlinePlaceholder) {
_hiddenClass = inlineSt.hiddenClass;
_inlinePlaceholder = _getEl(_hiddenClass);
@ -1012,10 +1026,14 @@ $.magnificPopup.registerModule(AJAX_NS, {
var opts = $.extend({
url: item.src,
success: function(data, textStatus, jqXHR) {
var temp = {
data:data,
xhr:jqXHR
};
_mfpTrigger('ParseAjax', jqXHR);
_mfpTrigger('ParseAjax', temp);
mfp.appendContent( $(jqXHR.responseText), AJAX_NS );
mfp.appendContent( $(temp.data), AJAX_NS );
item.finished = true;
@ -1029,6 +1047,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
mfp.updateStatus('ready');
_mfpTrigger('AjaxContentAdded');
},
error: function() {
_removeAjaxCursor();
@ -1353,7 +1372,9 @@ $.magnificPopup.registerModule(IFRAME_NS, {
//}
});
_mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, _fixIframeBugs);
_mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
_fixIframeBugs();
});
},
getIframe: function(item, template) {
@ -1439,8 +1460,10 @@ $.magnificPopup.registerModule('gallery', {
if(gSt.navigateByImgClick) {
mfp.wrap.on('click'+ns, '.mfp-img', function() {
mfp.next();
return false;
if(mfp.items.length > 1) {
mfp.next();
return false;
}
});
}
@ -1461,11 +1484,11 @@ $.magnificPopup.registerModule('gallery', {
_mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
var l = mfp.items.length;
values.counter = l ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
});
_mfpOn('BuildControls' + ns, function() {
if(gSt.arrows && !mfp.arrowLeft) {
if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
var markup = gSt.arrowMarkup,
arrowLeft = mfp.arrowLeft = $( markup.replace('%title%', gSt.tPrev).replace('%dir%', 'left') ).addClass(PREVENT_CLOSE_CLASS),
arrowRight = mfp.arrowRight = $( markup.replace('%title%', gSt.tNext).replace('%dir%', 'right') ).addClass(PREVENT_CLOSE_CLASS);
@ -1504,7 +1527,7 @@ $.magnificPopup.registerModule('gallery', {
_document.off(ns);
mfp.wrap.off('click'+ns);
if(supportsFastClick) {
if(mfp.arrowLeft && supportsFastClick) {
mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
}
mfp.arrowRight = mfp.arrowLeft = null;

View file

@ -56,7 +56,21 @@
.mfp-inline-holder .mfp-content,
.mfp-ajax-holder .mfp-content {
width: 100%;
cursor: auto; }
cursor: auto;
&:after {
content: '';
display: block;
width: auto;
height: auto;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: -1;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}
}
.mfp-ajax-cur {
cursor: progress; }
@ -221,22 +235,22 @@ button::-moz-focus-inner {
.border-radius(5px, 5px, 0, 0); }
.mfp-arrow-left:after,
.mfp-arrow-left .mfp-a {
border-right: 12px solid white;
border-right: 12px solid #fff;
left: 5px; }
.mfp-arrow-left:before,
.mfp-arrow-left .mfp-b {
border-right: 20px solid white; }
border-right: 20px solid #fff; }
.mfp-arrow-right {
right: 0;
.border-radius(0, 0, 5px, 5px); }
.mfp-arrow-right:after,
.mfp-arrow-right .mfp-a {
border-left: 12px solid white;
border-left: 12px solid #fff;
left: 3px; }
.mfp-arrow-right:before,
.mfp-arrow-right .mfp-b {
border-left: 20px solid white; }
border-left: 20px solid #fff; }
.mfp-iframe-holder {
padding-top: 40px;
@ -255,7 +269,8 @@ button::-moz-focus-inner {
.mfp-iframe-scaler iframe {
position: absolute;
top: -3px;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
@ -263,7 +278,7 @@ button::-moz-focus-inner {
background: black; }
.mfp-iframe-holder .mfp-close {
top: -43px; }
top: -40px; }
/* Main image in popup */
img.mfp-img {