From 94b9385c1240b2343ebda0a1ed752810b785f64e Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Tue, 4 Jun 2013 11:19:59 -0400 Subject: [PATCH] Update Magnific Popup to version 0.8.9 --- _posts/2013-05-22-sample-post-images.md | 4 +- assets/css/main.css | 27 ++++-- assets/js/main.js | 105 +++++++++++++--------- assets/js/main.min.js | 2 +- assets/js/vendor/jquery.magnific-popup.js | 105 +++++++++++++--------- assets/less/magnific-popup.less | 29 ++++-- 6 files changed, 174 insertions(+), 98 deletions(-) diff --git a/_posts/2013-05-22-sample-post-images.md b/_posts/2013-05-22-sample-post-images.md index b61aec9c..0fd0f0e4 100644 --- a/_posts/2013-05-22-sample-post-images.md +++ b/_posts/2013-05-22-sample-post-images.md @@ -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:
- - + +
Two images.
diff --git a/assets/css/main.css b/assets/css/main.css index 74eb156b..04b92613 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -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 { diff --git a/assets/js/main.js b/assets/js/main.js index b50fdfe4..98293067 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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; diff --git a/assets/js/main.min.js b/assets/js/main.min.js index b198a842..69f1551c 100644 --- a/assets/js/main.min.js +++ b/assets/js/main.min.js @@ -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="­";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('
').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(e||v.height())){return true}return false},_parseMarkup:function(t,n,i){var s;if(i.data){n=e.extend(i.data,n)}x(r,[t,n,i]);e.each(n,function(e,n){if(n===undefined||n===false){return true}s=e.split("_");if(s.length>1){var r=t.find(u+"-"+s[0]);if(r.length>0){var i=s[1];if(i==="replaceWith"){if(r[0]!==n[0]){r.replaceWith(n)}}else if(i==="img"){if(r.is("img")){r.attr("src",n)}else{r.replaceWith('')}}else{r.attr(s[1],n)}}}else{t.find(u+"-"+e).html(n)}})},_getScrollbarSize:function(){if(c.scrollbarSize===undefined){var e=document.createElement("div");e.id="mfp-sbm";e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;";document.body.appendChild(e);c.scrollbarSize=e.offsetWidth-e.clientWidth;document.body.removeChild(e)}return c.scrollbarSize}};e.magnificPopup={instance:null,proto:h.prototype,modules:[],open:function(e,t){C();if(!e)e={};e.isObj=true;e.index=t||0;return this.instance.open(e)},close:function(){return e.magnificPopup.instance.close()},registerModule:function(t,n){if(n.options){e.magnificPopup.defaults[t]=n.options}e.extend(this.proto,n.proto);this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:false,mainClass:"",preloader:true,focus:"",closeOnContentClick:false,closeOnBgClick:true,closeBtnInside:true,alignTop:false,removalDelay:0,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading..."}};e.fn.magnificPopup=function(t){C();var n=e(this);if(typeof t==="string"){if(t==="open"){var r,i=p?n.data("magnificPopup"):n[0].magnificPopup,s=parseInt(arguments[1],10)||0;if(i.items){r=i.items[s]}else{r=n;if(i.delegate){r=r.find(i.delegate)}r=r.eq(s)}c._openClick({mfpEl:r},n,i)}else{if(c.isOpen)c[t].apply(c,Array.prototype.slice.call(arguments,1))}}else{if(p){n.data("magnificPopup",t)}else{n[0].magnificPopup=t}c.addGroup(n,t)}return n};var L="inline",A,O,M,_=function(){if(M){O.after(M.addClass(A)).detach();M=null}};e.magnificPopup.registerModule(L,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){c.types.push(L);E(t+"."+L,function(){_()})},getInline:function(t,n){_();if(t.src){var r=c.st.inline,i=e(t.src);if(i.length){if(i[0].parentNode!==null){if(!O){A=r.hiddenClass;O=S(A);A="mfp-"+A}M=i.after(O).detach().removeClass(A)}c.updateStatus("ready")}else{c.updateStatus("error",r.tNotFound);i=e("
")}t.inlineElement=i;return i}c.updateStatus("ready");c._parseMarkup(n,{},t);return n}}});var D="ajax",P,H=function(){if(P){m.removeClass(P)}};e.magnificPopup.registerModule(D,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){c.types.push(D);P=c.st.ajax.cursor;E(t+"."+D,function(){H();if(c.req){c.req.abort()}})},getAjax:function(t){if(P)m.addClass(P);c.updateStatus("loading");var n=e.extend({url:t.src,success:function(n,r,i){x("ParseAjax",i);c.appendContent(e(i.responseText),D);t.finished=true;H();T();setTimeout(function(){c.wrap.addClass(a)},16);c.updateStatus("ready")},error:function(){H();t.finished=t.loadError=true;c.updateStatus("error",c.st.ajax.tError.replace("%url%",t.src))}},c.st.ajax.settings);c.req=e.ajax(n);return""}}});var B,j=function(t){if(t.data&&t.data.title!==undefined)return t.data.title;var n=c.st.image.titleSrc;if(n){if(e.isFunction(n)){return n.call(c,t)}else if(t.el){return t.el.attr(n)||""}}return""};e.magnificPopup.registerModule("image",{options:{markup:'
'+'
'+'
'+'
'+'
'+'
'+"
"+"
",cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:true,tError:'The image could not be loaded.'},proto:{initImage:function(){var e=c.st.image,n=".image";c.types.push("image");E(i+n,function(){if(c.currItem.type==="image"&&e.cursor){m.addClass(e.cursor)}});E(t+n,function(){if(e.cursor){m.removeClass(e.cursor)}v.off("resize"+u)});E("Resize"+n,c.resizeImage);if(c.isLowIE){E("AfterChange",c.resizeImage)}},resizeImage:function(){var e=c.currItem;if(!e.img)return;if(c.st.image.verticalFit){var t=0;if(c.isLowIE){t=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)}e.img.css("max-height",c.wH-t)}},_onImageHasSize:function(e){if(e.img){e.hasSize=true;if(B){clearInterval(B)}e.isCheckingImgSize=false;x("ImageHasSize",e);if(e.imgHidden){if(c.content)c.content.removeClass("mfp-loading");e.imgHidden=false}}},findImageSize:function(e){var t=0,n=e.img[0],r=function(i){if(B){clearInterval(B)}B=setInterval(function(){if(n.naturalWidth>0){c._onImageHasSize(e);return}if(t>200){clearInterval(B)}t++;if(t===3){r(10)}else if(t===40){r(50)}else if(t===100){r(500)}},i)};r(1)},getImage:function(t,n){var r=0,i=function(){if(t){if(t.img[0].complete){t.img.off(".mfploader");if(t===c.currItem){c._onImageHasSize(t);c.updateStatus("ready")}t.hasSize=true;t.loaded=true}else{r++;if(r<200){setTimeout(i,100)}else{s()}}}},s=function(){if(t){t.img.off(".mfploader");if(t===c.currItem){c._onImageHasSize(t);c.updateStatus("error",o.tError.replace("%url%",t.src))}t.hasSize=true;t.loaded=true;t.loadError=true}},o=c.st.image;var u=n.find(".mfp-img");if(u.length){var a=new Image;a.className="mfp-img";t.img=e(a).on("load.mfploader",i).on("error.mfploader",s);a.src=t.src;if(u.is("img")){t.img=t.img.clone()}}c._parseMarkup(n,{title:j(t),img_replaceWith:t.img},t);c.resizeImage();if(t.hasSize){if(B)clearInterval(B);if(t.loadError){n.addClass("mfp-loading");c.updateStatus("error",o.tError.replace("%url%",t.src))}else{n.removeClass("mfp-loading");c.updateStatus("ready")}return n}c.updateStatus("loading");t.loading=true;if(!t.hasSize){t.imgHidden=true;n.addClass("mfp-loading");c.findImageSize(t)}return n}}});var F="iframe",I="//about:blank",q=function(e){if(c.currTemplate[F]){var t=c.currTemplate[F].find("iframe");if(t.length){if(!e){t[0].src=I}if(c.isIE8){t.css("display",e?"block":"none")}}}};e.magnificPopup.registerModule(F,{options:{markup:'
'+'
'+''+"
",srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){c.types.push(F);E("BeforeChange",function(e,t,n){if(t!==n){if(t===F){q()}else if(n===F){q(true)}}});E(t+"."+F,q)},getIframe:function(t,n){var r=t.src;var i=c.st.iframe;e.each(i.patterns,function(){if(r.indexOf(this.index)>-1){if(this.id){if(typeof this.id==="string"){r=r.substr(r.lastIndexOf(this.id)+this.id.length,r.length)}else{r=this.id.call(this,r)}}r=this.src.replace("%id%",r);return false}});var s={};if(i.srcAction){s[i.srcAction]=r}c._parseMarkup(n,s,t);c.updateStatus("ready");return n}}});var R=function(e){var t=c.items.length;if(e>t-1){return e-t}else if(e<0){return t+e}return e},U=function(e,t,n){return e.replace("%curr%",t+1).replace("%total%",n)};e.magnificPopup.registerModule("gallery",{options:{enabled:false,arrowMarkup:'',preload:[0,2],navigateByImgClick:true,arrows:true,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=c.st.gallery,o=".mfp-gallery",u=Boolean(e.fn.mfpFastClick);c.direction=true;if(!n||!n.enabled)return false;b+=" mfp-gallery";E(i+o,function(){if(n.navigateByImgClick){c.wrap.on("click"+o,".mfp-img",function(){c.next();return false})}g.on("keydown"+o,function(e){if(e.keyCode===37){c.prev()}else if(e.keyCode===39){c.next()}})});E("UpdateStatus"+o,function(e,t){if(t.text){t.text=U(t.text,c.currItem.index,c.items.length)}});E(r+o,function(e,t,r,i){var s=c.items.length;r.counter=s?U(n.tCounter,i.index,s):""});E("BuildControls"+o,function(){if(n.arrows&&!c.arrowLeft){var t=n.arrowMarkup,r=c.arrowLeft=e(t.replace("%title%",n.tPrev).replace("%dir%","left")).addClass(l),i=c.arrowRight=e(t.replace("%title%",n.tNext).replace("%dir%","right")).addClass(l);var s=u?"mfpFastClick":"click";r[s](function(){c.prev()});i[s](function(){c.next()});if(c.isIE7){S("b",r[0],false,true);S("a",r[0],false,true);S("b",i[0],false,true);S("a",i[0],false,true)}c.container.append(r.add(i))}});E(s+o,function(){if(c._preloadTimeout)clearTimeout(c._preloadTimeout);c._preloadTimeout=setTimeout(function(){c.preloadNearbyImages();c._preloadTimeout=null},16)});E(t+o,function(){g.off(o);c.wrap.off("click"+o);if(u){c.arrowLeft.add(c.arrowRight).destroyMfpFastClick()}c.arrowRight=c.arrowLeft=null})},next:function(){c.direction=true;c.index=R(c.index+1);c.updateItemHTML()},prev:function(){c.direction=false;c.index=R(c.index-1);c.updateItemHTML()},goTo:function(e){c.direction=e>=c.index;c.index=e;c.updateItemHTML()},preloadNearbyImages:function(){var e=c.st.gallery.preload,t=Math.min(e[0],c.items.length),n=Math.min(e[1],c.items.length),r;for(r=1;r<=(c.direction?n:t);r++){c._preloadItem(c.index+r)}for(r=1;r<=(c.direction?t:n);r++){c._preloadItem(c.index-r)}},_preloadItem:function(t){t=R(t);if(c.items[t].preloaded){return}var n=c.items[t];if(!n.parsed){n=c.parseEl(t)}x("LazyLoad",n);if(n.type==="image"){n.img=e('').on("load.mfploader",function(){n.hasSize=true}).on("error.mfploader",function(){n.hasSize=true;n.loadError=true}).attr("src",n.src)}n.preloaded=true}}});var z="retina";e.magnificPopup.registerModule(z,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=c.st.retina,t=e.ratio;t=!isNaN(t)?t:t();if(t>1){E("ImageHasSize"+"."+z,function(e,n){n.img.css({"max-width":n.img[0].naturalWidth/t,width:"100%"})});E("ElementParse"+"."+z,function(n,r){r.src=e.replaceSrc(r,t)})}}}}});(function(){var t=1e3,n="ontouchstart"in window,r=function(){v.off("touchmove"+s+" touchend"+s)},i="mfpFastClick",s="."+i;e.fn.mfpFastClick=function(i){return e(this).each(function(){var o=e(this),u;if(n){var a,f,l,c,h,p;o.on("touchstart"+s,function(e){c=false;p=1;h=e.originalEvent?e.originalEvent.touches[0]:e.touches[0];f=h.clientX;l=h.clientY;v.on("touchmove"+s,function(e){h=e.originalEvent?e.originalEvent.touches:e.touches;p=h.length;h=h[0];if(Math.abs(h.clientX-f)>10||Math.abs(h.clientY-l)>10){c=true;r()}}).on("touchend"+s,function(e){r();if(c||p>1){return}u=true;e.preventDefault();clearTimeout(a);a=setTimeout(function(){u=false},t);i()})})}o.on("click"+s,function(){if(!u){i()}})})};e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+s+" click"+s);if(n)v.off("touchmove"+s+" touchend"+s)}})()})(window.jQuery||window.Zepto);$(function(){$("article").fitVids()});$(function(){$(".toc h3").click(function(){$("#drawer").toggleClass("hidden")})});$("a[href$='.jpg'],a[href$='.png'],a[href$='.gif']").addClass("image-popup");$(document).ready(function(){$(".image-popup").magnificPopup({type:"image",tLoading:"Loading image #%curr%...",gallery:{enabled:true,navigateByImgClick:true,preload:[0,1]},image:{tError:'Image #%curr% could not be loaded.'},removalDelay:300,mainClass:"mfp-fade"})}) \ No newline at end of file +(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="­";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('
').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(e||m.height())},_parseMarkup:function(t,n,r){var s;if(r.data){n=e.extend(r.data,n)}T(i,[t,n,r]);e.each(n,function(e,n){if(n===undefined||n===false){return true}s=e.split("_");if(s.length>1){var r=t.find(a+"-"+s[0]);if(r.length>0){var i=s[1];if(i==="replaceWith"){if(r[0]!==n[0]){r.replaceWith(n)}}else if(i==="img"){if(r.is("img")){r.attr("src",n)}else{r.replaceWith('')}}else{r.attr(s[1],n)}}}else{t.find(a+"-"+e).html(n)}})},_getScrollbarSize:function(){if(h.scrollbarSize===undefined){var e=document.createElement("div");e.id="mfp-sbm";e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;";document.body.appendChild(e);h.scrollbarSize=e.offsetWidth-e.clientWidth;document.body.removeChild(e)}return h.scrollbarSize}};e.magnificPopup={instance:null,proto:p.prototype,modules:[],open:function(e,t){k();if(!e)e={};e.isObj=true;e.index=t||0;return this.instance.open(e)},close:function(){return e.magnificPopup.instance.close()},registerModule:function(t,n){if(n.options){e.magnificPopup.defaults[t]=n.options}e.extend(this.proto,n.proto);this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:false,mainClass:"",preloader:true,focus:"",closeOnContentClick:false,closeOnBgClick:true,closeBtnInside:true,alignTop:false,removalDelay:0,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading..."}};e.fn.magnificPopup=function(t){k();var n=e(this);if(typeof t==="string"){if(t==="open"){var r,i=d?n.data("magnificPopup"):n[0].magnificPopup,s=parseInt(arguments[1],10)||0;if(i.items){r=i.items[s]}else{r=n;if(i.delegate){r=r.find(i.delegate)}r=r.eq(s)}h._openClick({mfpEl:r},n,i)}else{if(h.isOpen)h[t].apply(h,Array.prototype.slice.call(arguments,1))}}else{if(d){n.data("magnificPopup",t)}else{n[0].magnificPopup=t}h.addGroup(n,t)}return n};var A="inline",O,M,_,D=function(){if(_){M.after(_.addClass(O)).detach();_=null}};e.magnificPopup.registerModule(A,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){h.types.push(A);S(t+"."+A,function(){D()})},getInline:function(t,n){D();if(t.src){var r=h.st.inline,i=e(t.src);if(i.length){var s=i[0].parentNode;if(s&&s.tagName){if(!M){O=r.hiddenClass;M=x(O);O="mfp-"+O}_=i.after(M).detach().removeClass(O)}h.updateStatus("ready")}else{h.updateStatus("error",r.tNotFound);i=e("
")}t.inlineElement=i;return i}h.updateStatus("ready");h._parseMarkup(n,{},t);return n}}});var P="ajax",H,B=function(){if(H){g.removeClass(H)}};e.magnificPopup.registerModule(P,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){h.types.push(P);H=h.st.ajax.cursor;S(t+"."+P,function(){B();if(h.req){h.req.abort()}})},getAjax:function(t){if(H)g.addClass(H);h.updateStatus("loading");var n=e.extend({url:t.src,success:function(n,r,i){var s={data:n,xhr:i};T("ParseAjax",s);h.appendContent(e(s.data),P);t.finished=true;B();N();setTimeout(function(){h.wrap.addClass(f)},16);h.updateStatus("ready");T("AjaxContentAdded")},error:function(){B();t.finished=t.loadError=true;h.updateStatus("error",h.st.ajax.tError.replace("%url%",t.src))}},h.st.ajax.settings);h.req=e.ajax(n);return""}}});var j,F=function(t){if(t.data&&t.data.title!==undefined)return t.data.title;var n=h.st.image.titleSrc;if(n){if(e.isFunction(n)){return n.call(h,t)}else if(t.el){return t.el.attr(n)||""}}return""};e.magnificPopup.registerModule("image",{options:{markup:'
'+'
'+'
'+'
'+'
'+'
'+"
"+"
",cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:true,tError:'The image could not be loaded.'},proto:{initImage:function(){var e=h.st.image,n=".image";h.types.push("image");S(s+n,function(){if(h.currItem.type==="image"&&e.cursor){g.addClass(e.cursor)}});S(t+n,function(){if(e.cursor){g.removeClass(e.cursor)}m.off("resize"+a)});S("Resize"+n,h.resizeImage);if(h.isLowIE){S("AfterChange",h.resizeImage)}},resizeImage:function(){var e=h.currItem;if(!e.img)return;if(h.st.image.verticalFit){var t=0;if(h.isLowIE){t=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)}e.img.css("max-height",h.wH-t)}},_onImageHasSize:function(e){if(e.img){e.hasSize=true;if(j){clearInterval(j)}e.isCheckingImgSize=false;T("ImageHasSize",e);if(e.imgHidden){if(h.content)h.content.removeClass("mfp-loading");e.imgHidden=false}}},findImageSize:function(e){var t=0,n=e.img[0],r=function(i){if(j){clearInterval(j)}j=setInterval(function(){if(n.naturalWidth>0){h._onImageHasSize(e);return}if(t>200){clearInterval(j)}t++;if(t===3){r(10)}else if(t===40){r(50)}else if(t===100){r(500)}},i)};r(1)},getImage:function(t,n){var r=0,i=function(){if(t){if(t.img[0].complete){t.img.off(".mfploader");if(t===h.currItem){h._onImageHasSize(t);h.updateStatus("ready")}t.hasSize=true;t.loaded=true}else{r++;if(r<200){setTimeout(i,100)}else{s()}}}},s=function(){if(t){t.img.off(".mfploader");if(t===h.currItem){h._onImageHasSize(t);h.updateStatus("error",o.tError.replace("%url%",t.src))}t.hasSize=true;t.loaded=true;t.loadError=true}},o=h.st.image;var u=n.find(".mfp-img");if(u.length){var a=new Image;a.className="mfp-img";t.img=e(a).on("load.mfploader",i).on("error.mfploader",s);a.src=t.src;if(u.is("img")){t.img=t.img.clone()}}h._parseMarkup(n,{title:F(t),img_replaceWith:t.img},t);h.resizeImage();if(t.hasSize){if(j)clearInterval(j);if(t.loadError){n.addClass("mfp-loading");h.updateStatus("error",o.tError.replace("%url%",t.src))}else{n.removeClass("mfp-loading");h.updateStatus("ready")}return n}h.updateStatus("loading");t.loading=true;if(!t.hasSize){t.imgHidden=true;n.addClass("mfp-loading");h.findImageSize(t)}return n}}});var I="iframe",q="//about:blank",R=function(e){if(h.currTemplate[I]){var t=h.currTemplate[I].find("iframe");if(t.length){if(!e){t[0].src=q}if(h.isIE8){t.css("display",e?"block":"none")}}}};e.magnificPopup.registerModule(I,{options:{markup:'
'+'
'+''+"
",srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){h.types.push(I);S("BeforeChange",function(e,t,n){if(t!==n){if(t===I){R()}else if(n===I){R(true)}}});S(t+"."+I,function(){R()})},getIframe:function(t,n){var r=t.src;var i=h.st.iframe;e.each(i.patterns,function(){if(r.indexOf(this.index)>-1){if(this.id){if(typeof this.id==="string"){r=r.substr(r.lastIndexOf(this.id)+this.id.length,r.length)}else{r=this.id.call(this,r)}}r=this.src.replace("%id%",r);return false}});var s={};if(i.srcAction){s[i.srcAction]=r}h._parseMarkup(n,s,t);h.updateStatus("ready");return n}}});var U=function(e){var t=h.items.length;if(e>t-1){return e-t}else if(e<0){return t+e}return e},z=function(e,t,n){return e.replace("%curr%",t+1).replace("%total%",n)};e.magnificPopup.registerModule("gallery",{options:{enabled:false,arrowMarkup:'',preload:[0,2],navigateByImgClick:true,arrows:true,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=h.st.gallery,r=".mfp-gallery",u=Boolean(e.fn.mfpFastClick);h.direction=true;if(!n||!n.enabled)return false;w+=" mfp-gallery";S(s+r,function(){if(n.navigateByImgClick){h.wrap.on("click"+r,".mfp-img",function(){if(h.items.length>1){h.next();return false}})}y.on("keydown"+r,function(e){if(e.keyCode===37){h.prev()}else if(e.keyCode===39){h.next()}})});S("UpdateStatus"+r,function(e,t){if(t.text){t.text=z(t.text,h.currItem.index,h.items.length)}});S(i+r,function(e,t,r,i){var s=h.items.length;r.counter=s>1?z(n.tCounter,i.index,s):""});S("BuildControls"+r,function(){if(h.items.length>1&&n.arrows&&!h.arrowLeft){var t=n.arrowMarkup,r=h.arrowLeft=e(t.replace("%title%",n.tPrev).replace("%dir%","left")).addClass(c),i=h.arrowRight=e(t.replace("%title%",n.tNext).replace("%dir%","right")).addClass(c);var s=u?"mfpFastClick":"click";r[s](function(){h.prev()});i[s](function(){h.next()});if(h.isIE7){x("b",r[0],false,true);x("a",r[0],false,true);x("b",i[0],false,true);x("a",i[0],false,true)}h.container.append(r.add(i))}});S(o+r,function(){if(h._preloadTimeout)clearTimeout(h._preloadTimeout);h._preloadTimeout=setTimeout(function(){h.preloadNearbyImages();h._preloadTimeout=null},16)});S(t+r,function(){y.off(r);h.wrap.off("click"+r);if(h.arrowLeft&&u){h.arrowLeft.add(h.arrowRight).destroyMfpFastClick()}h.arrowRight=h.arrowLeft=null})},next:function(){h.direction=true;h.index=U(h.index+1);h.updateItemHTML()},prev:function(){h.direction=false;h.index=U(h.index-1);h.updateItemHTML()},goTo:function(e){h.direction=e>=h.index;h.index=e;h.updateItemHTML()},preloadNearbyImages:function(){var e=h.st.gallery.preload,t=Math.min(e[0],h.items.length),n=Math.min(e[1],h.items.length),r;for(r=1;r<=(h.direction?n:t);r++){h._preloadItem(h.index+r)}for(r=1;r<=(h.direction?t:n);r++){h._preloadItem(h.index-r)}},_preloadItem:function(t){t=U(t);if(h.items[t].preloaded){return}var n=h.items[t];if(!n.parsed){n=h.parseEl(t)}T("LazyLoad",n);if(n.type==="image"){n.img=e('').on("load.mfploader",function(){n.hasSize=true}).on("error.mfploader",function(){n.hasSize=true;n.loadError=true}).attr("src",n.src)}n.preloaded=true}}});var W="retina";e.magnificPopup.registerModule(W,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=h.st.retina,t=e.ratio;t=!isNaN(t)?t:t();if(t>1){S("ImageHasSize"+"."+W,function(e,n){n.img.css({"max-width":n.img[0].naturalWidth/t,width:"100%"})});S("ElementParse"+"."+W,function(n,r){r.src=e.replaceSrc(r,t)})}}}}});(function(){var t=1e3,n="ontouchstart"in window,r=function(){m.off("touchmove"+s+" touchend"+s)},i="mfpFastClick",s="."+i;e.fn.mfpFastClick=function(i){return e(this).each(function(){var o=e(this),u;if(n){var a,f,l,c,h,p;o.on("touchstart"+s,function(e){c=false;p=1;h=e.originalEvent?e.originalEvent.touches[0]:e.touches[0];f=h.clientX;l=h.clientY;m.on("touchmove"+s,function(e){h=e.originalEvent?e.originalEvent.touches:e.touches;p=h.length;h=h[0];if(Math.abs(h.clientX-f)>10||Math.abs(h.clientY-l)>10){c=true;r()}}).on("touchend"+s,function(e){r();if(c||p>1){return}u=true;e.preventDefault();clearTimeout(a);a=setTimeout(function(){u=false},t);i()})})}o.on("click"+s,function(){if(!u){i()}})})};e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+s+" click"+s);if(n)m.off("touchmove"+s+" touchend"+s)}})()})(window.jQuery||window.Zepto);$(function(){$("article").fitVids()});$(function(){$(".toc h3").click(function(){$("#drawer").toggleClass("hidden")})});$("a[href$='.jpg'],a[href$='.png'],a[href$='.gif']").addClass("image-popup");$(document).ready(function(){$(".image-popup").magnificPopup({type:"image",tLoading:"Loading image #%curr%...",gallery:{enabled:true,navigateByImgClick:true,preload:[0,1]},image:{tError:'Image #%curr% could not be loaded.'},removalDelay:300,mainClass:"mfp-fade"})}) \ No newline at end of file diff --git a/assets/js/vendor/jquery.magnific-popup.js b/assets/js/vendor/jquery.magnific-popup.js index 4541d3cc..c0fa0892 100644 --- a/assets/js/vendor/jquery.magnific-popup.js +++ b/assets/js/vendor/jquery.magnific-popup.js @@ -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; diff --git a/assets/less/magnific-popup.less b/assets/less/magnific-popup.less index c968f9de..f65a6a69 100644 --- a/assets/less/magnific-popup.less +++ b/assets/less/magnific-popup.less @@ -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 {