// ----------countdown---------
// Set the date we're counting down to
function aCommerceHotDealTime(date, hotdealID) {
var countDownDate = new Date(date).getTime();
$ = jQuery;
// Update the count down every 1 second
var x = setInterval(function () {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
$(hotdealID).html('
' + days + 'Days
' + hours + 'hours
' + minutes + 'Min
' + seconds + ' Sec
');
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
}
//Quanitity New Add
function acommerce_spinner_up_down() {
jQuery('body').on('tap click', 'div.quantity .quantity-up', function () {
var input = jQuery(this).parent().find('input[type="number"]'),
max = input.attr('max'),
oldValue = parseFloat(input.val());
if (oldValue >= max && '' != max) {
var newVal = oldValue;
} else {
var newVal = oldValue + 1;
}
input.val(newVal);
input.trigger("change");
});
jQuery('body').on('tap click', 'div.quantity .quantity-down, .acommerce_qty_spinner .quantity-down', function () {
var input = jQuery(this).parent().find('input[type="number"]'),
min = input.attr('min'),
oldValue = parseFloat(input.val());
if (oldValue <= min && '' != min) {
var newVal = oldValue;
} else {
var newVal = oldValue - 1;
}
input.val(newVal);
input.trigger("change");
});
}
jQuery(document).ready(function ($) {
// Jquery click function
$('.acommerce-header-cat-title a').click(function () {
$('.acommerce-header-cat-content').toggleClass('acommerce-isactive');
});
// Search Popup Section
$('.acommerce-search svg').click(function (e) {
e.preventDefault();
e.stopPropagation();
$('.acommerce-popup-search').toggleClass('is_active');
});
$('body:not(.acommerce-popup-search)').click(function (event) {
if (event.target.closest(".acommerce-popup-search")) return;
$('.acommerce-popup-search').removeClass('is_active');
});
//aCommerce
jQuery('a.add_to_cart_button').click(function () {
jQuery(this).append('')
});
//Match height Js
$('ul.products li.product,section.our-products.single_category_style_1 li.product').matchHeight();
$('.acommerce_slider_section.carousel.our-products.four-product-slider.py-5 li.product').matchHeight();
$('.latest-blog-details article.blog-single-item .latest-blog-image img').matchHeight();
//acommerce_spinner_up_down
acommerce_spinner_up_down();
$('div.quantity .input-text').before('');
$('div.quantity .input-text').after('');
// -------- Menu-toggle ------
$('.main-menu-toggle').click(function () {
$(this).parent('nav').children('.main-menu-container-collapse').first().slideToggle('1000');
});
/* **
* Sub Menu
**/
$('ul#primary-menu>li.menu-item-has-children>a').append('');
$('nav .menu-item-has-children').append('');
$('nav .page_item_has_children').append('');
$('nav .sub-toggle').click(function () {
$(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000');
$(this).children('.fa-plus').first().toggleClass('fa-minus');
});
$('.navbar .sub-toggle-children').click(function () {
$(this).parent('.page_item_has_children').children('ul.sub-menu').first().slideToggle('1000');
$(this).children('.fa-plus').first().toggleClass('fa-minus');
});
/**
* Sticky nav
*/
if ($(".header_sticky")[0]) {
var windowWidth = $(window).width();
if (windowWidth > 350) {
var sticky_header = 'enable';
if (sticky_header == 'enable') {
try {
$(window).scroll(function () {
var sticky = $('.header_sticky'),
scroll = $(window).scrollTop();
if (scroll > 350) {
sticky.addClass('header_fixed')
} else {
sticky.removeClass('header_fixed');
}
});
} catch (e) {
//console.log( e );
}
}
}
} else {
// Do something if class does not exist
}
// ------homepage-main-slider--------
$('.flexslider').show();
$('.flexslider').flexslider({
animation: "slide"
});
// ------four-product-slider--------
$('.acommerce_slider_section').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 300,
itemMargin: 15,
minItems: 1,
maxItems: 4
});
// -------full-slider-single-product-------
$('.flexslider3').flexslider({
animation: "slide",
});
// ------testimonials-slider--------
$('.testimonial_flexslider_section').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 350,
itemMargin: 20,
minItems: 1,
maxItems: 4
});
// ------testimonials3-slider--------
$('.flexslider7').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 850,
itemMargin: 20,
minItems: 1,
maxItems: 4
});
// ------related products--------
$('.acommerce-hotoffer-single').flexslider({
animation: "slide",
animationLoop: true,
minItems: 1,
maxItems: 1
});
// ------homepage2-four-product-slider--------
$('.flexslider5').flexslider({
animation: "slide",
animationLoop: true,
itemWidth: 260,
itemMargin: 20,
minItems: 1,
maxItems: 4
});
// --------wow--------
// new WOW().init();
// -------masonry jQuery-----
$('.acommerce-blog-grid').masonry({
// options
itemSelector: '.acommerce-grid-item',
columnWidth: 15
});
//
jQuery("div.add-to-wishlist-custom div.yith-wcwl-add-button").on('click', function (event) {
jQuery(this).addClass("yith-wcwl-ajax-loading");
});
});
/**
* Quick View Section
*/
function acommerce_product_single_carousel() {
if (jQuery('.thumbnails').length) {
jQuery('.images, #yith-quick-view-content').each(function () {
var cur_slidesToShow = 1;
var cur_sliderAutoplay = 4000;
var cur_fade = true;
jQuery(this).find('.acommerce-single-woo-slick').slick({
slidesToShow: cur_slidesToShow,
slidesToScroll: cur_slidesToShow,
autoplay: false,
autoplaySpeed: cur_sliderAutoplay,
speed: 500,
dots: false,
fade: cur_fade,
focusOnSelect: true,
arrows: false,
infinite: false,
asNavFor: jQuery(this).find('.thumbnails')
});
jQuery(this).find('.thumbnails').slick({
slidesToShow: 4,
slidesToScroll: 1,
nextArrow: '',
prevArrow: '',
asNavFor: jQuery(this).find('.acommerce-single-woo-slick'),
dots: false,
focusOnSelect: true,
infinite: false,
})
});
}
}
jQuery(document).ajaxComplete(function () {
if (!jQuery('.acommerce-thumbnails-control.slick-slider').length) {
acommerce_thumbnails_slider();
}
});
function acommerce_thumbnails_slider() {
var controls_wrapper, slider, slides, slide, item;
slider = jQuery('#yith-quick-view-content .woocommerce-product-gallery__wrapper');
slides = slider.find('.woocommerce-product-gallery__image');
controls_wrapper = jQuery('');
for (var i = 0; i < slides.length; i++) {
slide = slides[i];
item = '