(function($) {
function setInterval() {
var lastScrollTop = $(window).scrollTop();
var navbarHeight = $('#header').outerHeight();
$(window).scroll(function(event) {
var st = $(this).scrollTop();
if (st > lastScrollTop) {
$('#sticky_header').removeClass('header-is-sticky');
} else {
// Scroll Up
if (st < navbarHeight) {
$('#sticky_header').removeClass('header-is-sticky');
} else {
$('#sticky_header').addClass('header-is-sticky');
}
}
lastScrollTop = st;
});
}
function cloneHeader() {
var site_logo = $('.site-title').clone(true);
var site_nav = $('.main-navigation').clone(true, true);
var site_nav_res = $('.vce-res-nav').clone(true);
$('body').prepend('
');
if (vce_js_settings.sticky_header_logo !== "" && $("#sticky_header .site-title a img").length > 0) {
$("#sticky_header .site-title a img").attr("src", vce_js_settings.sticky_header_logo);
}
$("#sticky_header .site-title a img").css('width', 'auto');
if (vce_js_settings.mega_menu_slider) {
$('#sticky_header .vce-mega-menu-posts-wrap > ul').each(function() {
$(this).removeClass("owl-carousel owl-theme owl-loaded");
var temp_html = $(this).find('.owl-item:not(.cloned) li');
$(this).html('').append(temp_html);
vce_mega_menu_slider($(this));
});
}
}
function vce_mega_menu_slider($obj) {
var num_posts = $obj.parent().attr('data-numposts');
$obj.owlCarousel({
loop: true,
rtl: vce_js_settings.rtl_mode,
nav: true,
center: false,
fluidSpeed: 100,
items: num_posts,
navText: ['', ''],
responsive: {
0: {
items: 1,
nav: true,
autoWidth: true
},
600: {
items: 2,
autoWidth: true
},
768: {
items: 3,
autoWidth: false
},
1024: {
items: num_posts,
autoWidth: false
}
}
});
}
$(document).ready(function() {
/* FEATURED GRID SLIDER */
if (parseInt(vce_js_settings.rtl_mode) == 1) {
vce_js_settings.rtl_mode = true;
} else {
vce_js_settings.rtl_mode = false;
}
var responsive = {
0: {
items: 1,
nav: true,
autoWidth: true
},
600: {
items: 2,
autoWidth: true
},
768: {
items: 3,
autoWidth: false
},
1024: {
items: 3,
autoWidth: true
}
},
autoplay = vce_js_settings.grid_slider_autoplay;
if($("#vce-featured-grid").hasClass('vce-featured-grid-big')){
responsive = {
0: {
items: 1,
nav: true,
autoWidth: true
},
600: {
items: 1,
autoWidth: true
},
768: {
items: 1,
autoWidth: true
},
1024: {
items: 1,
autoWidth: true
}
};
autoplay = vce_js_settings.grid_big_slider_autoplay;
}
$("#vce-featured-grid").owlCarousel({
margin: 1,
loop: true,
rtl: vce_js_settings.rtl_mode,
autoplay: autoplay,
autoplaySpeed: 500,
autoplayTimeout: autoplay,
autoplayHoverPause: true,
nav: true,
center: true,
fluidSpeed: 100,
items: 1,
navText: ['', ''],
responsive: responsive
});
$(".vce-featured-full-slider").owlCarousel({
loop: true,
nav: true,
rtl: vce_js_settings.rtl_mode,
autoplay: vce_js_settings.full_slider_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_js_settings.full_slider_autoplay,
autoplayHoverPause: true,
center: true,
items: 1,
navText: ['', '']
});
vce_post_widget_slider($('.site-content'));
function vce_post_widget_slider(obj) {
obj.find('.vce-post-slider').each(function() {
var autoplay_time = parseInt($(this).attr('data-autoplay')) * 1000;
var autoplay = autoplay_time ? true : false;
$(this).owlCarousel({
loop: true,
nav: true,
rtl: vce_js_settings.rtl_mode,
autoplay: autoplay,
autoplayTimeout: autoplay_time,
autoplayHoverPause: true,
center: true,
fluidSpeed: 100,
items: 1,
navText: ['', '']
});
});
}
/* MAGNIFIC POPUP */
//.site-content
vce_image_popup($('.site-content'));
function vce_image_popup(obj) {
var item = obj.find('.vce-image-format'),
l = item.length;
if (l) {
item.magnificPopup({
type: 'image',
zoom: {
enabled: true,
duration: 300, // don't foget to change the duration also in CSS
opener: function(element) {
return element.find('img');
}
}
});
}
}
vce_gallery_popup($('.site-content'));
function vce_gallery_popup(obj) {
var item = obj.find('.vce-gallery-big'),
l = item.length;
if (l) {
item.magnificPopup({
type: 'image',
delegate: 'a',
gallery: {
enabled: true
},
zoom: {
enabled: true,
duration: 300, // don't foget to change the duration also in CSS
opener: function(element) {
return element.find('img');
}
},
image: {
titleSrc: function(item) {
var $caption = item.el.closest('.big-gallery-item').find('.gallery-caption');
if ($caption != 'undefined') {
return $caption.text();
}
return '';
}
}
});
}
}
$('body').on('click', '.vce-gallery-slider a', function(e) {
e.preventDefault();
var item_id = $(this).closest('.gallery-item').attr('data-item');
var $wrap = $(this).closest('.gallery');
var $big = $wrap.find('.vce-gallery-big');
$big.find('.big-gallery-item').fadeOut(400);
$big.find('.item-' + item_id).fadeIn(400);
});
/* GALLERY POST SLIDER */
vce_gallery($('.site-content'));
function vce_gallery(obj) {
obj.find('.gallery .vce-gallery-slider').each(function() {
$(this).owlCarousel({
margin: 1,
loop: true,
rtl: vce_js_settings.rtl_mode,
nav: true,
mouseDrag: false,
center: false,
fluidSpeed: 100,
navText: ['', ''],
items: $(this).attr('data-columns'),
autoWidth: false
});
});
}
/* MODULE SLIDERS */
var vce_slider_items_num;
if ($("body").hasClass('vce-sid-none')) {
vce_slider_items_num = {
'b': 2,
'cdf': 3,
'e': 7,
'h': 3
};
} else {
vce_slider_items_num = {
'b': 1,
'cdf': 2,
'e': 5,
'h': 2
};
}
$(".vce-slider-pagination.vce-slider-a, .vce-slider-pagination.vce-slider-g").each(function() {
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(this).owlCarousel({
loop: true,
autoHeight: false,
rtl: vce_js_settings.rtl_mode,
autoWidth: true,
nav: true,
autoplay: vce_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_autoplay,
autoplayHoverPause: true,
fluidSpeed: 100,
navText: ['', ''],
responsive: {
0: {
items: 1,
nav: true,
autoWidth: false,
margin: 10
},
600: {
items: 1,
autoWidth: false
},
768: {
items: 1,
margin: 20,
autoWidth: false
},
1023: {
items: 1,
autoWidth: false,
margin: 20,
}
}
});
});
$(".vce-slider-pagination.vce-slider-b").each(function() {
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(this).owlCarousel({
loop: true,
autoHeight: false,
autoWidth: true,
rtl: vce_js_settings.rtl_mode,
nav: true,
fluidSpeed: 100,
autoplay: vce_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_autoplay,
autoplayHoverPause: true,
navText: ['', ''],
responsive: {
0: {
items: 1,
nav: true,
autoWidth: false,
margin: 10
},
600: {
items: 1,
autoWidth: false
},
768: {
items: 1,
margin: 20,
autoWidth: false
},
1023: {
items: vce_slider_items_num.b,
autoWidth: false,
margin: 20,
}
}
});
});
$(".vce-slider-pagination.vce-slider-c, .vce-slider-pagination.vce-slider-d, .vce-slider-pagination.vce-slider-f").each(function() {
var vce_num_items;
var vce_res_num_items;
if ($(this).parent().parent().hasClass('main-box-half')) {
vce_num_items = 1;
vce_res_num_items = 1;
} else {
vce_num_items = vce_slider_items_num.cdf;
vce_res_num_items = 2;
}
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(this).owlCarousel({
loop: true,
autoHeight: false,
rtl: vce_js_settings.rtl_mode,
autoWidth: true,
nav: true,
fluidSpeed: 100,
autoplay: vce_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_autoplay,
autoplayHoverPause: true,
navText: ['', ''],
responsive: {
0: {
items: 1,
nav: true,
autoWidth: false,
margin: 10
},
670: {
items: vce_res_num_items,
margin: 18,
autoWidth: false
},
768: {
items: vce_res_num_items,
margin: 15,
autoWidth: false
},
1023: {
items: vce_num_items,
autoWidth: false,
margin: 19,
}
}
});
});
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(".vce-slider-pagination.vce-slider-e").each(function() {
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(this).owlCarousel({
loop: true,
autoHeight: false,
autoWidth: true,
rtl: vce_js_settings.rtl_mode,
nav: true,
fluidSpeed: 100,
autoplay: vce_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_autoplay,
autoplayHoverPause: true,
navText: ['', ''],
responsive: {
0: {
items: 2,
nav: true,
autoWidth: false,
margin: 5
},
600: {
items: 3,
margin: 18,
autoWidth: false
},
768: {
items: 5,
margin: 15,
autoWidth: false
},
1023: {
items: vce_slider_items_num.e,
autoWidth: false,
margin: 19,
}
}
});
});
$(".vce-slider-pagination.vce-slider-h").each(function() {
var vce_autoplay;
vce_autoplay = $(this).attr('data-autoplay');
$(this).owlCarousel({
loop: true,
autoHeight: false,
autoWidth: true,
rtl: vce_js_settings.rtl_mode,
nav: true,
fluidSpeed: 100,
autoplay: vce_autoplay,
autoplaySpeed: 500,
autoplayTimeout: vce_autoplay,
autoplayHoverPause: true,
navText: ['', ''],
responsive: {
0: {
items: 1,
nav: true,
autoWidth: false,
margin: 10
},
600: {
items: 1,
autoWidth: false
},
768: {
items: 2,
margin: 20,
autoWidth: false
},
1023: {
items: vce_slider_items_num.h,
autoWidth: false,
margin: 20
}
}
});
});
function vce_sticky_sidebar(fixed) {
if ($(window).width() >= 1024) {
if ($('.vce-sticky').length > 0) {
var content_height = $('#main-wrapper').find('.site-content').last().height();
var sidebar_height = $('#main-wrapper').find('.sidebar').last().height();
var vce_top_position;
if ($('.header-sticky').length) {
vce_top_position = 80;
} else {
vce_top_position = 30;
}
if (content_height > sidebar_height) {
$('#main-wrapper').find('.sidebar').last().css('min-height', content_height - 30);
$(".vce-sticky").stick_in_parent({
parent: ".sidebar",
inner_scrolling: false,
offset_top: vce_top_position
});
if (fixed === true && $(".vce-sticky").last().css('position') == 'absolute') {
$(".vce-sticky").last().css('position', 'fixed').css('top', vce_top_position);
}
} else {
$('.sidebar').css('min-height', sidebar_height);
}
}
} else {
$('.sidebar').each(function() {
$(this).css('height', 'auto');
$(this).css('min-height', '1px');
});
$(".vce-sticky").trigger("sticky_kit:detach");
}
}
$(window).bind('resize', function() {
if ($(window).width() < 1024) {
$('.sidebar.left').insertAfter('.vce-main-content');
} else {
$('.sidebar.left').insertBefore('.vce-main-content');
if($('body').hasClass('sidr-main-open')){
$.sidr('close', 'sidr-main');
$(this).removeClass('nav-open');
}
}
vce_logo();
vce_sticky_sidebar();
//Center elements on resize
$('.vce-featured .vce-featured-info, .vce-lay-h .entry-header').each(function() {
$(this).vceCenter();
});
if (vce_js_settings.lay_fa_grid_center) {
$('#vce-featured-grid .vce-featured-info').each(function() {
$(this).vceCenter();
});
}
});
$('body').imagesLoaded(function() {
/* MATCH HEIGHT FOR LAYOUTS */
$('.vce-lay-c, .vce-sid-none .vce-lay-b, .vce-lay-d, .vce-lay-e, .vce-lay-h').matchHeight();
$('.vce-lay-f').matchHeight(false);
$('.main-box-half .main-box-inside .vce-loop-wrap').matchHeight();
$('.main-box-half').matchHeight();
$('.vce-mega-menu-posts-wrap .mega-menu-link').matchHeight();
/* Initialize sticky sidebar */
vce_sticky_sidebar();
});
//Put left sidebar after main content in responsive mode
if ($(window).width() < 1024 && $('.sidebar.left').length) {
$('.sidebar.left').insertAfter('.vce-main-content');
} else {
$('.sidebar.left').insertBefore('.vce-main-content');
}
/* Fit videos */
$(".meta-media").fitVids();
$(".entry-content").fitVids();
$(".vce-featured-header .vce-hover-effect").hover(function() {
$('.vce-featured-header .vce-featured-header-background').animate({
opacity: vce_js_settings.fa_big_opacity[2]
}, 100);
}, function() {
$('.vce-featured-header .vce-featured-header-background').animate({
opacity: vce_js_settings.fa_big_opacity[1]
}, 100);
});
/* Reverse submenu ul if out of the screen */
$('.nav-menu li').hover(function(e) {
if ($(this).closest('body').width() < $(document).width()) {
$(this).find('ul').addClass('vce-rev');
}
}, function() {
$(this).find('ul').removeClass('vce-rev');
});
/* Responsive navigation */
$('#vce-responsive-nav').sidr({
name: 'sidr-main',
source: '#site-navigation',
speed: 100
});
/*Top bar on resposive navigation */
if (vce_js_settings.top_bar_mobile != 0) {
var mobile_nav = $('#sidr-id-vce_main_navigation_menu');
if ($('#vce_top_navigation_menu').length) {
var top_navigation = $('#vce_top_navigation_menu').children().clone();
var top_navigation_group = $('').append(''+vce_js_settings.top_bar_more_link+'');
if ($('.sidr-class-search-header-wrap').length) {
if( vce_js_settings.top_bar_mobile_group != 0 ){
top_navigation_group.append($('