(function ($) {
"use strict";
// Spinner
var spinner = function () {
setTimeout(function () {
if ($('#spinner').length > 0) {
$('#spinner').removeClass('show');
}
}, 1);
};
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;
});
// Modal Video
$(document).ready(function () {
var $videoSrc;
$('.btn-play').click(function () {
$videoSrc = $(this).data("src");
});
console.log($videoSrc);
$('#videoModal').on('shown.bs.modal', function (e) {
$("#video").attr('src', $videoSrc + "?autoplay=1&modestbranding=1&showinfo=0");
})
$('#videoModal').on('hide.bs.modal', function (e) {
$("#video").attr('src', $videoSrc);
})
});
// Facts counter
$('[data-toggle="counter-up"]').counterUp({
delay: 10,
time: 2000
});
// Date and time picker
$('.date').datetimepicker({
format: 'L'
});
$('.time').datetimepicker({
format: 'LT'
});
// Rating
$("#halfstarsReview").rating({
"half": true,
"color": "#FEA116",
"click": function (e) {
console.log(e);
$("#halfstarsInput").val(e.stars);
}
});
// Header carousel
$(".header-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1500,
items: 1,
dots: true,
loop: true,
nav : true,
navText : [
'',
''
]
});
// Testimonials carousel
$(".testimonial-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1000,
margin: 25,
dots: false,
loop: true,
nav : true,
navText : [
'',
''
],
responsive: {
0:{
items:1
},
768:{
items:2
}
}
});
// Testimonials carousel center
$(".testimonial-carousel-center").owlCarousel({
autoplay: true,
smartSpeed: 1000,
center: true,
dots: false,
loop: true,
nav : true,
navText : [
'',
''
],
responsive: {
0:{
items:1
},
768:{
items:2
}
}
});
// Related post carousel
$(".related-carousel").owlCarousel({
autoplay: true,
margin: 30,
dots: false,
loop: true,
nav : true,
navText : [
'',
''
],
responsive: {
0:{
items:1
},
768:{
items:2
}
}
});
// Gallery isotope and filter
var portfolioIsotope = $('.portfolio-container').isotope({
itemSelector: '.portfolio-item',
layoutMode: 'fitRows'
});
$('#portfolio-flters li').on('click', function () {
$("#portfolio-flters li").removeClass('active');
$(this).addClass('active');
portfolioIsotope.isotope({filter: $(this).data('filter')});
});
})(jQuery);