vendor/assets/javascripts/magnific-popup/jquery.magnific-popup.js in magnific-popup-rails-0.8.8 vs vendor/assets/javascripts/magnific-popup/jquery.magnific-popup.js in magnific-popup-rails-0.8.9

- old
+ new

@@ -1,6 +1,6 @@ -/*! Magnific Popup - v0.8.8 - 2013-05-24 +/*! Magnific Popup - v0.8.9 - 2013-06-04 * http://dimsemenov.com/plugins/magnific-popup/ * Copyright (c) 2013 Dmitry Semenov; */ ;(function($) { /*>>core*/ @@ -13,10 +13,11 @@ /** * Private static constants */ var CLOSE_EVENT = 'Close', + AFTER_CLOSE_EVENT = 'AfterClose', BEFORE_APPEND_EVENT = 'BeforeAppend', MARKUP_PARSE_EVENT = 'MarkupParse', OPEN_EVENT = 'Open', CHANGE_EVENT = 'Change', NS = 'mfp', @@ -139,11 +140,11 @@ * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed */ 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); // We disable fixed positioned lightbox on devices that don't handle it nicely. // If you know a better way of detecting this - let me know. @@ -225,11 +226,11 @@ } }); mfp.container = _getEl('container', mfp.wrap); } - + mfp.contentContainer = _getEl('content'); if(mfp.st.preloader) { mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading); } @@ -306,15 +307,17 @@ 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) { bodyStyles.overflow = 'hidden'; } else { @@ -411,15 +414,15 @@ } 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); } _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS); @@ -442,10 +445,12 @@ } mfp.currItem = null; mfp.content = null; mfp.currTemplate = null; mfp.prevHeight = 0; + + _mfpTrigger(AFTER_CLOSE_EVENT); }, updateSize: function(winHeight) { if(mfp.isIOS) { @@ -455,10 +460,14 @@ mfp.wrap.css('height', height); mfp.wH = height; } 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'); }, @@ -703,16 +712,12 @@ _removeClassFromMFP: function(cName) { this.bgOverlay.removeClass(cName); 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) { values = $.extend(item.data, values); } @@ -906,10 +911,11 @@ } console.log('Test #2:', performance.now() - start); */ + /*>>core*/ /*>>inline*/ var INLINE_NS = 'inline', @@ -948,11 +954,12 @@ el = $(item.src); 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); _hiddenClass = 'mfp-'+_hiddenClass; } @@ -1017,14 +1024,18 @@ mfp.updateStatus('loading'); 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; _removeAjaxCursor(); @@ -1034,9 +1045,10 @@ mfp.wrap.addClass(READY_CLASS); }, 16); mfp.updateStatus('ready'); + _mfpTrigger('AjaxContentAdded'); }, error: function() { _removeAjaxCursor(); item.finished = item.loadError = true; mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src)); \ No newline at end of file