Fixed "Viewing small (image) attachments" (Closes #369)

This commit is contained in:
RainLoop Team 2014-11-06 16:00:36 +04:00
parent eb30a1fe27
commit 96e4741a57
17 changed files with 2827 additions and 178 deletions

View file

@ -1,6 +1,6 @@
/*! Magnific Popup - v0.9.8 - 2013-10-26
/*! Magnific Popup - v0.9.9 - 2014-09-06
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2013 Dmitry Semenov; MIT */
* Copyright (c) 2014 Dmitry Semenov; */
;(function($) {
/*>>core*/
@ -76,9 +76,6 @@ var _mfpOn = function(name, f) {
}
}
},
_setFocus = function() {
(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
},
_getCloseBtn = function(type) {
if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
@ -137,7 +134,6 @@ MagnificPopup.prototype = {
// 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.
mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
_body = $(document.body);
_document = $(document);
mfp.popupsCache = {};
@ -149,6 +145,10 @@ MagnificPopup.prototype = {
*/
open: function(data) {
if(!_body) {
_body = $(document.body);
}
var i;
if(data.isObj === false) {
@ -343,14 +343,11 @@ MagnificPopup.prototype = {
_mfpTrigger('BuildControls');
// remove scrollbar, add margin e.t.c
$('html').css(windowStyles);
// add everything to DOM
mfp.bgOverlay.add(mfp.wrap).prependTo( document.body );
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || _body );
// Save last focused element
mfp._lastFocusedEl = document.activeElement;
@ -360,19 +357,14 @@ MagnificPopup.prototype = {
if(mfp.content) {
mfp._addClassToMFP(READY_CLASS);
_setFocus();
mfp._setFocus();
} else {
// if content is not defined (not loaded e.t.c) we add class only for BG
mfp.bgOverlay.addClass(READY_CLASS);
}
// Trap the focus in popup
_document.on('focusin' + EVENT_NS, function (e) {
if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
_setFocus();
return false;
}
});
_document.on('focusin' + EVENT_NS, mfp._onFocusIn);
}, 16);
@ -573,11 +565,12 @@ MagnificPopup.prototype = {
*/
parseEl: function(index) {
var item = mfp.items[index],
type = item.type;
type;
if(item.tagName) {
item = { el: $(item) };
} else {
type = item.type;
item = { data: item, src: item.src };
}
@ -762,6 +755,15 @@ MagnificPopup.prototype = {
_hasScrollBar: function(winHeight) {
return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
},
_setFocus: function() {
(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
},
_onFocusIn: function(e) {
if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
mfp._setFocus();
return false;
}
},
_parseMarkup: function(template, values, item) {
var arr;
if(item.data) {
@ -804,7 +806,6 @@ MagnificPopup.prototype = {
// thx David
if(mfp.scrollbarSize === undefined) {
var scrollDiv = document.createElement("div");
scrollDiv.id = "mfp-sbm";
scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
document.body.appendChild(scrollDiv);
mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
@ -885,6 +886,8 @@ $.magnificPopup = {
alignTop: false,
removalDelay: 0,
prependTo: null,
fixedContentPos: 'auto',
@ -1098,7 +1101,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
_removeAjaxCursor();
_setFocus();
mfp._setFocus();
setTimeout(function() {
mfp.wrap.addClass(READY_CLASS);
@ -1330,8 +1333,12 @@ $.magnificPopup.registerModule('image', {
if(el.is('img')) {
item.img = item.img.clone();
}
if(item.img[0].naturalWidth > 0) {
img = item.img[0];
if(img.naturalWidth > 0) {
item.hasSize = true;
} else if(!img.width) {
item.hasSize = false;
}
}
@ -2038,4 +2045,4 @@ $.magnificPopup.registerModule(RETINA_NS, {
})();
/*>>fastclick*/
})(window.jQuery || window.Zepto);
_checkInstance(); })(window.jQuery || window.Zepto);