jQuery(document).ready(function($) {
if (blossom_pin_data.rtl == '1') {
rtl = true;
} else {
rtl = false;
}
//banner slider
$('.banner-slider').owlCarousel({
loop: true,
autoplay: true,
margin: 8,
nav: true,
dots: false,
lazyload: true,
rtl: rtl,
navText: [' ', ' '],
responsive: {
0: {
items: 1,
margin: 0
},
600: {
items: 2
},
768: {
items: 3
},
1200: {
items: 4
},
1400: {
items: 5
}
},
});
//Home Page Masonry
var $this = $('.blog:not(.no-post) #primary .site-main');
$this.imagesLoaded(function() {
$this.masonry({
itemSelector: '.blog #primary .post'
});
});
// Search Form
var winWidth = $(window).width();
var headerHeight = $('.site-header').outerHeight();
$('.site-header .tools .search-icon').click(function() {
$('.search-form-holder').css('top', headerHeight);
$('body').toggleClass('form-open');
});
// search form for mobile version
$('.mobile-site-header .tools .search-icon').click(function() {
var mobileHeaderHeight = $('.mobile-site-header').outerHeight();
$('.search-form-holder').css('top', mobileHeaderHeight);
$('body').toggleClass('form-open');
});
//for single post scrolling header
if (winWidth > 1024) {
$(window).scroll(function() {
if ($(this).scrollTop() > headerHeight) {
$('.single .single-header').addClass("show");
} else {
$('.single .single-header').removeClass("show");
}
});
}
if (blossom_pin_data.single == '1') {
// When the user scrolls the page, execute myFunction
var totalheight = $('.recommended-post').innerHeight() + $('.comment-section').innerHeight() + $('.instagram-section').innerHeight() + $('.newsletter-section').innerHeight() + $('.site-footer').innerHeight();
window.onscroll = function() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight - parseInt(totalheight);
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
};
}
//primary mobile menu
$('.mobile-menu').prepend('');
$('#mobile-site-navigation ul li.menu-item-has-children').append('');
$('#mobile-site-navigation ul li .arrow-holder').click(function() {
$(this).prev().slideToggle();
$(this).toggleClass('active');
});
$('#toggle-button').click(function() {
// $('.main-navigation').toggleClass('open');
$('body').toggleClass('menu-open');
});
$('.btn-close-menu').click(function() {
$('body').removeClass('menu-open');
$('.main-navigation').removeClass('open');
});
$('.overlay').click(function() {
$('body').removeClass('menu-open');
$('.main-navigation').removeClass('open');
});
$('#toggle-button').click(function(event) {
event.stopPropagation();
});
$('#mobile-site-navigation').click(function(event) {
event.stopPropagation();
});
//for accessibility
$('.main-navigation ul li a').focus(function() {
$(this).parents('li').addClass('focused');
}).blur(function() {
$(this).parents('li').removeClass('focused');
});
// Script for back to top
$(window).scroll(function(){
if($(this).scrollTop() > 300){
$('.back-to-top').fadeIn();
}else{
$('.back-to-top').fadeOut();
}
});
$(".back-to-top").click(function(){
$('html,body').animate({scrollTop:0},600);
});
// $(".insta-icon").prependTo(".profile-link");
});