(function ($) {
"use strict";
// Spinner
var spinner = function () {
setTimeout(function () {
if ($('#spinner').length > 0) {
$('#spinner').removeClass('show');
}
}, 3000);
};
spinner();
// Initiate the wowjs
new WOW().init();
// Sticky Navbar
$(window).scroll(function () {
if ($(this).scrollTop() > 300) {
$('.sticky-top').css('top', '0px');
} else {
$('.sticky-top').css('top', '-100px');
}
});
// Dropdown on mouse hover
const $dropdown = $(".dropdown");
const $dropdownToggle = $(".dropdown-toggle");
const $dropdownMenu = $(".dropdown-menu");
const showClass = "show";
$(window).on("load resize", function() {
if (this.matchMedia("(min-width: 992px)").matches) {
$dropdown.hover(
function() {
const $this = $(this);
$this.addClass(showClass);
$this.find($dropdownToggle).attr("aria-expanded", "true");
$this.find($dropdownMenu).addClass(showClass);
},
function() {
const $this = $(this);
$this.removeClass(showClass);
$this.find($dropdownToggle).attr("aria-expanded", "false");
$this.find($dropdownMenu).removeClass(showClass);
}
);
} else {
$dropdown.off("mouseenter mouseleave");
}
});
// Back to top button
$(window).scroll(function () {
if ($(this).scrollTop() > 300) {
$('.back-to-top').fadeIn('slow');
} else {
$('.back-to-top').fadeOut('slow');
}
});
$('.back-to-top').click(function () {
$('html, body').animate({scrollTop: 0}, 1500, 'easeInOutExpo');
return false;
});
// Header carousel
$(".header-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1500,
items: 1,
dots: false,
loop: true,
nav : true,
navText : [
'',
''
]
});
// Testimonials carousel
$(".testimonial-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1000,
center: true,
margin: 24,
dots: true,
loop: true,
nav : false,
responsive: {
0:{
items:1
},
768:{
items:2
},
992:{
items:3
}
}
});
})(jQuery);
// Sticky form search
// Get the modal
var modal = document.getElementById("searchModal");
// Get the button that opens the modal
var btn = document.getElementById("searchButton");
// Get the element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}