(function ($) {
"use strict";
var $main_window = $(window);
// Preloader
$main_window.on("load", function () {
$(".preloader").delay(1000).fadeOut(500);
});
// sticky
$(window).on('scroll', function () {
var scroll = $(window).scrollTop();
if (scroll < 220) {
$("#header-sticky").removeClass("sticky-menu");
} else {
$("#header-sticky").addClass("sticky-menu");
}
});
// RESPONSIVE MENU
$('.responsive').on('click', function (e) {
$('#mobile-menu').slideToggle();
});
// meanmenu
$('#mobile-menu').meanmenu({
meanMenuContainer: '.mobile-menu',
meanScreenWidth: "992"
});
$('.info-bar').on('click', function () {
$('.extra-info').addClass('info-open');
})
$('.close-icon').on('click', function () {
$('.extra-info').removeClass('info-open');
})
// menu toggle
$(".main-menu li a").on('click', function () {
if ($(window).width() < 1200) {
$("#mobile-menu").slideUp();
}
});
// smoth scroll
$(function () {
$('a.smoth-scroll').on('click', function (event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 100
}, 1000);
event.preventDefault();
});
});
// featured-post-slider
$('.category-post-slider-active').slick({
dots: false,
infinite: true,
arrows: false,
autoplay:true,
autoplaySpeed:2500,
speed: 2000,
slidesToShow: 3,
slidesToScroll: 1,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
infinite: true,
dots: true
}
},
{
breakpoint: 992,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
// scrollToTop
$.scrollUp({
scrollName: 'scrollUp',
topDistance: '300',
topSpeed: 300,
animation: 'fade',
animationInSpeed: 200,
animationOutSpeed: 200,
scrollText: '',
activeOverlay: false,
});
// isotop
$(".element").each(function() {
var a = $(this);
a.typed({
strings: a.attr("data-elements").split(","),
typeSpeed: 100,
backDelay: 3e3
})
})
})(jQuery);
accessblogtown();
function accessblogtown() {
jQuery( document ).on( 'keydown', function( e ) {
if ( jQuery( window ).width() > 992 ) {
return;
}
var activeElement = document.activeElement;
var menuItems = jQuery( '#primary .menu-item > a' );
var firstEl = jQuery( '.menu-toggle' );
var lastEl = menuItems[ menuItems.length - 1 ];
var tabKey = event.keyCode === 9;
var shiftKey = event.shiftKey;
if ( ! shiftKey && tabKey && lastEl === activeElement ) {
event.preventDefault();
firstEl.focus();
}
} );
}
jQuery(document).ready(function($) {
//main navigation
$('.main-navigation ul li.menu-item-has-children').find('> a').after('');
$('.main-navigation ul li.page_item_has_children').find('> a').after('');
$('.main-navigation ul li button.submenu-toggle').on('click', function () {
$(this).parent('li.menu-item-has-children').toggleClass('active');
$(this).parent('li.page_item_has_children').toggleClass('active');
$(this).siblings('.sub-menu').stop(true, false, true).slideToggle();
$(this).siblings('.children').stop(true, false, true).slideToggle();
});
$('.main-navigation .toggle-button').click(function(){
$('.primary-menu-list').animate({
width: 'toggle',
});
});
$('.main-navigation .close').click(function(){
$('.primary-menu-list').animate({
width: 'toggle',
});
});
//for accessibility
$('.main-navigation ul li a, .main-navigation ul li button').focus(function() {
$(this).parents('li').addClass('focused');
}).blur(function() {
$(this).parents('li').removeClass('focused');
});
//tab js
$('.tab-btn').click(function(){
var divId = $(this).attr('id');
$('.tab-btn').removeClass('active');
$(this).addClass('active');
$('.tab-content').stop(true, false, true);
$('.tab-content').removeClass('active');
$('#'+divId+'-content').stop(true, false, true).addClass('active');
});
});