var THEMEMASCOT = {};
(function ($) {
"use strict";
THEMEMASCOT.isRTL = {
check: function () {
if ($("html").attr("dir") === "rtl") {
return true;
} else {
return false;
}
}
};
THEMEMASCOT.isLTR = {
check: function () {
if ($("html").attr("dir") !== "rtl") {
return true;
} else {
return false;
}
}
};
//Hide Loading Box (Preloader)
function handlePreloader() {
if ($('.preloader').length) {
$('.preloader').delay(200).fadeOut(500);
}
}
//Update Header Style and Scroll to Top
function headerStyle() {
if ($('.main-header').length) {
var windowpos = $(window).scrollTop();
var siteHeader = $('.header-style-one');
var scrollLink = $('.scroll-to-top');
var sticky_header = $('.main-header .sticky-header');
if (windowpos > 100) {
sticky_header.addClass("fixed-header animated slideInDown");
scrollLink.fadeIn(300);
} else {
sticky_header.removeClass("fixed-header animated slideInDown");
scrollLink.fadeOut(300);
}
if (windowpos > 1) {
siteHeader.addClass("fixed-header");
} else {
siteHeader.removeClass("fixed-header");
}
}
}
headerStyle();
//Mobile Nav Hide Show
if ($('.mobile-menu').length) {
var mobileMenuContent = $('.main-header .main-menu .navigation').html();
$('.mobile-menu .navigation').append(mobileMenuContent);
$('.sticky-header .navigation').append(mobileMenuContent);
$('.mobile-menu .close-btn').on('click', function () {
$('body').removeClass('mobile-menu-visible');
});
//Dropdown Button
$('.mobile-menu li.dropdown .dropdown-btn').on('click', function () {
$(this).prev('ul').slideToggle(500);
$(this).toggleClass('active');
});
//Menu Toggle Btn
$('.mobile-nav-toggler').on('click', function () {
$('body').addClass('mobile-menu-visible');
});
//Menu Toggle Btn
$('.mobile-menu .menu-backdrop, .mobile-menu .close-btn').on('click', function () {
$('body').removeClass('mobile-menu-visible');
});
}
//Banner Carousel
if ($('.banner-carousel').length) {
$('.banner-carousel').owlCarousel({
rtl: THEMEMASCOT.isRTL.check(),
animateOut: 'fadeOut',
animateIn: 'fadeIn',
loop: true,
margin: 0,
nav: true,
smartSpeed: 500,
autoHeight: true,
autoplay: true,
autoplayTimeout: 10000,
navText: ['', ''],
responsive: {
0: {
items: 1
},
600: {
items: 1
},
1024: {
items: 1
},
}
});
}
// Testimonial Carousel
if ($('.testimonial-carousel').length) {
$('.testimonial-carousel').owlCarousel({
rtl: THEMEMASCOT.isRTL.check(),
loop: true,
margin: 0,
nav: false,
items: 1,
smartSpeed: 700,
autoplay: 5000,
navText: ['', ''],
responsive: {
0: {
items: 1
},
768: {
items: 2
}
}
});
}
//Fact Counter + Text Count
if ($('.count-box').length) {
$('.count-box').appear(function () {
var $t = $(this),
n = $t.find(".count-text").attr("data-stop"),
r = parseInt($t.find(".count-text").attr("data-speed"), 10);
if (!$t.hasClass("counted")) {
$t.addClass("counted");
$({
countNum: $t.find(".count-text").text()
}).animate({
countNum: n
}, {
duration: r,
easing: "linear",
step: function () {
$t.find(".count-text").text(Math.floor(this.countNum));
},
complete: function () {
$t.find(".count-text").text(this.countNum);
}
});
}
}, {
accY: 0
});
}
// Scroll to a Specific Div
if ($('.scroll-to-target').length) {
$(".scroll-to-target").on('click', function () {
var target = $(this).attr('data-target');
// animate
$('html, body').animate({
scrollTop: $(target).offset().top
}, 1500);
});
}
// Elements Animation
if ($('.wow').length) {
var wow = new WOW({
boxClass: 'wow', // animated element css class (default is wow)
animateClass: 'animated', // animation css class (default is animated)
offset: 0, // distance to the element when triggering the animation (default is 0)
mobile: false, // trigger animations on mobile devices (default is true)
live: true // act on asynchronously loaded content (default is true)
});
wow.init();
}
/* ==========================================================================
When document is Scrollig, do
========================================================================== */
$(window).on('scroll', function () {
headerStyle();
});
/* ==========================================================================
When document is loading, do
========================================================================== */
$(window).on('load', function () {
handlePreloader();
});
})(window.jQuery);