jQuery(function ($) {
'use strict';
// Header Sticky
$(window).on('scroll',function() {
if ($(this).scrollTop() > 120){
$('.navbar-area').addClass("is-sticky");
}
else{
$('.navbar-area').removeClass("is-sticky");
}
});
// Mean Menu
jQuery('.mean-menu').meanmenu({
meanScreenWidth: "1199"
});
// Others Option For Responsive JS
$(".others-option-for-responsive .dot-menu").on("click", function(){
$(".others-option-for-responsive .container .container").toggleClass("active");
});
// Video Slides
$('.video-slides').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 1,
},
768: {
items: 2,
},
1200: {
items: 2,
}
}
});
// Popup Video
$('.popup-youtube').magnificPopup({
disableOn: 320,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
// Business News Slides
$('.business-news-slides').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 1,
},
768: {
items: 2,
},
1200: {
items: 2,
}
}
});
// Health News Slides
$('.health-news-slides').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 1,
},
768: {
items: 2,
},
1200: {
items: 2,
}
}
});
// Subscribe form
$(".newsletter-form").validator().on("submit", function (event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
formErrorSub();
submitMSGSub(false, "Please enter your email correctly.");
} else {
// everything looks good!
event.preventDefault();
}
});
function callbackFunction (resp) {
if (resp.result === "success") {
formSuccessSub();
}
else {
formErrorSub();
}
}
function formSuccessSub(){
$(".newsletter-form")[0].reset();
submitMSGSub(true, "Thank you for subscribing!");
setTimeout(function() {
$("#validator-newsletter").addClass('hide');
}, 4000)
}
function formErrorSub(){
$(".newsletter-form").addClass("animated shake");
setTimeout(function() {
$(".newsletter-form").removeClass("animated shake");
}, 1000)
}
function submitMSGSub(valid, msg){
if(valid){
var msgClasses = "validation-success";
} else {
var msgClasses = "validation-danger";
}
$("#validator-newsletter").removeClass().addClass(msgClasses).text(msg);
}
// AJAX MailChimp
$(".newsletter-form").ajaxChimp({
url: "https://envytheme.us20.list-manage.com/subscribe/post?u=60e1ffe2e8a68ce1204cd39a5&id=42d6d188d9", // Your url MailChimp
callback: callbackFunction
});
// Go to Top
$(function(){
// Scroll Event
$(window).on('scroll', function(){
var scrolled = $(window).scrollTop();
if (scrolled > 600) $('.go-top').addClass('active');
if (scrolled < 600) $('.go-top').removeClass('active');
});
// Click Event
$('.go-top').on('click', function() {
$("html, body").animate({ scrollTop: "0" }, 500);
});
});
// Sports Slides
$('.sports-slider').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
items: 1,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 2,
},
768: {
items: 1,
},
1200: {
items: 1,
}
}
});
// Tech Slides
$('.tech-slider').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
items: 1,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 2,
},
768: {
items: 1,
},
1200: {
items: 1,
}
}
});
// Breaking News Slides
$('.breaking-news-slides').owlCarousel({
loop: true,
nav: false,
dots: false,
autoplayHoverPause: true,
autoplay: true,
animateOut:"slideOutDown",
animateIn:"flipInX",
items: 1,
margin: 30,
navText: [
"",
""
],
});
// Main News Slides
$('.main-news-slides').owlCarousel({
loop: true,
nav: true,
dots: false,
autoplayHoverPause: true,
autoplay: true,
margin: 30,
navText: [
"",
""
],
responsive: {
0: {
items: 1,
},
576: {
items: 1,
},
768: {
items: 2,
},
1200: {
items: 3,
}
}
});
// FAQ Accordion
$(function() {
$('.accordion').find('.accordion-title').on('click', function(){
// Adds Active Class
$(this).toggleClass('active');
// Expand or Collapse This Panel
$(this).next().slideToggle('fast');
// Hide The Other Panels
$('.accordion-content').not($(this).next()).slideUp('fast');
// Removes Active Class From Other Titles
$('.accordion-title').not($(this)).removeClass('active');
});
});
// Nice Select JS
$('select').niceSelect();
// Count Time
function makeTimer() {
var endTime = new Date("September 20, 3000 17:00:00 PDT");
var endTime = (Date.parse(endTime)) / 1000;
var now = new Date();
var now = (Date.parse(now) / 1000);
var timeLeft = endTime - now;
var days = Math.floor(timeLeft / 86400);
var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600 )) / 60);
var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
if (hours < "10") { hours = "0" + hours; }
if (minutes < "10") { minutes = "0" + minutes; }
if (seconds < "10") { seconds = "0" + seconds; }
$("#days").html(days + "Days");
$("#hours").html(hours + "Hours");
$("#minutes").html(minutes + "Minutes");
$("#seconds").html(seconds + "Seconds");
}
setInterval(function() { makeTimer(); }, 0);
// Preloader
$(window).on('load', function() {
$('.preloader').fadeOut();
$('.preloader-area').addClass('preloader-deactivate');
});
}(jQuery));
// function to set a given theme/color-scheme
function setTheme(themeName) {
localStorage.setItem('theme', themeName);
document.documentElement.className = themeName;
}
// function to toggle between light and dark theme
function toggleTheme() {
if (localStorage.getItem('theme') === 'theme-dark') {
setTheme('theme-light');
} else {
setTheme('theme-dark');
}
}
// Immediately invoked function to set the theme on initial load
(function () {
if (localStorage.getItem('theme') === 'theme-dark') {
setTheme('theme-dark');
document.getElementById('slider').checked = false;
} else {
setTheme('theme-light');
document.getElementById('slider').checked = true;
}
})();