( function($) {
/**
* Mobile menu
*/
$( '.dropdown-toggle' ).on( 'click', function(){
$( this ).toggleClass( 'toggled' );
$( this ).next().slideToggle();
} );
// Function to show the menu
function show_menu() {
$( '.nav-parent' ).addClass( 'mobile-menu-open' );
$( '.mobile-menu-overlay' ).addClass( 'mobile-menu-active' );
}
// Function to hide the menu
function hide_menu(){
$( '.nav-parent' ).removeClass( 'mobile-menu-open' );
$( '.mobile-menu-overlay' ).removeClass( 'mobile-menu-active' );
}
$( '.menubar-right' ).on( 'click', show_menu );
$( '.mobile-menu-overlay' ).on( 'click', hide_menu );
$( '.menubar-close' ).on( 'click', hide_menu );
// Menu show and hide in focus attributes
$('.main-navigation ul li a').focus(function(){
$(this).parent().addClass('focus');
});
$('.main-navigation ul li a').focusout(function(){
if(!$(this).parent().hasClass('menu-item-has-children')) {
$(this).parent().removeClass('focus');
}
});
$('.main-navigation ul .sub-menu .menu-item:last-child').focusout(function() {
if(!$(this).hasClass('focus')) {
$(this).parent().parent().removeClass('focus');
}
});
$(window).click(function(){
$('.main-navigation ul li').removeClass('focus');
$('#navbarmenus').removeClass('show');
});
// Add class in navigation alt search form
$('.search-form .search-icon').click(function() {
$('.search-form').toggleClass('search-form-show');
});
$('.search-form .close-icon').click(function() {
$('.search-form').removeClass('search-form-show');
});
// Menu bar show and hide in focus attributes
$('#navbarmenus .menu-item:last-child').focusout(function() {
$('#navbarmenus, .menu-overlay-bg').removeClass('show');
});
$( ".menu-item-has-children" ).focus(function() {
alert( "Handler for .focus() called." );
});
/**
* Slick Slider
*/
$( '.ct-slick' ).slick( {
nextArrow: '',
prevArrow: '',
});
$( '.ct-testimonial-slider' ).slick();
/**
* Flipbox responsive
*/
$( '.flip-front' ).each( function() {
$height = $( this ).height();
$( this ).parent().parent().css( 'min-height', $height + 'px' );
} );
$( window ).on( 'resize', function() {
$( '.flip-front' ).each( function() {
$height = $( this ).height();
$( this ).parent().parent().css( 'min-height', $height + 'px' );
} );
} );
/**
* Back to Top
*/
$( '#back-to-top' ).on( 'click', function( e ){
e.preventDefault();
$( "html, body" ).animate( {scrollTop: 0}, 1000 );
} );
$( window ).scroll( function() {
if ( $( this ).scrollTop() > 800 ) {
$( '#back-to-top' ).fadeIn();
} else {
$( '#back-to-top' ).fadeOut();
}
} );
} )( jQuery );