Adresse
Webers Webdesign
Ludwig-Schopp-Straße 27
53117 Bonn
function handle_lightbox_groups(){
?>
<script>
(function($){
$(document).ready(function() {
// Automatically find all group-X classes (only with numbers)
var groupNumbers = [];
$('[class*="group-"]').each(function() {
var classes = $(this).attr('class').split(/\s+/);
$.each(classes, function(index, className) {
var match = className.match(/^group-(\d+)$/);
if(match && $.inArray(parseInt(match[1]), groupNumbers) === -1) {
groupNumbers.push(parseInt(match[1]));
}
});
});
// Exit script if no valid groups are present
if(groupNumbers.length === 0) {
return;
}
setTimeout(function() {
// Exact Enfold settings from avia-snippet-lightbox.js
var enfoldSettings = {
type: 'image',
mainClass: 'avia-popup mfp-zoom-in',
tLoading: '',
tClose: '',
removalDelay: 300,
closeBtnInside: true,
closeOnContentClick: false,
midClick: true,
autoFocusLast: false,
fixedContentPos: $('html').hasClass('av-default-lightbox-no-scroll'),
image: {
titleSrc: function(item) {
var title = item.el.attr('title');
if(!title) {
title = item.el.find('img').attr('title');
}
if(!title) {
title = item.el.parent().next('.wp-caption-text').html();
}
if(typeof title != "undefined") {
return title;
}
if(!$('body').hasClass('avia-mfp-show-alt-text')) {
return '';
}
var alt = item.el.attr('alt');
if(typeof alt != "undefined") {
return alt;
}
alt = item.el.find('img').attr('alt');
if(typeof alt != "undefined") {
return alt;
}
return '';
}
},
gallery: {
tPrev: '',
tNext: '',
tCounter: '%curr% / %total%',
enabled: true,
preload: [1,1]
},
callbacks: {
beforeOpen: function() {
if(this.st.el && this.st.el.data('fixed-content')) {
this.fixedContentPos = true;
}
var elementCustomClass = '';
if(this.st.el && this.st.el.data('custom_class')) {
elementCustomClass = this.st.el.data('custom_class').trim();
}
if(elementCustomClass) {
this.st.mainClass += ' ' + elementCustomClass;
}
},
open: function() {
$.magnificPopup.instance.next = function() {
var self = this;
self.wrap.removeClass('mfp-image-loaded');
setTimeout(function() { $.magnificPopup.proto.next.call(self); }, 120);
};
$.magnificPopup.instance.prev = function() {
var self = this;
self.wrap.removeClass('mfp-image-loaded');
setTimeout(function() { $.magnificPopup.proto.prev.call(self); }, 120);
};
if(this.st.el && this.st.el.data('av-extra-class')) {
this.wrap.addClass(this.currItem.el.data('av-extra-class'));
}
this.wrap.avia_swipe_trigger({prev:'.mfp-arrow-left', next:'.mfp-arrow-right'});
},
markupParse: function(template, values, item) {
if(typeof values.img_replaceWith == 'undefined' || typeof values.img_replaceWith.length == 'undefined' || values.img_replaceWith.length == 0) {
return;
}
var img = $(values.img_replaceWith[0]);
if(typeof img.attr('alt') != 'undefined') {
return;
}
var alt = item.el.attr('alt');
if(typeof alt == "undefined") {
alt = item.el.find('img').attr('alt');
}
if(typeof alt != "undefined") {
img.attr('alt', alt);
}
return;
},
imageLoadComplete: function() {
var self = this;
setTimeout(function() { self.wrap.addClass('mfp-image-loaded'); }, 16);
},
change: function() {
if(this.currItem.el) {
var current = this.currItem.el;
this.content.find('.av-extra-modal-content, .av-extra-modal-markup').remove();
if(current.data('av-extra-content')) {
var extra = current.data('av-extra-content');
this.content.append("<div class='av-extra-modal-content'>" + extra + "</div>");
}
if(current.data('av-extra-markup')) {
var markup = current.data('av-extra-markup');
this.wrap.append("<div class='av-extra-modal-markup'>" + markup + "</div>");
}
}
}
}
};
// Initialize each found group
$.each(groupNumbers, function(index, groupNum) {
var groupSelector = '.group-' + groupNum + ' .lightbox-added';
var $group = $(groupSelector);
if($group.length) {
$group.magnificPopup('destroy');
$group.magnificPopup(enfoldSettings);
}
});
$('.lightbox-added').not('[class*="group-"] .lightbox-added').each(function() {
var $this = $(this);
$this.magnificPopup('destroy');
$this.magnificPopup(enfoldSettings);
});
}, 500);
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'handle_lightbox_groups', 999);