Update Magnific Popup to version 0.8.9

This commit is contained in:
Michael Rose committed 2013-06-04 11:19:59 -04:00
1 parent 34a15e5ea7
commit 94b9385c12
6 files changed
+158 -82

No files matched your search

+2 -2
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: And you'll get something that looks like this:
<figure class="half"> <figure class="half">
<img src="http://placehold.it/600x300.jpg"> <a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg"></a>
<img src="http://placehold.it/600x300.jpg"> <a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg"></a>
<figcaption>Two images.</figcaption> <figcaption>Two images.</figcaption>
</figure> </figure>
+21 -6
View File
@@ -2237,6 +2237,20 @@ html {
width: 100%; width: 100%;
cursor: auto; 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 { .mfp-ajax-cur {
cursor: progress; cursor: progress;
} }
@@ -2427,12 +2441,12 @@ button::-moz-focus-inner {
} }
.mfp-arrow-left:after, .mfp-arrow-left:after,
.mfp-arrow-left .mfp-a { .mfp-arrow-left .mfp-a {
border-right: 12px solid white; border-right: 12px solid #fff;
left: 5px; left: 5px;
} }
.mfp-arrow-left:before, .mfp-arrow-left:before,
.mfp-arrow-left .mfp-b { .mfp-arrow-left .mfp-b {
border-right: 20px solid white; border-right: 20px solid #fff;
} }
.mfp-arrow-right { .mfp-arrow-right {
right: 0; right: 0;
@@ -2454,12 +2468,12 @@ button::-moz-focus-inner {
} }
.mfp-arrow-right:after, .mfp-arrow-right:after,
.mfp-arrow-right .mfp-a { .mfp-arrow-right .mfp-a {
border-left: 12px solid white; border-left: 12px solid #fff;
left: 3px; left: 3px;
} }
.mfp-arrow-right:before, .mfp-arrow-right:before,
.mfp-arrow-right .mfp-b { .mfp-arrow-right .mfp-b {
border-left: 20px solid white; border-left: 20px solid #fff;
} }
.mfp-iframe-holder { .mfp-iframe-holder {
padding-top: 40px; padding-top: 40px;
@@ -2478,7 +2492,8 @@ button::-moz-focus-inner {
} }
.mfp-iframe-scaler iframe { .mfp-iframe-scaler iframe {
position: absolute; position: absolute;
top: -3px; display: block;
top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -2486,7 +2501,7 @@ button::-moz-focus-inner {
background: black; background: black;
} }
.mfp-iframe-holder .mfp-close { .mfp-iframe-holder .mfp-close {
top: -43px; top: -40px;
} }
/* Main image in popup */ /* Main image in popup */
img.mfp-img { img.mfp-img {
+56 -33
View File
@@ -80,7 +80,7 @@
}; };
})( jQuery ); })( jQuery );
/*! Magnific Popup - v0.8.5 - 2013-05-15 /*! Magnific Popup - v0.8.9 - 2013-06-04
* http://dimsemenov.com/plugins/magnific-popup/ * http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; */ * Copyright (c) 2013 Dmitry Semenov; */
;(function($) { ;(function($) {
@@ -97,6 +97,7 @@
* Private static constants * Private static constants
*/ */
var CLOSE_EVENT = 'Close', var CLOSE_EVENT = 'Close',
AFTER_CLOSE_EVENT = 'AfterClose',
BEFORE_APPEND_EVENT = 'BeforeAppend', BEFORE_APPEND_EVENT = 'BeforeAppend',
MARKUP_PARSE_EVENT = 'MarkupParse', MARKUP_PARSE_EVENT = 'MarkupParse',
OPEN_EVENT = 'Open', OPEN_EVENT = 'Open',
@@ -223,7 +224,7 @@ MagnificPopup.prototype = {
init: function() { init: function() {
var appVersion = navigator.appVersion; var appVersion = navigator.appVersion;
mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1; 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.isLowIE = mfp.isIE7 || mfp.isIE8;
mfp.isAndroid = (/android/gi).test(appVersion); mfp.isAndroid = (/android/gi).test(appVersion);
mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion); mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
@@ -242,23 +243,12 @@ MagnificPopup.prototype = {
*/ */
open: function(data) { open: function(data) {
mfp.items = data.items.length ? data.items : [data.items];
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
var i; var i;
mfp.types = []; if(data.isObj === false) {
_wrapClasses = ''; // convert jQuery collection to array to avoid conflicts later
mfp.items = data.items.toArray();
mfp.ev = data.el || _document;
if(data.isObj) {
mfp.index = data.index || 0;
} else {
mfp.index = 0; mfp.index = 0;
var items = data.items, var items = data.items,
item; item;
@@ -272,8 +262,20 @@ MagnificPopup.prototype = {
break; 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(data.key) {
if(!mfp.popupsCache[data.key]) { if(!mfp.popupsCache[data.key]) {
@@ -389,11 +391,13 @@ MagnificPopup.prototype = {
var bodyStyles = {}; var bodyStyles = {};
if( mfp.fixedContentPos ) { if( mfp.fixedContentPos ) {
if(mfp._hasScrollBar(windowHeight)){
var s = mfp._getScrollbarSize(); var s = mfp._getScrollbarSize();
if(s) { if(s) {
bodyStyles.paddingRight = s; bodyStyles.paddingRight = s;
} }
} }
}
if(mfp.fixedContentPos) { if(mfp.fixedContentPos) {
if(!mfp.isIE7) { if(!mfp.isIE7) {
@@ -494,11 +498,11 @@ MagnificPopup.prototype = {
mfp._removeClassFromMFP(classesToRemove); mfp._removeClassFromMFP(classesToRemove);
if(mfp.fixedContentPos) { if(mfp.fixedContentPos) {
var bodyStyles = {paddingRight: 0}; var bodyStyles = {paddingRight: ''};
if(mfp.isIE7) { if(mfp.isIE7) {
$('body, html').css('overflow', 'auto'); $('body, html').css('overflow', '');
} else { } else {
bodyStyles.overflow = 'visible'; bodyStyles.overflow = '';
} }
_body.css(bodyStyles); _body.css(bodyStyles);
} }
@@ -525,6 +529,8 @@ MagnificPopup.prototype = {
mfp.content = null; mfp.content = null;
mfp.currTemplate = null; mfp.currTemplate = null;
mfp.prevHeight = 0; mfp.prevHeight = 0;
_mfpTrigger(AFTER_CLOSE_EVENT);
}, },
updateSize: function(winHeight) { updateSize: function(winHeight) {
@@ -538,6 +544,10 @@ MagnificPopup.prototype = {
} else { } else {
mfp.wH = winHeight || _window.height(); 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'); _mfpTrigger('Resize');
@@ -640,7 +650,6 @@ MagnificPopup.prototype = {
var item = mfp.items[index], var item = mfp.items[index],
type = item.type; type = item.type;
if(item.tagName) { if(item.tagName) {
item = { el: $(item) }; item = { el: $(item) };
} else { } else {
@@ -720,9 +729,16 @@ MagnificPopup.prototype = {
} }
} }
if(e.type) if(e.type) {
e.preventDefault(); 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); options.el = $(e.mfpEl);
if(options.delegate) { if(options.delegate) {
options.items = el.find(options.delegate); options.items = el.find(options.delegate);
@@ -780,12 +796,8 @@ MagnificPopup.prototype = {
mfp.wrap.removeClass(cName); mfp.wrap.removeClass(cName);
}, },
_hasScrollBar: function(winHeight) { _hasScrollBar: function(winHeight) {
if(document.body.clientHeight > (winHeight || _window.height()) ) { return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) )
return true;
}
return false;
}, },
_parseMarkup: function(template, values, item) { _parseMarkup: function(template, values, item) {
var arr; var arr;
if(item.data) { if(item.data) {
@@ -983,6 +995,7 @@ for(i = 0; i < rounds; i++) {
console.log('Test #2:', performance.now() - start); console.log('Test #2:', performance.now() - start);
*/ */
/*>>core*/ /*>>core*/
/*>>inline*/ /*>>inline*/
@@ -1025,7 +1038,8 @@ $.magnificPopup.registerModule(INLINE_NS, {
if(el.length) { if(el.length) {
// If target element has parent - we replace it with placeholder and put it back after popup is closed // 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) { if(!_inlinePlaceholder) {
_hiddenClass = inlineSt.hiddenClass; _hiddenClass = inlineSt.hiddenClass;
_inlinePlaceholder = _getEl(_hiddenClass); _inlinePlaceholder = _getEl(_hiddenClass);
@@ -1094,10 +1108,14 @@ $.magnificPopup.registerModule(AJAX_NS, {
var opts = $.extend({ var opts = $.extend({
url: item.src, url: item.src,
success: function(data, textStatus, jqXHR) { 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; item.finished = true;
@@ -1111,6 +1129,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
mfp.updateStatus('ready'); mfp.updateStatus('ready');
_mfpTrigger('AjaxContentAdded');
}, },
error: function() { error: function() {
_removeAjaxCursor(); _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) { getIframe: function(item, template) {
@@ -1521,8 +1542,10 @@ $.magnificPopup.registerModule('gallery', {
if(gSt.navigateByImgClick) { if(gSt.navigateByImgClick) {
mfp.wrap.on('click'+ns, '.mfp-img', function() { mfp.wrap.on('click'+ns, '.mfp-img', function() {
if(mfp.items.length > 1) {
mfp.next(); mfp.next();
return false; return false;
}
}); });
} }
@@ -1543,11 +1566,11 @@ $.magnificPopup.registerModule('gallery', {
_mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) { _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
var l = mfp.items.length; 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() { _mfpOn('BuildControls' + ns, function() {
if(gSt.arrows && !mfp.arrowLeft) { if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
var markup = gSt.arrowMarkup, var markup = gSt.arrowMarkup,
arrowLeft = mfp.arrowLeft = $( markup.replace('%title%', gSt.tPrev).replace('%dir%', 'left') ).addClass(PREVENT_CLOSE_CLASS), 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); 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); _document.off(ns);
mfp.wrap.off('click'+ns); mfp.wrap.off('click'+ns);
if(supportsFastClick) { if(mfp.arrowLeft && supportsFastClick) {
mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick(); mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
} }
mfp.arrowRight = mfp.arrowLeft = null; mfp.arrowRight = mfp.arrowLeft = null;
+1 -1
View File
@@ -1 +1 @@
(function(e){"use strict";e.fn.fitVids=function(t){var n={customSelector:null};var r=document.createElement("div"),i=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];r.className="fit-vids-style";r.innerHTML="­<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>";i.parentNode.insertBefore(r,i);if(t){e.extend(n,t)}return this.each(function(){var t=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.youtube-nocookie.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(n.customSelector){t.push(n.customSelector)}var r=e(this).find(t.join(","));r.each(function(){var t=e(this);if(this.tagName.toLowerCase()==="embed"&&t.parent("object").length||t.parent(".fluid-width-video-wrapper").length){return}var n=this.tagName.toLowerCase()==="object"||t.attr("height")&&!isNaN(parseInt(t.attr("height"),10))?parseInt(t.attr("height"),10):t.height(),r=!isNaN(parseInt(t.attr("width"),10))?parseInt(t.attr("width"),10):t.width(),i=n/r;if(!t.attr("id")){var s="fitvid"+Math.floor(Math.random()*999999);t.attr("id",s)}t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",i*100+"%");t.removeAttr("height").removeAttr("width")})})}})(jQuery);(function(e){var t="Close",n="BeforeAppend",r="MarkupParse",i="Open",s="Change",o="mfp",u="."+o,a="mfp-ready",f="mfp-removing",l="mfp-prevent-close";var c,h=function(){},p=!!window.jQuery,d,v=e(window),m,g,y,b,w;var E=function(e,t){c.ev.on(o+e+u,t)},S=function(t,n,r,i){var s=document.createElement("div");s.className="mfp-"+t;if(r){s.innerHTML=r}if(!i){s=e(s);if(n){s.appendTo(n)}}else if(n){n.appendChild(s)}return s},x=function(t,n){c.ev.triggerHandler(o+t,n);if(c.st.callbacks){t=t.charAt(0).toLowerCase()+t.slice(1);if(c.st.callbacks[t]){c.st.callbacks[t].apply(c,e.isArray(n)?n:[n])}}},T=function(){(c.st.focus?c.content.find(c.st.focus).eq(0):c.wrap).focus()},N=function(t){if(t!==w||!c.currTemplate.closeBtn){c.currTemplate.closeBtn=e(c.st.closeMarkup.replace("%title%",c.st.tClose));w=t}return c.currTemplate.closeBtn},C=function(){if(!e.magnificPopup.instance){c=new h;c.init();e.magnificPopup.instance=c}},k=function(t){if(e(t).hasClass(l)){return}var n=c.st.closeOnContentClick;var r=c.st.closeOnBgClick;if(n&&r){return true}else{if(!c.content||e(t).hasClass("mfp-close")||c.preloader&&t===c.preloader[0]){return true}if(t!==c.content[0]&&!e.contains(c.content[0],t)){if(r){return true}}else if(n){return true}}return false};h.prototype={constructor:h,init:function(){var t=navigator.appVersion;c.isIE7=t.indexOf("MSIE 7.")!==-1;c.isIE8=t.indexOf("MSIE 8.")!==-1,c.isLowIE=c.isIE7||c.isIE8;c.isAndroid=/android/gi.test(t);c.isIOS=/iphone|ipad|ipod/gi.test(t);c.probablyMobile=c.isAndroid||c.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent);m=e(document.body);g=e(document);c.popupsCache={}},open:function(t){c.items=t.items.length?t.items:[t.items];if(c.isOpen){c.updateItemHTML();return}var n;c.types=[];b="";c.ev=t.el||g;if(t.isObj){c.index=t.index||0}else{c.index=0;var s=t.items,o;for(n=0;n<s.length;n++){o=s[n];if(o.parsed){o=o.el[0]}if(o===t.el[0]){c.index=n;break}}}if(t.key){if(!c.popupsCache[t.key]){c.popupsCache[t.key]={}}c.currTemplate=c.popupsCache[t.key]}else{c.currTemplate={}}c.st=e.extend(true,{},e.magnificPopup.defaults,t);c.fixedContentPos=c.st.fixedContentPos==="auto"?!c.probablyMobile:c.st.fixedContentPos;if(!c.bgOverlay){c.bgOverlay=S("bg").on("click"+u,function(){c.close()});c.wrap=S("wrap").attr("tabindex",-1).on("click"+u,function(e){if(k(e.target)){c.close()}});c.container=S("container",c.wrap)}c.contentContainer=S("content");if(c.st.preloader){c.preloader=S("preloader",c.container,c.st.tLoading)}var f=e.magnificPopup.modules;for(n=0;n<f.length;n++){var l=f[n];l=l.charAt(0).toUpperCase()+l.slice(1);c["init"+l].call(c)}x("BeforeOpen");if(!c.st.closeBtnInside){c.wrap.append(N())}else{E(r,function(e,t,n,r){n.close_replaceWith=N(r.type)});b+=" mfp-close-btn-in"}if(c.st.alignTop){b+=" mfp-align-top"}if(c.fixedContentPos){c.wrap.css({overflow:c.st.overflowY,overflowX:"hidden",overflowY:c.st.overflowY})}else{c.wrap.css({top:v.scrollTop(),position:"absolute"})}if(c.st.fixedBgPos===false||c.st.fixedBgPos==="auto"&&!c.fixedContentPos){c.bgOverlay.css({height:g.height(),position:"absolute"})}g.on("keyup"+u,functionLine truncated (function(e){"use strict";e.fn.fitVids=function(t){var n={customSelector:null};var r=document.createElement("div"),i=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];r.className="fit-vids-style";r.innerHTML="­<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>";i.parentNode.insertBefore(r,i);if(t){e.extend(n,t)}return this.each(function(){var t=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.youtube-nocookie.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(n.customSelector){t.push(n.customSelector)}var r=e(this).find(t.join(","));r.each(function(){var t=e(this);if(this.tagName.toLowerCase()==="embed"&&t.parent("object").length||t.parent(".fluid-width-video-wrapper").length){return}var n=this.tagName.toLowerCase()==="object"||t.attr("height")&&!isNaN(parseInt(t.attr("height"),10))?parseInt(t.attr("height"),10):t.height(),r=!isNaN(parseInt(t.attr("width"),10))?parseInt(t.attr("width"),10):t.width(),i=n/r;if(!t.attr("id")){var s="fitvid"+Math.floor(Math.random()*999999);t.attr("id",s)}t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",i*100+"%");t.removeAttr("height").removeAttr("width")})})}})(jQuery);(function(e){var t="Close",n="AfterClose",r="BeforeAppend",i="MarkupParse",s="Open",o="Change",u="mfp",a="."+u,f="mfp-ready",l="mfp-removing",c="mfp-prevent-close";var h,p=function(){},d=!!window.jQuery,v,m=e(window),g,y,b,w,E;var S=function(e,t){h.ev.on(u+e+a,t)},x=function(t,n,r,i){var s=document.createElement("div");s.className="mfp-"+t;if(r){s.innerHTML=r}if(!i){s=e(s);if(n){s.appendTo(n)}}else if(n){n.appendChild(s)}return s},T=function(t,n){h.ev.triggerHandler(u+t,n);if(h.st.callbacks){t=t.charAt(0).toLowerCase()+t.slice(1);if(h.st.callbacks[t]){h.st.callbacks[t].apply(h,e.isArray(n)?n:[n])}}},N=function(){(h.st.focus?h.content.find(h.st.focus).eq(0):h.wrap).focus()},C=function(t){if(t!==E||!h.currTemplate.closeBtn){h.currTemplate.closeBtn=e(h.st.closeMarkup.replace("%title%",h.st.tClose));E=t}return h.currTemplate.closeBtn},k=function(){if(!e.magnificPopup.instance){h=new p;h.init();e.magnificPopup.instance=h}},L=function(t){if(e(t).hasClass(c)){return}var n=h.st.closeOnContentClick;var r=h.st.closeOnBgClick;if(n&&r){return true}else{if(!h.content||e(t).hasClass("mfp-close")||h.preloader&&t===h.preloader[0]){return true}if(t!==h.content[0]&&!e.contains(h.content[0],t)){if(r){return true}}else if(n){return true}}return false};p.prototype={constructor:p,init:function(){var t=navigator.appVersion;h.isIE7=t.indexOf("MSIE 7.")!==-1;h.isIE8=t.indexOf("MSIE 8.")!==-1;h.isLowIE=h.isIE7||h.isIE8;h.isAndroid=/android/gi.test(t);h.isIOS=/iphone|ipad|ipod/gi.test(t);h.probablyMobile=h.isAndroid||h.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent);g=e(document.body);y=e(document);h.popupsCache={}},open:function(t){var n;if(t.isObj===false){h.items=t.items.toArray();h.index=0;var r=t.items,o;for(n=0;n<r.length;n++){o=r[n];if(o.parsed){o=o.el[0]}if(o===t.el[0]){h.index=n;break}}}else{h.items=e.isArray(t.items)?t.items:[t.items];h.index=t.index||0}if(h.isOpen){h.updateItemHTML();return}h.types=[];w="";h.ev=t.mainEl||y;if(t.key){if(!h.popupsCache[t.key]){h.popupsCache[t.key]={}}h.currTemplate=h.popupsCache[t.key]}else{h.currTemplate={}}h.st=e.extend(true,{},e.magnificPopup.defaults,t);h.fixedContentPos=h.st.fixedContentPos==="auto"?!h.probablyMobile:h.st.fixedContentPos;if(!h.bgOverlay){h.bgOverlay=x("bg").on("click"+a,function(){h.close()});h.wrap=x("wrap").attr("tabindex",-1).on("click"+a,function(e){if(L(e.target)){h.close()}});h.container=x("container",h.wrap)}h.contentContainer=x("content");if(h.st.preloader){h.preloader=x("preloader",h.container,h.st.tLoading)}var u=e.magnificPopup.modules;for(n=0;n<u.length;n++){var l=u[n];l=l.charAt(0).toUpperCase()+l.slice(1);h["init"+l].call(h)}T("BeforeOpen");if(!h.st.closeBtnInside){h.wrap.append(C())}else{S(i,function(e,t,n,r){n.close_replaceWith=C(r.type)});w+=" mfp-close-btn-in"}if(h.st.alignTop){w+=" mfp-align-top"}if(h.fixedContentPos){h.wrap.css({overflow:h.st.overflowY,overflowX:"hidden",overflowY:h.st.overflowY})}else{h.wrap.css({top:m.scrollTop(),position:"absolute"})}if(h.st.fixedBgPos===false||h.st.fixedBgPos==="auto"&&!h.fixedContentPos){h.bgOverlay.css({heightLine truncated
+56 -33
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/ * http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; */ * Copyright (c) 2013 Dmitry Semenov; */
;(function($) { ;(function($) {
@@ -15,6 +15,7 @@
* Private static constants * Private static constants
*/ */
var CLOSE_EVENT = 'Close', var CLOSE_EVENT = 'Close',
AFTER_CLOSE_EVENT = 'AfterClose',
BEFORE_APPEND_EVENT = 'BeforeAppend', BEFORE_APPEND_EVENT = 'BeforeAppend',
MARKUP_PARSE_EVENT = 'MarkupParse', MARKUP_PARSE_EVENT = 'MarkupParse',
OPEN_EVENT = 'Open', OPEN_EVENT = 'Open',
@@ -141,7 +142,7 @@ MagnificPopup.prototype = {
init: function() { init: function() {
var appVersion = navigator.appVersion; var appVersion = navigator.appVersion;
mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1; 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.isLowIE = mfp.isIE7 || mfp.isIE8;
mfp.isAndroid = (/android/gi).test(appVersion); mfp.isAndroid = (/android/gi).test(appVersion);
mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion); mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
@@ -160,23 +161,12 @@ MagnificPopup.prototype = {
*/ */
open: function(data) { open: function(data) {
mfp.items = data.items.length ? data.items : [data.items];
if(mfp.isOpen) {
mfp.updateItemHTML();
return;
}
var i; var i;
mfp.types = []; if(data.isObj === false) {
_wrapClasses = ''; // convert jQuery collection to array to avoid conflicts later
mfp.items = data.items.toArray();
mfp.ev = data.el || _document;
if(data.isObj) {
mfp.index = data.index || 0;
} else {
mfp.index = 0; mfp.index = 0;
var items = data.items, var items = data.items,
item; item;
@@ -190,8 +180,20 @@ MagnificPopup.prototype = {
break; 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(data.key) {
if(!mfp.popupsCache[data.key]) { if(!mfp.popupsCache[data.key]) {
@@ -307,10 +309,12 @@ MagnificPopup.prototype = {
var bodyStyles = {}; var bodyStyles = {};
if( mfp.fixedContentPos ) { if( mfp.fixedContentPos ) {
if(mfp._hasScrollBar(windowHeight)){
var s = mfp._getScrollbarSize(); var s = mfp._getScrollbarSize();
if(s) { if(s) {
bodyStyles.paddingRight = s; bodyStyles.paddingRight = s;
} }
}
} }
if(mfp.fixedContentPos) { if(mfp.fixedContentPos) {
@@ -412,11 +416,11 @@ MagnificPopup.prototype = {
mfp._removeClassFromMFP(classesToRemove); mfp._removeClassFromMFP(classesToRemove);
if(mfp.fixedContentPos) { if(mfp.fixedContentPos) {
var bodyStyles = {paddingRight: 0}; var bodyStyles = {paddingRight: ''};
if(mfp.isIE7) { if(mfp.isIE7) {
$('body, html').css('overflow', 'auto'); $('body, html').css('overflow', '');
} else { } else {
bodyStyles.overflow = 'visible'; bodyStyles.overflow = '';
} }
_body.css(bodyStyles); _body.css(bodyStyles);
} }
@@ -443,6 +447,8 @@ MagnificPopup.prototype = {
mfp.content = null; mfp.content = null;
mfp.currTemplate = null; mfp.currTemplate = null;
mfp.prevHeight = 0; mfp.prevHeight = 0;
_mfpTrigger(AFTER_CLOSE_EVENT);
}, },
updateSize: function(winHeight) { updateSize: function(winHeight) {
@@ -456,6 +462,10 @@ MagnificPopup.prototype = {
} else { } else {
mfp.wH = winHeight || _window.height(); 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'); _mfpTrigger('Resize');
@@ -558,7 +568,6 @@ MagnificPopup.prototype = {
var item = mfp.items[index], var item = mfp.items[index],
type = item.type; type = item.type;
if(item.tagName) { if(item.tagName) {
item = { el: $(item) }; item = { el: $(item) };
} else { } else {
@@ -638,9 +647,16 @@ MagnificPopup.prototype = {
} }
} }
if(e.type) if(e.type) {
e.preventDefault(); 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); options.el = $(e.mfpEl);
if(options.delegate) { if(options.delegate) {
options.items = el.find(options.delegate); options.items = el.find(options.delegate);
@@ -698,12 +714,8 @@ MagnificPopup.prototype = {
mfp.wrap.removeClass(cName); mfp.wrap.removeClass(cName);
}, },
_hasScrollBar: function(winHeight) { _hasScrollBar: function(winHeight) {
if(document.body.clientHeight > (winHeight || _window.height()) ) { return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) )
return true;
}
return false;
}, },
_parseMarkup: function(template, values, item) { _parseMarkup: function(template, values, item) {
var arr; var arr;
if(item.data) { if(item.data) {
@@ -901,6 +913,7 @@ for(i = 0; i < rounds; i++) {
console.log('Test #2:', performance.now() - start); console.log('Test #2:', performance.now() - start);
*/ */
/*>>core*/ /*>>core*/
/*>>inline*/ /*>>inline*/
@@ -943,7 +956,8 @@ $.magnificPopup.registerModule(INLINE_NS, {
if(el.length) { if(el.length) {
// If target element has parent - we replace it with placeholder and put it back after popup is closed // 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) { if(!_inlinePlaceholder) {
_hiddenClass = inlineSt.hiddenClass; _hiddenClass = inlineSt.hiddenClass;
_inlinePlaceholder = _getEl(_hiddenClass); _inlinePlaceholder = _getEl(_hiddenClass);
@@ -1012,10 +1026,14 @@ $.magnificPopup.registerModule(AJAX_NS, {
var opts = $.extend({ var opts = $.extend({
url: item.src, url: item.src,
success: function(data, textStatus, jqXHR) { 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; item.finished = true;
@@ -1029,6 +1047,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
mfp.updateStatus('ready'); mfp.updateStatus('ready');
_mfpTrigger('AjaxContentAdded');
}, },
error: function() { error: function() {
_removeAjaxCursor(); _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) { getIframe: function(item, template) {
@@ -1439,8 +1460,10 @@ $.magnificPopup.registerModule('gallery', {
if(gSt.navigateByImgClick) { if(gSt.navigateByImgClick) {
mfp.wrap.on('click'+ns, '.mfp-img', function() { mfp.wrap.on('click'+ns, '.mfp-img', function() {
if(mfp.items.length > 1) {
mfp.next(); mfp.next();
return false; return false;
}
}); });
} }
@@ -1461,11 +1484,11 @@ $.magnificPopup.registerModule('gallery', {
_mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) { _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
var l = mfp.items.length; 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() { _mfpOn('BuildControls' + ns, function() {
if(gSt.arrows && !mfp.arrowLeft) { if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
var markup = gSt.arrowMarkup, var markup = gSt.arrowMarkup,
arrowLeft = mfp.arrowLeft = $( markup.replace('%title%', gSt.tPrev).replace('%dir%', 'left') ).addClass(PREVENT_CLOSE_CLASS), 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); 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); _document.off(ns);
mfp.wrap.off('click'+ns); mfp.wrap.off('click'+ns);
if(supportsFastClick) { if(mfp.arrowLeft && supportsFastClick) {
mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick(); mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
} }
mfp.arrowRight = mfp.arrowLeft = null; mfp.arrowRight = mfp.arrowLeft = null;
+22 -7
View File
@@ -56,7 +56,21 @@
.mfp-inline-holder .mfp-content, .mfp-inline-holder .mfp-content,
.mfp-ajax-holder .mfp-content { .mfp-ajax-holder .mfp-content {
width: 100%; 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 { .mfp-ajax-cur {
cursor: progress; } cursor: progress; }
@@ -221,22 +235,22 @@ button::-moz-focus-inner {
.border-radius(5px, 5px, 0, 0); } .border-radius(5px, 5px, 0, 0); }
.mfp-arrow-left:after, .mfp-arrow-left:after,
.mfp-arrow-left .mfp-a { .mfp-arrow-left .mfp-a {
border-right: 12px solid white; border-right: 12px solid #fff;
left: 5px; } left: 5px; }
.mfp-arrow-left:before, .mfp-arrow-left:before,
.mfp-arrow-left .mfp-b { .mfp-arrow-left .mfp-b {
border-right: 20px solid white; } border-right: 20px solid #fff; }
.mfp-arrow-right { .mfp-arrow-right {
right: 0; right: 0;
.border-radius(0, 0, 5px, 5px); } .border-radius(0, 0, 5px, 5px); }
.mfp-arrow-right:after, .mfp-arrow-right:after,
.mfp-arrow-right .mfp-a { .mfp-arrow-right .mfp-a {
border-left: 12px solid white; border-left: 12px solid #fff;
left: 3px; } left: 3px; }
.mfp-arrow-right:before, .mfp-arrow-right:before,
.mfp-arrow-right .mfp-b { .mfp-arrow-right .mfp-b {
border-left: 20px solid white; } border-left: 20px solid #fff; }
.mfp-iframe-holder { .mfp-iframe-holder {
padding-top: 40px; padding-top: 40px;
@@ -255,7 +269,8 @@ button::-moz-focus-inner {
.mfp-iframe-scaler iframe { .mfp-iframe-scaler iframe {
position: absolute; position: absolute;
top: -3px; display: block;
top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -263,7 +278,7 @@ button::-moz-focus-inner {
background: black; } background: black; }
.mfp-iframe-holder .mfp-close { .mfp-iframe-holder .mfp-close {
top: -43px; } top: -40px; }
/* Main image in popup */ /* Main image in popup */
img.mfp-img { img.mfp-img {