Skip to content

Commit

Permalink
1.2.0 build
Browse files Browse the repository at this point in the history
  • Loading branch information
dimsemenov committed Jun 8, 2024
1 parent f77d6d5 commit 31eb9a7
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 182 deletions.
168 changes: 125 additions & 43 deletions dist/jquery.magnific-popup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Magnific Popup - v1.1.0 - 2016-02-20
/*! Magnific Popup - v1.2.0 - 2024-06-08
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2016 Dmitry Semenov; */
* Copyright (c) 2024 Dmytro Semenov; */
;(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
Expand Down Expand Up @@ -83,7 +83,7 @@ var _mfpOn = function(name, f) {
// converts "mfpEventName" to "eventName" callback and triggers it if it's present
e = e.charAt(0).toLowerCase() + e.slice(1);
if(mfp.st.callbacks[e]) {
mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
mfp.st.callbacks[e].apply(mfp, Array.isArray(data) ? data : [data]);
}
}
},
Expand Down Expand Up @@ -175,7 +175,7 @@ MagnificPopup.prototype = {
}
}
} else {
mfp.items = $.isArray(data.items) ? data.items : [data.items];
mfp.items = Array.isArray(data.items) ? data.items : [data.items];
mfp.index = data.index || 0;
}

Expand Down Expand Up @@ -641,7 +641,7 @@ MagnificPopup.prototype = {
var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;

if(disableOn) {
if($.isFunction(disableOn)) {
if(typeof disableOn === "function") {
if( !disableOn.call(mfp) ) {
return true;
}
Expand Down Expand Up @@ -693,7 +693,11 @@ MagnificPopup.prototype = {
status = data.status;
text = data.text;

mfp.preloader.html(text);
if (mfp.st.allowHTMLInStatusIndicator) {
mfp.preloader.html(text);
} else {
mfp.preloader.text(text);
}

mfp.preloader.find('a').on('click', function(e) {
e.stopImmediatePropagation();
Expand All @@ -712,7 +716,7 @@ MagnificPopup.prototype = {
// "target" is an element that was clicked
_checkIfClose: function(target) {

if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
if($(target).closest('.' + PREVENT_CLOSE_CLASS).length) {
return;
}

Expand All @@ -724,7 +728,7 @@ MagnificPopup.prototype = {
} else {

// We close the popup if click is on close button or on preloader. Or if there is no content.
if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
if(!mfp.content || $(target).closest('.mfp-close').length || (mfp.preloader && target === mfp.preloader[0]) ) {
return true;
}

Expand Down Expand Up @@ -796,7 +800,11 @@ MagnificPopup.prototype = {
}

} else {
template.find(EVENT_NS + '-'+key).html(value);
if (mfp.st.allowHTMLInTemplate) {
template.find(EVENT_NS + '-'+key).html(value);
} else {
template.find(EVENT_NS + '-'+key).text(value);
}
}
});
},
Expand Down Expand Up @@ -899,7 +907,11 @@ $.magnificPopup = {

tLoading: 'Loading...',

autoFocusLast: true
autoFocusLast: true,

allowHTMLInStatusIndicator: false,

allowHTMLInTemplate: false

}
};
Expand Down Expand Up @@ -1047,7 +1059,7 @@ $.magnificPopup.registerModule(AJAX_NS, {
options: {
settings: null,
cursor: 'mfp-ajax-cur',
tError: '<a href="%url%">The content</a> could not be loaded.'
tError: 'The content could not be loaded.'
},

proto: {
Expand Down Expand Up @@ -1117,7 +1129,7 @@ var _imgInterval,
var src = mfp.st.image.titleSrc;

if(src) {
if($.isFunction(src)) {
if(typeof src === "function") {
return src.call(mfp, item);
} else if(item.el) {
return item.el.attr(src) || '';
Expand All @@ -1144,7 +1156,7 @@ $.magnificPopup.registerModule('image', {
cursor: 'mfp-zoom-out-cur',
titleSrc: 'title',
verticalFit: true,
tError: '<a href="%url%">The image</a> could not be loaded.'
tError: 'The image could not be loaded.'
},

proto: {
Expand Down Expand Up @@ -1249,6 +1261,23 @@ $.magnificPopup.registerModule('image', {

var guard = 0,

imgSt = mfp.st.image,

// image error handler
onLoadError = function() {
if(item) {
item.img.off('.mfploader');
if(item === mfp.currItem){
mfp._onImageHasSize(item);
mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
}

item.hasSize = true;
item.loaded = true;
item.loadError = true;
}
},

// image load complete handler
onLoadComplete = function() {
if(item) {
Expand Down Expand Up @@ -1277,23 +1306,8 @@ $.magnificPopup.registerModule('image', {
}
}
}
},

// image error handler
onLoadError = function() {
if(item) {
item.img.off('.mfploader');
if(item === mfp.currItem){
mfp._onImageHasSize(item);
mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
}

item.hasSize = true;
item.loaded = true;
item.loadError = true;
}
},
imgSt = mfp.st.image;
};



var el = template.find('.mfp-img');
Expand Down Expand Up @@ -1638,6 +1652,7 @@ $.magnificPopup.registerModule(IFRAME_NS, {
if(iframeSt.srcAction) {
dataObj[iframeSt.srcAction] = embedSrc;
}

mfp._parseMarkup(template, dataObj, item);

mfp.updateStatus('ready');
Expand Down Expand Up @@ -1679,7 +1694,10 @@ $.magnificPopup.registerModule('gallery', {

tPrev: 'Previous (Left arrow key)',
tNext: 'Next (Right arrow key)',
tCounter: '%curr% of %total%'
tCounter: '%curr% of %total%',

langDir: null,
loop: true,
},

proto: {
Expand All @@ -1691,6 +1709,10 @@ $.magnificPopup.registerModule('gallery', {
mfp.direction = true; // true - next, false - prev

if(!gSt || !gSt.enabled ) return false;

if (!gSt.langDir) {
gSt.langDir = document.dir || 'ltr';
}

_wrapClasses += ' mfp-gallery';

Expand All @@ -1707,11 +1729,20 @@ $.magnificPopup.registerModule('gallery', {

_document.on('keydown'+ns, function(e) {
if (e.keyCode === 37) {
mfp.prev();
if (gSt.langDir === 'rtl') mfp.next();
else mfp.prev();
} else if (e.keyCode === 39) {
mfp.next();
if (gSt.langDir === 'rtl') mfp.prev();
else mfp.next();
}
});

mfp.updateGalleryButtons();

});

_mfpOn('UpdateStatus'+ns, function(/*e, data*/) {
mfp.updateGalleryButtons();
});

_mfpOn('UpdateStatus'+ns, function(e, data) {
Expand All @@ -1727,18 +1758,44 @@ $.magnificPopup.registerModule('gallery', {

_mfpOn('BuildControls' + ns, function() {
if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
var markup = gSt.arrowMarkup,
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);

arrowLeft.click(function() {
mfp.prev();
var arrowLeftDesc, arrowRightDesc, arrowLeftAction, arrowRightAction;

if (gSt.langDir === 'rtl') {
arrowLeftDesc = gSt.tNext;
arrowRightDesc = gSt.tPrev;
arrowLeftAction = 'next';
arrowRightAction = 'prev';
} else {
arrowLeftDesc = gSt.tPrev;
arrowRightDesc = gSt.tNext;
arrowLeftAction = 'prev';
arrowRightAction = 'next';
}

var markup = gSt.arrowMarkup,
arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, arrowLeftDesc).replace(/%action%/gi, arrowLeftAction).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, arrowRightDesc).replace(/%action%/gi, arrowRightAction).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);

if (gSt.langDir === 'rtl') {
mfp.arrowNext = arrowLeft;
mfp.arrowPrev = arrowRight;
} else {
mfp.arrowNext = arrowRight;
mfp.arrowPrev = arrowLeft;
}

arrowLeft.on('click', function() {
if (gSt.langDir === 'rtl') mfp.next();
else mfp.prev();
});
arrowRight.click(function() {
mfp.next();
arrowRight.on('click', function() {
if (gSt.langDir === 'rtl') mfp.prev();
else mfp.next();
});

mfp.container.append(arrowLeft.add(arrowRight));

}
});

Expand All @@ -1760,13 +1817,17 @@ $.magnificPopup.registerModule('gallery', {

},
next: function() {
var newIndex = _getLoopedId(mfp.index + 1);
if (!mfp.st.gallery.loop && newIndex === 0 ) return false;
mfp.direction = true;
mfp.index = _getLoopedId(mfp.index + 1);
mfp.index = newIndex;
mfp.updateItemHTML();
},
prev: function() {
var newIndex = mfp.index - 1;
if (!mfp.st.gallery.loop && newIndex < 0) return false;
mfp.direction = false;
mfp.index = _getLoopedId(mfp.index - 1);
mfp.index = _getLoopedId(newIndex);
mfp.updateItemHTML();
},
goTo: function(newIndex) {
Expand Down Expand Up @@ -1813,10 +1874,31 @@ $.magnificPopup.registerModule('gallery', {


item.preloaded = true;
}
},

/**
* Show/hide the gallery prev/next buttons if we're at the start/end, if looping is turned off
* Added by Joloco for Veg
*/
updateGalleryButtons: function() {

if ( !mfp.st.gallery.loop && typeof mfp.arrowPrev === 'object' && mfp.arrowPrev !== null) {

if (mfp.index === 0) mfp.arrowPrev.hide();
else mfp.arrowPrev.show();

if (mfp.index === (mfp.items.length - 1)) mfp.arrowNext.hide();
else mfp.arrowNext.show();

}

},

}

});


/*>>gallery*/

/*>>retina*/
Expand Down
Loading

0 comments on commit 31eb9a7

Please sign in to comment.