Skip to content

Commit 0a53aaa

Browse files
committed
0.9.8
1 parent 8afdb9e commit 0a53aaa

File tree

6 files changed

+105
-54
lines changed

6 files changed

+105
-54
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Optionally:
4141

4242
## Changelog
4343

44+
45+
### 0.9.8 (Oct 26, 2013)
46+
47+
- Added figure and figcaption elements to image markup (#233, thanks to @pjackson28).
48+
- 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).
49+
- 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; };`.
50+
- Working on a new module: the exact copy of native iOS gallery, with touch/zoom/pan e.t.c., will publish branch soon :)
51+
4452
### 0.9.7 (Oct 10, 2013)
4553

4654
- CSS: removed outline on buttons (thanks to @OriginalEXE).

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "magnific-popup",
3-
"version": "0.9.7",
3+
"version": "0.9.8",
44
"main": [
55
"dist/jquery.magnific-popup.js",
66
"dist/magnific-popup.css"

dist/jquery.magnific-popup.js

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Magnific Popup - v0.9.7 - 2013-10-10
1+
/*! Magnific Popup - v0.9.8 - 2013-10-26
22
* http://dimsemenov.com/plugins/magnific-popup/
33
* Copyright (c) 2013 Dmitry Semenov; */
44
;(function($) {
@@ -94,41 +94,6 @@ var _mfpOn = function(name, f) {
9494
$.magnificPopup.instance = mfp;
9595
}
9696
},
97-
// Check to close popup or not
98-
// "target" is an element that was clicked
99-
_checkIfClose = function(target) {
100-
101-
if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
102-
return;
103-
}
104-
105-
var closeOnContent = mfp.st.closeOnContentClick;
106-
var closeOnBg = mfp.st.closeOnBgClick;
107-
108-
if(closeOnContent && closeOnBg) {
109-
return true;
110-
} else {
111-
112-
// We close the popup if click is on close button or on preloader. Or if there is no content.
113-
if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
114-
return true;
115-
}
116-
117-
// if click is outside the content
118-
if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
119-
if(closeOnBg) {
120-
// last check, if the clicked element is in DOM, (in case it's removed onclick)
121-
if( $.contains(document, target) ) {
122-
return true;
123-
}
124-
}
125-
} else if(closeOnContent) {
126-
return true;
127-
}
128-
129-
}
130-
return false;
131-
},
13297
// CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
13398
supportsTransitions = function() {
13499
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 = {
254219
});
255220

256221
mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
257-
if(_checkIfClose(e.target)) {
222+
if(mfp._checkIfClose(e.target)) {
258223
mfp.close();
259224
}
260225
});
@@ -349,7 +314,7 @@ MagnificPopup.prototype = {
349314
if(mfp._hasScrollBar(windowHeight)){
350315
var s = mfp._getScrollbarSize();
351316
if(s) {
352-
windowStyles.paddingRight = s;
317+
windowStyles.marginRight = s;
353318
}
354319
}
355320
}
@@ -379,7 +344,7 @@ MagnificPopup.prototype = {
379344
_mfpTrigger('BuildControls');
380345

381346

382-
// remove scrollbar, add padding e.t.c
347+
// remove scrollbar, add margin e.t.c
383348
$('html').css(windowStyles);
384349

385350
// add everything to DOM
@@ -456,7 +421,7 @@ MagnificPopup.prototype = {
456421
mfp._removeClassFromMFP(classesToRemove);
457422

458423
if(mfp.fixedContentPos) {
459-
var windowStyles = {paddingRight: ''};
424+
var windowStyles = {marginRight: ''};
460425
if(mfp.isIE7) {
461426
$('body, html').css('overflow', '');
462427
} else {
@@ -751,6 +716,41 @@ MagnificPopup.prototype = {
751716
/*
752717
"Private" helpers that aren't private at all
753718
*/
719+
// Check to close popup or not
720+
// "target" is an element that was clicked
721+
_checkIfClose: function(target) {
722+
723+
if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
724+
return;
725+
}
726+
727+
var closeOnContent = mfp.st.closeOnContentClick;
728+
var closeOnBg = mfp.st.closeOnBgClick;
729+
730+
if(closeOnContent && closeOnBg) {
731+
return true;
732+
} else {
733+
734+
// We close the popup if click is on close button or on preloader. Or if there is no content.
735+
if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
736+
return true;
737+
}
738+
739+
// if click is outside the content
740+
if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
741+
if(closeOnBg) {
742+
// last check, if the clicked element is in DOM, (in case it's removed onclick)
743+
if( $.contains(document, target) ) {
744+
return true;
745+
}
746+
}
747+
} else if(closeOnContent) {
748+
return true;
749+
}
750+
751+
}
752+
return false;
753+
},
754754
_addClassToMFP: function(cName) {
755755
mfp.bgOverlay.addClass(cName);
756756
mfp.wrap.addClass(cName);
@@ -1153,11 +1153,15 @@ $.magnificPopup.registerModule('image', {
11531153
options: {
11541154
markup: '<div class="mfp-figure">'+
11551155
'<div class="mfp-close"></div>'+
1156-
'<div class="mfp-img"></div>'+
1157-
'<div class="mfp-bottom-bar">'+
1158-
'<div class="mfp-title"></div>'+
1159-
'<div class="mfp-counter"></div>'+
1160-
'</div>'+
1156+
'<figure>'+
1157+
'<div class="mfp-img"></div>'+
1158+
'<figcaption>'+
1159+
'<div class="mfp-bottom-bar">'+
1160+
'<div class="mfp-title"></div>'+
1161+
'<div class="mfp-counter"></div>'+
1162+
'</div>'+
1163+
'</figcaption>'+
1164+
'</figure>'+
11611165
'</div>',
11621166
cursor: 'mfp-zoom-out-cur',
11631167
titleSrc: 'title',

dist/jquery.magnific-popup.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

magnific-popup.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magnific-popup",
33
"title": "Magnific Popup",
44
"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.",
5-
"version": "0.9.7",
5+
"version": "0.9.8",
66
"homepage": "http://dimsemenov.com/plugins/magnific-popup/",
77
"demo": "http://dimsemenov.com/plugins/magnific-popup/",
88
"docs": "http://dimsemenov.com/plugins/magnific-popup/documentation.html",

website/documentation.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ Markup of close button. %title% will be replaced with option `tClose`.
641641

642642
## Gallery
643643

644-
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.
644+
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:
645645

646646
{% highlight javascript %}
647647
gallery: {
@@ -659,20 +659,48 @@ gallery: {
659659
}
660660
{% endhighlight %}
661661

662+
Example:
663+
664+
{% highlight javascript %}
665+
// This will create a single gallery from all elements that have class "gallery-item"
666+
$('.gallery-item').magnificPopup({
667+
type: 'image',
668+
gallery:{
669+
enabled:true
670+
}
671+
});
672+
{% endhighlight %}
673+
662674
### Multiple galleries
663675

664-
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:
676+
To have multiple galleries on a page, you need to create a new instance of Magnific Popup for each seperate gallery. For example
677+
678+
{% highlight html %}
679+
<div class="gallery">
680+
<a href="path-to-image.jpg">Open image 1 (gallery #1)</a>
681+
<a href="path-to-image.jpg">Open image 2 (gallery #1)</a>
682+
</div>
683+
<div class="gallery">
684+
<a href="path-to-image.jpg">Open image 1 (gallery #2)</a>
685+
<a href="path-to-image.jpg">Open image 2 (gallery #2)</a>
686+
<a href="http://vimeo.com/123123" class="mfp-iframe">Open video (gallery #2). Class mfp-iframe forces "iframe" content type on this item.</a>
687+
</div>
688+
{% endhighlight %}
665689

666690
{% highlight javascript %}
667-
$('.gallery').each(function() { // the containers for all your galleries should have the class gallery
691+
$('.gallery').each(function() { // the containers for all your galleries
668692
$(this).magnificPopup({
669-
delegate: 'a', // the container for each your gallery items
693+
delegate: 'a', // the selector for gallery item
670694
type: 'image',
671-
gallery:{enabled:true}
695+
gallery: {
696+
enabled:true
697+
}
672698
});
673699
});
674700
{% endhighlight %}
675701

702+
You don't necessarily need to use `delegate` option, it can be just `$(this).find('a').magnificPopup( ...`.
703+
676704
### Lazy-loading
677705

678706
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({
11251153

11261154
See [example on CodePen](http://codepen.io/dimsemenov/pen/JGjHK).
11271155

1156+
### How to override some function without modifying the source files?
1157+
1158+
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):
1159+
1160+
{% highlight javascript %}
1161+
$.magnificPopup.proto._setFocus = function() {
1162+
(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
1163+
};
1164+
{% endhighlight %}
1165+
1166+
11281167
<h2 id="contribute">Make Magnific Popup better!</h2>
11291168

11301169
Improve this documentation page <a href="https://github.com/dimsemenov/Magnific-Popup/edit/master/website/documentation.md">via GitHub</a> (simply submit commit). Any improvements, including your own CodePen examples are very welcome.

0 commit comments

Comments
 (0)