diff --git a/README.md b/README.md
index 2255f146..c2198c42 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,14 @@ Optionally:
## Changelog
+
+### 0.9.8 (Oct 26, 2013)
+
+- Added figure and figcaption elements to image markup (#233, thanks to @pjackson28).
+- To avoid "jump" of content background, gap from right side (that "replaces" the scrollbar) is added with help of `margin`, instead of `padding`, (closes #125, thanks to @chodorowicz).
+- Function that checks if the clicked element should close popup or not is now public (so it can be overriden with your own logic), e.g. `$.magnificPopup.proto._checkIfClose = function(clickedTarget) { /* your logic, return true if close, clickedTarget is the element that was clicked. */ return true; };`.
+- Working on a new module: the exact copy of native iOS gallery, with touch/zoom/pan e.t.c., will publish branch soon :)
+
### 0.9.7 (Oct 10, 2013)
- CSS: removed outline on buttons (thanks to @OriginalEXE).
diff --git a/bower.json b/bower.json
index 67b2d542..e46a5b9a 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "magnific-popup",
- "version": "0.9.7",
+ "version": "0.9.8",
"main": [
"dist/jquery.magnific-popup.js",
"dist/magnific-popup.css"
diff --git a/dist/jquery.magnific-popup.js b/dist/jquery.magnific-popup.js
index 9157ee29..c74156c0 100644
--- a/dist/jquery.magnific-popup.js
+++ b/dist/jquery.magnific-popup.js
@@ -1,4 +1,4 @@
-/*! Magnific Popup - v0.9.7 - 2013-10-10
+/*! Magnific Popup - v0.9.8 - 2013-10-26
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; */
;(function($) {
@@ -94,41 +94,6 @@ var _mfpOn = function(name, f) {
$.magnificPopup.instance = mfp;
}
},
- // Check to close popup or not
- // "target" is an element that was clicked
- _checkIfClose = function(target) {
-
- if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
- return;
- }
-
- var closeOnContent = mfp.st.closeOnContentClick;
- var closeOnBg = mfp.st.closeOnBgClick;
-
- if(closeOnContent && closeOnBg) {
- return true;
- } else {
-
- // We close the popup if click is on close button or on preloader. Or if there is no content.
- if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
- return true;
- }
-
- // if click is outside the content
- if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
- if(closeOnBg) {
- // last check, if the clicked element is in DOM, (in case it's removed onclick)
- if( $.contains(document, target) ) {
- return true;
- }
- }
- } else if(closeOnContent) {
- return true;
- }
-
- }
- return false;
- },
// CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
supportsTransitions = function() {
var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist
@@ -254,7 +219,7 @@ MagnificPopup.prototype = {
});
mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
- if(_checkIfClose(e.target)) {
+ if(mfp._checkIfClose(e.target)) {
mfp.close();
}
});
@@ -349,7 +314,7 @@ MagnificPopup.prototype = {
if(mfp._hasScrollBar(windowHeight)){
var s = mfp._getScrollbarSize();
if(s) {
- windowStyles.paddingRight = s;
+ windowStyles.marginRight = s;
}
}
}
@@ -379,7 +344,7 @@ MagnificPopup.prototype = {
_mfpTrigger('BuildControls');
- // remove scrollbar, add padding e.t.c
+ // remove scrollbar, add margin e.t.c
$('html').css(windowStyles);
// add everything to DOM
@@ -456,7 +421,7 @@ MagnificPopup.prototype = {
mfp._removeClassFromMFP(classesToRemove);
if(mfp.fixedContentPos) {
- var windowStyles = {paddingRight: ''};
+ var windowStyles = {marginRight: ''};
if(mfp.isIE7) {
$('body, html').css('overflow', '');
} else {
@@ -751,6 +716,41 @@ MagnificPopup.prototype = {
/*
"Private" helpers that aren't private at all
*/
+ // Check to close popup or not
+ // "target" is an element that was clicked
+ _checkIfClose: function(target) {
+
+ if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
+ return;
+ }
+
+ var closeOnContent = mfp.st.closeOnContentClick;
+ var closeOnBg = mfp.st.closeOnBgClick;
+
+ if(closeOnContent && closeOnBg) {
+ return true;
+ } else {
+
+ // We close the popup if click is on close button or on preloader. Or if there is no content.
+ if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
+ return true;
+ }
+
+ // if click is outside the content
+ if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
+ if(closeOnBg) {
+ // last check, if the clicked element is in DOM, (in case it's removed onclick)
+ if( $.contains(document, target) ) {
+ return true;
+ }
+ }
+ } else if(closeOnContent) {
+ return true;
+ }
+
+ }
+ return false;
+ },
_addClassToMFP: function(cName) {
mfp.bgOverlay.addClass(cName);
mfp.wrap.addClass(cName);
@@ -1153,11 +1153,15 @@ $.magnificPopup.registerModule('image', {
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(){t.types.push(q),x("BeforeChange",function(e,t,i){t!==i&&(t===q?K():i===q&&K(!0))}),x(l+"."+q,function(){K()})},getIframe:function(i,n){var o=i.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(n,a,i),t.updateStatus("ready"),n}}});var Y=function(e){var i=t.items.length;return e>i-1?e-i:0>e?i+e:e},U=function(e,t,i){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,i)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var i=t.st.gallery,n=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,i&&i.enabled?(a+=" mfp-gallery",x(f+n,function(){i.navigateByImgClick&&t.wrap.on("click"+n,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+n,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+n,function(e,i){i.text&&(i.text=U(i.text,t.currItem.index,t.items.length))}),x(p+n,function(e,n,o,r){var a=t.items.length;o.counter=a>1?U(i.tCounter,r.index,a):""}),x("BuildControls"+n,function(){if(t.items.length>1&&i.arrows&&!t.arrowLeft){var n=i.arrowMarkup,o=t.arrowLeft=e(n.replace(/%title%/gi,i.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(n.replace(/%title%/gi,i.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+n,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+n,function(){o.off(n),t.wrap.off("click"+n),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=Y(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=Y(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,i=t.st.gallery.preload,n=Math.min(i[0],t.items.length),o=Math.min(i[1],t.items.length);for(e=1;(t.direction?o:n)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?n:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(i){if(i=Y(i),!t.items[i].preloaded){var n=t.items[i];n.parsed||(n=t.parseEl(i)),T("LazyLoad",n),"image"===n.type&&(n.img=e('').on("load.mfploader",function(){n.hasSize=!0}).on("error.mfploader",function(){n.hasSize=!0,n.loadError=!0,T("LazyLoadError",n)}).attr("src",n.src)),n.preloaded=!0}}}});var G="retina";e.magnificPopup.registerModule(G,{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=t.st.retina,i=e.ratio;i=isNaN(i)?i():i,i>1&&(x("ImageHasSize."+G,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/i,width:"100%"})}),x("ElementParse."+G,function(t,n){n.src=e.replaceSrc(n,i)}))}}}}),function(){var t=1e3,i="ontouchstart"in window,n=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(i){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,n())}).on("touchend"+r,function(e){n(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),i&&I.off("touchmove"+r+" touchend"+r)}}()})(window.jQuery||window.Zepto);
\ No newline at end of file
diff --git a/magnific-popup.jquery.json b/magnific-popup.jquery.json
index 8eff462d..18839376 100644
--- a/magnific-popup.jquery.json
+++ b/magnific-popup.jquery.json
@@ -2,7 +2,7 @@
"name": "magnific-popup",
"title": "Magnific Popup",
"description": "Fast, light, mobile-friendly and responsive lightbox and modal dialog plugin. Open inline HTML, ajax loaded content, image, form, iframe (YouTube video, Vimeo, Google Maps), photo gallery. In/out animation effects are added with CSS3 transitions.",
- "version": "0.9.7",
+ "version": "0.9.8",
"homepage": "http://dimsemenov.com/plugins/magnific-popup/",
"demo": "http://dimsemenov.com/plugins/magnific-popup/",
"docs": "http://dimsemenov.com/plugins/magnific-popup/documentation.html",
diff --git a/website/documentation.md b/website/documentation.md
index f5db377a..164fa9af 100644
--- a/website/documentation.md
+++ b/website/documentation.md
@@ -641,7 +641,7 @@ Markup of close button. %title% will be replaced with option `tClose`.
## Gallery
-Basically all galery module does is allows you to switch content of popup and adds navigation arrows. It can switch and mix any types of content, not just images.
+Basically all galery module does is allows you to switch content of popup and adds navigation arrows. It can switch and mix any types of content, not just images. Gallery options:
{% highlight javascript %}
gallery: {
@@ -659,20 +659,48 @@ gallery: {
}
{% endhighlight %}
+Example:
+
+{% highlight javascript %}
+// This will create a single gallery from all elements that have class "gallery-item"
+$('.gallery-item').magnificPopup({
+ type: 'image',
+ gallery:{
+ enabled:true
+ }
+});
+{% endhighlight %}
+
### Multiple galleries
-To have multiple galleries on a page, you need to create a new instance of Magnific Popup for each seperate gallery. The below example can be used:
+To have multiple galleries on a page, you need to create a new instance of Magnific Popup for each seperate gallery. For example
+
+{% highlight html %}
+
+{% endhighlight %}
{% highlight javascript %}
-$('.gallery').each(function() { // the containers for all your galleries should have the class gallery
+$('.gallery').each(function() { // the containers for all your galleries
$(this).magnificPopup({
- delegate: 'a', // the container for each your gallery items
+ delegate: 'a', // the selector for gallery item
type: 'image',
- gallery:{enabled:true}
+ gallery: {
+ enabled:true
+ }
});
});
{% endhighlight %}
+You don't necessarily need to use `delegate` option, it can be just `$(this).find('a').magnificPopup( ...`.
+
### Lazy-loading
Lazy-loading option preloads nearby items. It accepts array with two integers, first one - is a number of items to preload before the current, second one - the number of images to preload after the current. For example `preload: [1,3]` will load 3 next items and 1 that is before current. These values are automatically switched based on direction of movement.
@@ -1125,6 +1153,17 @@ $('.some-button').magnificPopup({
See [example on CodePen](http://codepen.io/dimsemenov/pen/JGjHK).
+### How to override some function without modifying the source files?
+
+Rewrite the function that you wish to modify in Magnific Popup class prototype object, for example to override function that sets focus on some element (add this code after popup JS file is included, but before popup is initialized):
+
+{% highlight javascript %}
+$.magnificPopup.proto._setFocus = function() {
+ (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
+};
+{% endhighlight %}
+
+
Make Magnific Popup better!
Improve this documentation page via GitHub (simply submit commit). Any improvements, including your own CodePen examples are very welcome.