(function ($) { "use strict"; /*------ Wow Active ----*/ new WOW().init(); /*--- Language currency active ----*/ $('.language-dropdown-active').on('click', function(e) { e.preventDefault(); $('.language-dropdown').slideToggle(400); }); $('.currency-dropdown-active').on('click', function(e) { e.preventDefault(); $('.currency-dropdown').slideToggle(400); }); /*------------------------- Category active --------------------------*/ $('.category-show').on('click', function(e) { e.preventDefault(); $('.category-hide, .sidenav-mobile-categori-hide').slideToggle(900); }); $('.category-show').keydown(function(e){ if (e.keyCode === 27) { $('.category-hide').css("display", "none"); } }); $('.category-not-visible').on('blur','li:last', function(e) { $('.category-hide').css("display", "none"); }); $('.category-hide').keydown(function(e){ if (e.keyCode === 27) { $('.category-hide').css("display", "none"); $('.category-show').focus(); } }); /*---------------------------- Cart Plus Minus Button ------------------------------ */ var CartPlusMinus = $('.cart-plus-minus'); CartPlusMinus.prepend('
-
'); CartPlusMinus.append('
+
'); $(".qtybutton").on("click", function() { var $button = $(this); var oldValue = $button.parent().find("input").val(); if ($button.text() === "+") { var newVal = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below zero if (oldValue > 0) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 1; } } $button.parent().find("input").val(newVal); }); $('#exampleModal').on('shown.bs.modal', function () { $('.quickview-slide-active').slick({ slidesToShow: 3, slidesToScroll: 1, fade: false, loop: true, dots: false, arrows: true, prevArrow: '', nextArrow: '', responsive: [ { breakpoint: 1199, settings: { slidesToShow: 3, } }, { breakpoint: 991, settings: { slidesToShow: 3, } }, { breakpoint: 767, settings: { slidesToShow: 3, } }, { breakpoint: 575, settings: { slidesToShow: 2, } } ] }); $('.quickview-slide-active a').on('click', function() { $('.quickview-slide-active a').removeClass('active'); }) }) /*------- Color active -----*/ $('.pro-details-color-content').on('click', 'a', function(e){ e.preventDefault(); $(this).addClass('active').parent().siblings().children('a').removeClass('active'); }); /*-------------------------------- Social icon active -----------------------------------*/ if ($('.pro-details-action').length) { var $body = $('body'), $cartWrap = $('.pro-details-action'), $cartContent = $cartWrap.find('.product-dec-social'); $cartWrap.on('click', '.social', function(e) { e.preventDefault(); var $this = $(this); if (!$this.parent().hasClass('show')) { $this.siblings('.product-dec-social').addClass('show').parent().addClass('show'); } else { $this.siblings('.product-dec-social').removeClass('show').parent().removeClass('show'); } }); /*Close When Click Outside*/ $body.on('click', function(e) { var $target = e.target; if (!$($target).is('.pro-details-action') && !$($target).parents().is('.pro-details-action') && $cartWrap.hasClass('show')) { $cartWrap.removeClass('show'); $cartContent.removeClass('show'); } }); } /* NiceSelect */ $('.nice-select').niceSelect(); /*--------------------- mobile-menu --------------------- */ var $offCanvasNav = $('.mobile-menu , .category-menu-dropdown'), $offCanvasNavSubMenu = $offCanvasNav.find('.dropdown'); /*Add Toggle Button With Off Canvas Sub Menu*/ $offCanvasNavSubMenu.parent().prepend(''); /*Close Off Canvas Sub Menu*/ $offCanvasNavSubMenu.slideUp(); /*Category Sub Menu Toggle*/ $offCanvasNav.on('click', 'li a, li .menu-expand', function(e) { var $this = $(this); if ( ($this.parent().attr('class').match(/\b(menu-item-has-children|has-children|has-sub-menu)\b/)) && ($this.attr('href') === '#' || $this.hasClass('menu-expand')) ) { e.preventDefault(); if ($this.siblings('ul:visible').length){ $this.parent('li').removeClass('active'); $this.siblings('ul').slideUp(); } else { $this.parent('li').addClass('active'); $this.closest('li').siblings('li').removeClass('active').find('li').removeClass('active'); $this.closest('li').siblings('li').find('ul:visible').slideUp(); $this.siblings('ul').slideDown(); } } }); /*------ Hero slider active ----*/ $('.hero-slider-active').slick({ slidesToShow: 1, slidesToScroll: 1, fade: true, loop: true, dots: false, arrows: true, prevArrow: '', nextArrow: '', }); /*------ Product slider active 2 ----*/ $('.product-slider-active-2').slick({ slidesToShow: 3, slidesToScroll: 1, fade: false, loop: true, dots: true, rows: 2, arrows: false, responsive: [ { breakpoint: 1199, settings: { slidesToShow: 2, } }, { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 767, settings: { slidesToShow: 1, } }, { breakpoint: 575, settings: { slidesToShow: 1, } } ] }); /*-------------------------------- Product slider active 9 -----------------------------------*/ $('.product-slider-active-9').slick({ slidesToShow: 4, slidesToScroll: 1, fade: false, loop: true, dots: true, arrows: false, responsive: [ { breakpoint: 1199, settings: { slidesToShow: 3, } }, { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 767, settings: { slidesToShow: 2, } }, { breakpoint: 575, settings: { slidesToShow: 1, } } ] }); /*------ Product slider active 2 ----*/ $('.brand-logo-wrap-2').slick({ slidesToShow: 5, slidesToScroll: 2, fade: false, loop: true, dots: false, arrows: false, responsive: [ { breakpoint: 1199, settings: { slidesToShow: 2, } }, { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 767, settings: { slidesToShow: 1, } }, { breakpoint: 575, settings: { slidesToShow: 1, } } ] }); //adding to favorite $('body').on('click', '.add-favorite', function() { var post_id = $(this).data('post_id'); $.ajax({ url: myAjax.ajaxurl, type: 'POST', data: { 'action': 'favorite', 'post_id': post_id, }, success: function(data) { $('.fv_' + post_id).html('In favorite'); $('.num-favorite').html(data); }, }); }); //deleting from favorite $('body').on('click', '.delete-favorite', function() { var post_id = $(this).data('post_id'); $.ajax({ url: myAjax.ajaxurl, type: 'POST', data: { 'action': 'delfavorite', 'post_id': post_id, }, success: function(data) { $('.fv_' + post_id).html('Deleted'); $('.num-favorite').html(data); }, }); }); })(jQuery);