(function($) { "use strict"; // ------------------------------------------------------------------------------------------- // Ligthbox activation // ------------------------------------------------------------------------------------------- $.avia_utilities = $.avia_utilities || {}; $.avia_utilities.av_popup = { type: 'image', mainClass: 'avia-popup mfp-zoom-in', tLoading: '', tClose: '', removalDelay: 300, //delay removal by X to allow out-animation closeBtnInside: true, closeOnContentClick:false, midClick: true, fixedContentPos: false, // allows scrolling when lightbox is open but also removes any jumping because of scrollbar removal iframe: { patterns: { youtube: { index: 'youtube.com/watch', id: function(url) { //fetch the id var m = url.match(/[\\?\\&]v=([^\\?\\&]+)/), id, params; if ( !m || !m[1] ) return null; id = m[1]; //fetch params params = url.split('/watch'); params = params[1]; return id + params; }, src: '//www.youtube.com/embed/%id%' } } }, 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 ""; return title; } }, gallery: { // delegate: options.autolinkElements, tPrev: '', tNext: '', tCounter: '%curr% / %total%', enabled: true, preload: [1,1] // Will preload 1 - before current, and 1 after the current image }, callbacks: { beforeOpen: function() { //add custom css class for different styling if( this.st.el && this.st.el.data('fixed-content') ) { this.fixedContentPos = true; } }, open: function() { //overwrite default prev + next function. Add timeout for crossfade animation $.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); } //add custom css class for different styling if( this.st.el && this.st.el.data('av-extra-class') ) { this.wrap.addClass( this.currItem.el.data('av-extra-class') ); } }, 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( "
" ); } if( current.data('av-extra-markup') ) { var markup = current.data('av-extra-markup'); this.wrap.append( "