|
1 | | -/*! Magnific Popup - v0.9.7 - 2013-10-10 |
| 1 | +/*! Magnific Popup - v0.9.8 - 2013-10-26 |
2 | 2 | * http://dimsemenov.com/plugins/magnific-popup/ |
3 | 3 | * Copyright (c) 2013 Dmitry Semenov; */ |
4 | 4 | ;(function($) { |
@@ -94,41 +94,6 @@ var _mfpOn = function(name, f) { |
94 | 94 | $.magnificPopup.instance = mfp; |
95 | 95 | } |
96 | 96 | }, |
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 | | - }, |
132 | 97 | // CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr |
133 | 98 | supportsTransitions = function() { |
134 | 99 | 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 = { |
254 | 219 | }); |
255 | 220 |
|
256 | 221 | mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) { |
257 | | - if(_checkIfClose(e.target)) { |
| 222 | + if(mfp._checkIfClose(e.target)) { |
258 | 223 | mfp.close(); |
259 | 224 | } |
260 | 225 | }); |
@@ -349,7 +314,7 @@ MagnificPopup.prototype = { |
349 | 314 | if(mfp._hasScrollBar(windowHeight)){ |
350 | 315 | var s = mfp._getScrollbarSize(); |
351 | 316 | if(s) { |
352 | | - windowStyles.paddingRight = s; |
| 317 | + windowStyles.marginRight = s; |
353 | 318 | } |
354 | 319 | } |
355 | 320 | } |
@@ -379,7 +344,7 @@ MagnificPopup.prototype = { |
379 | 344 | _mfpTrigger('BuildControls'); |
380 | 345 |
|
381 | 346 |
|
382 | | - // remove scrollbar, add padding e.t.c |
| 347 | + // remove scrollbar, add margin e.t.c |
383 | 348 | $('html').css(windowStyles); |
384 | 349 |
|
385 | 350 | // add everything to DOM |
@@ -456,7 +421,7 @@ MagnificPopup.prototype = { |
456 | 421 | mfp._removeClassFromMFP(classesToRemove); |
457 | 422 |
|
458 | 423 | if(mfp.fixedContentPos) { |
459 | | - var windowStyles = {paddingRight: ''}; |
| 424 | + var windowStyles = {marginRight: ''}; |
460 | 425 | if(mfp.isIE7) { |
461 | 426 | $('body, html').css('overflow', ''); |
462 | 427 | } else { |
@@ -751,6 +716,41 @@ MagnificPopup.prototype = { |
751 | 716 | /* |
752 | 717 | "Private" helpers that aren't private at all |
753 | 718 | */ |
| 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 | + }, |
754 | 754 | _addClassToMFP: function(cName) { |
755 | 755 | mfp.bgOverlay.addClass(cName); |
756 | 756 | mfp.wrap.addClass(cName); |
@@ -1153,11 +1153,15 @@ $.magnificPopup.registerModule('image', { |
1153 | 1153 | options: { |
1154 | 1154 | markup: '<div class="mfp-figure">'+ |
1155 | 1155 | '<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>'+ |
1161 | 1165 | '</div>', |
1162 | 1166 | cursor: 'mfp-zoom-out-cur', |
1163 | 1167 | titleSrc: 'title', |
|
0 commit comments