',
slides = selector.find('li').eq(0).show().end(),
left,right,
move = function(ev){
ev.stopPropagation();
ev.preventDefault();
var direction = ev.data.dir,
current = slides.filter(':visible'),
toShow;
if(direction === 'next'){
toShow = current.next();
if(!toShow.length){
toShow = slides.eq(0);
}
}
else{
toShow = current.prev();
if(!toShow.length){
toShow = slides.eq(slides.length-1);
}
}
//animate
current.fadeOut(200, function(){ toShow.fadeIn(200); })
};
if(selector.hasClass('slider-ctrls')){
//there are controls already
return;
}
if(slides.length > 1){ //more then one slide
selector.addClass('slider-ctrls').append(html);
left = selector.find('span.prev-slide');
right = selector.find('span.next-slide');
//bind clicks
left.on(click_event,null,{dir: 'prev'}, move);
right.on(click_event,null,{dir: 'next'}, move);
}
});
}
},
lightbox : function(){
//if no lightbox script do nothing
//Using lightGallery ?
if(typeof $.fn.lightGallery !== 'undefined'){
var lightbox_args = {
hash : !!parseInt(G.lg_lightbox_share, 10),
share : !!parseInt(G.lg_lightbox_share, 10),
controls : !!parseInt(G.lg_lightbox_controls, 10),
download : !!parseInt(G.lg_lightbox_download, 10),
counter : !!parseInt(G.lg_lightbox_counter, 10),
thumbnail : !!parseInt(G.lg_lightbox_thumbnail, 10),
showThumbByDefault: !!parseInt(G.lg_lightbox_show_thumbs, 10),
autoplay : !!parseInt(G.lg_lightbox_autoplay_open, 10),
autoplayControls : !!parseInt(G.lg_lightbox_autoplay, 10),
progressBar : !!parseInt(G.lg_lightbox_progressbar, 10),
fullScreen : !!parseInt(G.lg_lightbox_full_screen, 10),
zoom : !!parseInt(G.lg_lightbox_zoom, 10),
mode : G.lg_lightbox_mode,
pause : parseInt(G.lg_lightbox_autoplay_pause, 10),
speed : parseInt(G.lg_lightbox_speed, 10),
preload : parseInt(G.lg_lightbox_preload, 10),
hideBarsDelay : parseInt(G.lg_lightbox_hide_delay, 10)
},
$gallery = $(".gallery-media-collection"),
vc_media_grid = $('div.vc_media_grid, div.vc_masonry_media_grid'),
wp_gallery = $('div.gallery');
//bricks albums/works
if( $gallery.length ){
var $gallery_items = $gallery.children(),
//standard params
params = $.extend(
{
selector : $gallery_items.not('.link'),
exThumbImage: 'data-thumb'
},
lightbox_args),
filter = function(event, filter_string, $gallery){
var new_params;
//if all elements are visible
if(filter_string === '*'){
new_params = params;
}
else{
new_params = $.extend({}, params, {selector: $gallery_items.not('.link').filter(filter_string)})
}
//clean current binding of elements to lightbox
$gallery.data('lightGallery').destroy(true);
//rebind only filtered elements
$gallery.lightGallery(new_params);
};
//if gallery is bricks gallery & have vimeo video, load Vimeo Api for lightbox
if( $gallery.parent().is('div.bricks-frame') && $gallery_items.filter('[data-video_type="vimeo"]').length ){
//load VIMEO API
(function(){
var tag = document.createElement('script');
tag.src = "https://f.vimeocdn.com/js/froogaloop2.min.js";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
})();
}
//rewrite HTML to match lightbox syntax
$gallery_items.each(function(){
var $el = $(this),
$link = $el.children('a.item__link'),
$desc = $el.find('div.item-desc'),
$video = $el.find('div.album-video'),
title;
if($desc.length){
title = $link.text();
//mark where lightbox should search for description
$el.attr('data-sub-html', '#'+$desc.attr('id'));
//wrap real description so we can distinguish it
$desc.wrapInner('
');
//add title
$desc.prepend('
'+title+'
');
//wrap everything in special class, so it will look nice in lightbox
$desc.wrapInner('
');
//share texts
$el.attr('data-pinterest-text', title);
$el.attr('data-tweet-text', title);
}
//can't have data-html and data-src in one item
if($video.length){
$el.attr('data-html', '#'+$video.attr('id'));
}
else{
$el.attr('data-src', $link.attr('href'));
}
});
$gallery.lightGallery(params);
$window.on('a13_gallery_filtered', filter);
}
//lets try media grid from VC
if( vc_media_grid.length ){
//when elements are loaded we bind our lightbox
$window.on('grid:items:added', function(event, element){
var this_media_grid = $(element),
grid_items = this_media_grid.find('a.a13-lightbox-added');
//we check if this was fired for one of our media grids
if(vc_media_grid.is(this_media_grid) && grid_items.length){
this_media_grid.lightGallery($.extend({}, lightbox_args,
{
selector : grid_items,
exThumbImage : 'href',
subHtmlSelectorRelative : true,
hash : false
})
);
//block VC actions that force to open image native
grid_items.on('click', function(){
return false;
});
}
});
}
//lets try normal WordPress gallery
if( wp_gallery.length ){
var gallery_items = wp_gallery.find('.gallery-icon').children('a');
wp_gallery.lightGallery($.extend(
{
selector : gallery_items,
exThumbImage : 'href',
getCaptionFromTitleOrAlt : false
},
lightbox_args)
);
}
//single post/page/work/album but not page made with Elementor
if(G.lightbox_single_post && ( $body.hasClass('single-post') || $body.hasClass('single-work') || ( $body.hasClass('page') && !$body.hasClass('elementor-page') ) || $body.hasClass('single-album') )){
var content = $body.find('.real-content'),
single_images = content.find('a').children('img').parent();
content.lightGallery($.extend(
{
selector : single_images,
exThumbImage : 'href',
getCaptionFromTitleOrAlt : false
},
lightbox_args)
);
}
$window.on('post-load', function(){
var post_lightbox = $('#a13-post-lightbox' );
if(G.lightbox_single_post && post_lightbox.length && post_lightbox.is(':visible') ){
var content = post_lightbox.find('.real-content'),
single_images = content.find('a').children('img').parent();
content.lightGallery($.extend(
{
selector : single_images,
exThumbImage : 'href',
getCaptionFromTitleOrAlt : false
},
lightbox_args)
);
}
});
}
//if no lightbox script do nothing
},
demoFlyOut : function(){
var flyout = $('#a13-flyout-box');
if(flyout.length){
flyout.find('span.drag-out').on(click_event, function(){
flyout.toggleClass('open');
});
}
}
}
};
//start Theme
A13F = window.A13FRAMEWORK;
$(document).ready(A13F.onReady);
})(jQuery, window, document);