vendor/assets/javascripts/magnific-popup/jquery.magnific-popup.js in magnific-popup-rails-0.9.5 vs vendor/assets/javascripts/magnific-popup/jquery.magnific-popup.js in magnific-popup-rails-0.9.7

- old
+ new

@@ -1,6 +1,6 @@ -/*! Magnific Popup - v0.9.5 - 2013-08-21 +/*! Magnific Popup - v0.9.7 - 2013-10-10 * http://dimsemenov.com/plugins/magnific-popup/ * Copyright (c) 2013 Dmitry Semenov; */ ;(function($) { /*>>core*/ @@ -412,10 +412,12 @@ }, 16); mfp.isOpen = true; mfp.updateSize(windowHeight); _mfpTrigger(OPEN_EVENT); + + return data; }, /** * Closes the popup */ @@ -825,20 +827,24 @@ modules: [], open: function(options, index) { _checkInstance(); - if(!options) + if(!options) { options = {}; + } else { + options = $.extend(true, {}, options); + } + options.isObj = true; options.index = index || 0; return this.instance.open(options); }, close: function() { - return $.magnificPopup.instance.close(); + return $.magnificPopup.instance && $.magnificPopup.instance.close(); }, registerModule: function(name, module) { if(module.options) { $.magnificPopup.defaults[name] = module.options; @@ -924,11 +930,13 @@ if(mfp.isOpen) mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1)); } } else { - + // clone options obj + options = $.extend(true, {}, options); + /* * As Zepto doesn't support .data() method for objects * and it works only in normal browsers * we assign "options" object directly to the DOM element. FTW! */ @@ -1041,10 +1049,16 @@ _ajaxCur, _removeAjaxCursor = function() { if(_ajaxCur) { _body.removeClass(_ajaxCur); } + }, + _destroyAjaxRequest = function() { + _removeAjaxCursor(); + if(mfp.req) { + mfp.req.abort(); + } }; $.magnificPopup.registerModule(AJAX_NS, { options: { @@ -1056,18 +1070,13 @@ proto: { initAjax: function() { mfp.types.push(AJAX_NS); _ajaxCur = mfp.st.ajax.cursor; - _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, function() { - _removeAjaxCursor(); - if(mfp.req) { - mfp.req.abort(); - } - }); + _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest); + _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest); }, - getAjax: function(item) { if(_ajaxCur) _body.addClass(_ajaxCur); @@ -1382,11 +1391,12 @@ proto: { initZoom: function() { var zoomSt = mfp.st.zoom, - ns = '.zoom'; + ns = '.zoom', + image; if(!zoomSt.enabled || !mfp.supportsTransition) { return; } @@ -1486,10 +1496,11 @@ if(mfp._allowZoom()) { showMainContent(); if(animatedImg) { animatedImg.remove(); } + image = null; } }); }, _allowZoom: function() { @@ -1666,11 +1677,11 @@ return numSlides + index; } return index; }, _replaceCurrTotal = function(text, curr, total) { - return text.replace('%curr%', curr + 1).replace('%total%', total); + return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total); }; $.magnificPopup.registerModule('gallery', { options: { @@ -1730,11 +1741,11 @@ }); _mfpOn('BuildControls' + ns, function() { 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); + arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS), + arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS); var eName = supportsFastClick ? 'mfpFastClick' : 'click'; arrowLeft[eName](function() { mfp.prev(); }); \ No newline at end of file