(function($) { "use strict"; /*---------------------------------------- bootstrap dropdown -------------------------------------------*/ // add slidedown animation to bootstrap dropdown when expanding. $('.dropdown').on('show.bs.dropdown', function() { $(this).find('.dropdown-menu').first().stop(true, true).slidedown(); }); // add slideup animation to bootstrap dropdown when collapsing. $('.dropdown').on('hide.bs.dropdown', function() { $(this).find('.dropdown-menu').first().stop(true, true).slideup(); }); /*--------------------- toggle search bar --------------------- */ $(".search-btn").on("click", function() { $(this).toggleclass('active'); $('.dropdown_search').slidetoggle('medium'); }); /*--------------------------- menu fixed on scroll active ------------------------------ */ $(window).on("scroll", function(e) { var window_top = $(window).scrolltop() + 1; if (window_top > 250) { $(".sticky-nav").addclass("menu_fixed animated fadeindown"); } else { $(".sticky-nav").removeclass("menu_fixed animated fadeindown"); } }); /*--------------------------- nice select ------------------------------ */ $('select.shop-sort').niceselect(); /*--------------------- venobox --------------------- */ $('.venobox').venobox(); /*--------------------- /*--------------------------- commons variables ------------------------------ */ var $window = $(window), $body = $("body"); /*--------------------------------- off canvas function -----------------------------------*/ (function() { var $offcanvastoggle = $(".offcanvas-toggle"), $offcanvas = $(".offcanvas"), $offcanvasoverlay = $(".offcanvas-overlay"), $mobilemenutoggle = $(".mobile-menu-toggle"); $offcanvastoggle.on("click", function(e) { e.preventdefault(); var $this = $(this), $target = $this.attr("href"); $body.addclass("offcanvas-open"); $($target).addclass("offcanvas-open"); $offcanvasoverlay.fadein(); if ($this.parent().hasclass("mobile-menu-toggle")) { $this.addclass("close"); } }); $(".offcanvas-close, .offcanvas-overlay").on("click", function(e) { e.preventdefault(); $body.removeclass("offcanvas-open"); $offcanvas.removeclass("offcanvas-open"); $offcanvasoverlay.fadeout(); $mobilemenutoggle.find("a").removeclass("close"); }); })(); /*---------------------------------- off canvas menu -----------------------------------*/ function mobileoffcanvasmenu() { var $offcanvasnav = $(".offcanvas-menu, .overlay-menu"), $offcanvasnavsubmenu = $offcanvasnav.find(".sub-menu"); /*add toggle button with off canvas sub menu*/ $offcanvasnavsubmenu.parent().prepend(''); /*category sub menu toggle*/ $offcanvasnav.on("click", "li a, .menu-expand", function(e) { var $this = $(this); if ($this.attr("href") === "#" || $this.hasclass("menu-expand")) { e.preventdefault(); if ($this.siblings("ul:visible").length) { $this.parent("li").removeclass("active"); $this.siblings("ul").slideup(); $this.parent("li").find("li").removeclass("active"); $this.parent("li").find("ul:visible").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(); } } }); } mobileoffcanvasmenu(); /*---------------------------------- * offcanvas: user panel ----------------------------------*/ function mobileoffcanvasuserpanel() { var $offcanvasnav = $('.offcanvas-userpanel'), $offcanvasnavsubmenu = $offcanvasnav.find('.user-sub-menu'); /*add toggle button with off canvas sub menu*/ $offcanvasnavsubmenu.parent().prepend(''); /*category sub menu toggle*/ $offcanvasnav.on('click', 'li a, .offcanvas__user-expand', function(e) { var $this = $(this); if ($this.attr('href') === '#' || $this.hasclass('offcanvas__user-expand')) { e.preventdefault(); if ($this.siblings('ul:visible').length) { $this.parent('li').removeclass('active'); $this.siblings('ul').slideup(); $this.parent('li').find('li').removeclass('active'); $this.parent('li').find('ul:visible').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(); } } }); } mobileoffcanvasuserpanel(); /*--------------------- hero slider ---------------------- */ var heroslider = new swiper('.hero-slider.swiper-container', { loop: true, speed: 1000, effect: "fade", autoplay: { delay: 7000, disableoninteraction: false, }, pagination: { el: '.swiper-pagination', clickable: true, }, // navigation arrows navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', } }); /*--------------------- category slider ---------------------- */ var categoryslider = new swiper('.category-slider.swiper-container', { loop: true, slidesperview: 5, spacebetween: 30, speed: 1500, autoplay: { delay: 7000, disableoninteraction: false, }, breakpoints: { 0: { slidesperview: 2, }, 478: { slidesperview: 2, }, 576: { slidesperview: 2, }, 768: { slidesperview: 3, }, 992: { slidesperview: 4, }, 1200: { slidesperview: 5, }, }, }); /*--------------------- blog slider ---------------------- */ var blogslider = new swiper('.blog-slider.swiper-container', { loop: true, slidesperview: 3, spacebetween: 30, speed: 1500, // navigation arrows navigation: { nextel: ".swiper-button-next", prevel: ".swiper-button-prev", }, breakpoints: { 0: { slidesperview: 1, }, 478: { slidesperview: 1, }, 576: { slidesperview: 1, }, 768: { slidesperview: 2, }, 992: { slidesperview: 2, }, 1200: { slidesperview: 3, }, }, }); /*--------------------- new product slider ---------------------- */ var productslider = new swiper('.new-product-slider.swiper-container', { slidesperview: 4, spacebetween: 30, speed: 1500, loop: true, // navigation arrows navigation: { nextel: ".swiper-button-next", prevel: ".swiper-button-prev", }, breakpoints: { 0: { slidesperview: 1, }, 478: { slidesperview: 2, }, 576: { slidesperview: 2, }, 768: { slidesperview: 3, }, 992: { slidesperview: 3, }, 1200: { slidesperview: 4, }, }, }); /*--------------------------- quick view slider ------------------------------ */ var gallerythumb = new swiper('.gallery-thumbs', { spacebetween: 10, slidesperview: 4, freemode: true, watchslidesvisibility: true, watchslidesprogress: true, }); var gallerytop = new swiper('.gallery-top', { spacebetween: 0, loop: true, navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', }, thumbs: { swiper: gallerythumb } }); /*--------------------------- product details slider ------------------------------ */ var zoomthumb = new swiper('.zoom-thumbs', { spacebetween: 10, slidesperview: 4, freemode: true, watchslidesvisibility: true, watchslidesprogress: true, }); var zoomtop = new swiper('.zoom-top', { spacebetween: 0, navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', }, thumbs: { swiper: zoomthumb } }); /*--------------------------- product details slider ------------------------------ */ var zoomthumb = new swiper('.zoom-thumbs-2', { spacebetween: 0, slidesperview: 4, direction: 'vertical', freemode: true, watchslidesvisibility: true, watchslidesprogress: true, }); var zoomtop = new swiper('.zoom-top-2', { spacebetween: 0, loop: true, navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', }, thumbs: { swiper: zoomthumb } }); /*------------------------------- product gallery - image zoom --------------------------------*/ $('.zoom-image-hover').zoom(); /*---------------------------- 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 > 1) { var newval = parsefloat(oldvalue) - 1; } else { newval = 1; } } $button.parent().find("input").val(newval); }); /*------------------------------ single product slider -----------------------------------*/ var swiper = new swiper(".single-product-slider", { slidesperview: 4, spacebetween: 20, speed: 1500, loop: true, navigation: { nextel: ".swiper-button-next", prevel: ".swiper-button-prev", }, breakpoints: { 0: { slidesperview: 1, }, 478: { slidesperview: 1, }, 576: { slidesperview: 2, }, 768: { slidesperview: 3, }, 992: { slidesperview: 3, }, 1024: { slidesperview: 4, }, 1200: { slidesperview: 4, }, }, }); /*------------------------------- create an account toggle ---------------------------------*/ $(".checkout-toggle2").on("click", function() { $(".open-toggle2").slidetoggle(1000); }); $(".checkout-toggle").on("click", function() { $(".open-toggle").slidetoggle(1000); }); /*--------------------- scroll up --------------------- */ $.scrollup({ scrolltext: '', easingtype: "linear", scrollspeed: 900, animation: "fade", }); /*--------------------- countdown --------------------- */ $("[data-countdown]").each(function() { var $this = $(this), finaldate = $(this).data("countdown"); $this.countdown(finaldate, function(event) { $this.html(event.strftime('%-ddays
%-hhours
%mmins
%ssec
')); }); }); /*----------------------------- blog gallery slider -------------------------------- */ var swiper = new swiper(".blog-post-media", { slidesperview: 1, spacebetween: 0, loop: true, navigation: { nextel: ".swiper-button-next", prevel: ".swiper-button-prev", }, }); /********************************************* * company logo slider active - 7 grid single rows **********************************************/ var companylogoslider = new swiper('.company-logo-slider.swiper-container', { slidesperview: 5, speed: 1500, loop: true, autoplay: { delay: 2000, disableoninteraction: false, }, // navigation arrows navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', }, breakpoints: { 0: { slidesperview: 2, }, 480: { slidesperview: 2, }, 768: { slidesperview: 3, }, 992: { slidesperview: 4, }, 1200: { slidesperview: 5, }, } }); })(jquery);