var viewportMobile = 767; jQuery(document).ready(function(){ jQuery(function($) { $("#burgerMenu").click(function() { $(this).toggleClass('open'); $('#leftBar').toggleClass('show'); }); if ($(window).width() <= viewportMobile) { calculMenuPosition(); } // Script Open Search Function $("#menuCursor").click(function(e) { if ($(window).width() <= viewportMobile) { if (!$(event.target).closest('#menuCursor').length) { return false; } } var speed = 400; $(".dropDown").stop().slideUp(speed); if ($('#menuInput').hasClass('open')) { $("#searchView").stop().slideToggle(speed, function() { $('#menuInput').removeClass('open'); if ($('#searchCarousel').find('.slick-track').length > 0) { // $('#searchCarousel').slick('unslick'); } }); } else { $('#menuInput').addClass('open'); $("#searchView").stop().slideDown(speed); } }); $('#ui-search-carousel-next').click(function() { $('#searchCarousel .slick-next').click(); return false; }); // Script Close Search Function $("#closeSearch").click(function() { var speed = 400; if ($('#menuInput').hasClass('open')) { $("#searchView").stop().slideToggle(speed, function() { $('#menuInput').removeClass('open'); }); } else { $('#menuInput').addClass('open'); $("#searchView").stop().slideDown(speed); } }); $(".blocPopup .close").click(function() { $(".blocPopup:visible").slideUp(400); }); // Script Popup Bottom $(".imgFooter img").click(function() { var speed = 400; var speedOut = 200; if ($(this).attr("class") != "noPopup"){ if ($(this).attr("id") == "imgCopyright") { $(".blocPopup").not("#popupCopyright").slideUp(speedOut); $("#popupCopyright").slideToggle(speed); } else if ($(this).attr("id") == "imgSize") { $(".blocPopup").not("#popupChartSize").slideUp(speedOut, function() { unslickPopup($(this)); }); $("#popupChartSize").slideToggle(speed); if ($('#carouselChartSize').find('.slick-track').length == 0) { $('#carouselChartSize').slick({ slidesToShow: 4, slidesToScroll: 1, }); } } else if ($(this).attr("id") == "imgCurrency") { $(".blocPopup").not("#popupCurrency").slideUp(speedOut, function() { unslickPopup($(this)); }); $("#popupCurrency").slideToggle(speed); initFooterCarousel($("#popupCurrency")); } else if ($(this).attr("id") == "imgLang") { $(".blocPopup").not("#popupLang").slideUp(speedOut, function() { unslickPopup($(this)); }); $("#popupLang").slideToggle(speed); initFooterCarousel($("#popupLang")); } else if ($(this).attr("id") == "imgShipPolicy") { $(".blocPopup").not("#popupPolicy").slideUp(speedOut, function() { unslickPopup($(this)); }); $("#popupPolicy").slideToggle(speed); initFooterCarousel($("#popupPolicy")); } else if ($(this).attr("id") == "imgClip") { $(".blocPopup").not("#popupClip").slideUp(speedOut, function() { unslickPopup($(this)); }); $("#popupClip").slideToggle(speed); initFooterCarousel($("#popupClip")); } else if ($(this).attr("id") == "imgNewsletter") { $(".blocPopup").not("#popupNews").slideUp(speedOut); $("#popupNews").slideToggle(speed); } } }); $("#notification").click(function() { var speed = 400; var speedOut = 200; $(".blocPopup").not(".aartus-welcome-notification").slideUp(speedOut); $(".aartus-welcome-notification").slideToggle(speed); return false; }); $(document.body).on('added_to_cart', function() { var speed = 400; var speedOut = 200; $(".blocPopup").not(".aartus-added-cart-notification").slideUp(speedOut); $(".aartus-added-cart-notification").slideToggle(speed); return false; }); $('#nextSize .ball').click(function() { $('#carouselChartSize .slick-next').click(); return false; }); $('.blocPopupFlex .next .ball').click(function() { $('.blocPopupFlex:visible').find('.slick-next').click(); }); }); // Video Popup jQuery(function($) { var videoUrl = $("#aartus-yt-player").attr("src"); $(".aartus-video-trigger img").click(function() { $(".aartus-video-player").slideDown(); $("#aartus-yt-player").attr("src", videoUrl); }); $(".aartus-video-player .close i.fas").on("click", function(){ $(".aartus-video-player").slideUp(); $("#aartus-yt-player").attr("src", ""); }); }); function calculMenuPosition() { var navHeight = jQuery('#nav').innerHeight(); var menuHeight = jQuery('#menu').innerHeight(); var calculHeight = navHeight + menuHeight; var leftBarHeight = jQuery(window).height() - calculHeight; jQuery('#leftBar').css({'height' : Math.round(leftBarHeight), 'top' : Math.round(calculHeight)}); } function resetMenuPosition() { jQuery('#leftBar').css({'height' : 'inherit', 'top' : 'inherit'}); } function initSearchCarousel() { return; } function initFooterCarousel(id) { if (id.find('.slick-track').length == 0) { id.find('.carouselPopup').slick({ slidesToShow: 3, slidesToScroll: 1, }); id.find('.next').show(); } } function unslickPopup(element) { if (element.find('.slick-track').length > 0) { element.find('.carouselPopup').slick('unslick'); } } }); // Ajax Product Search jQuery(function($) { $(".aartus-search-universal").keyup(function(){ $(document).trigger('aartusProductSearch'); }); $(".aartus-search-universal").keydown(function(){ $(document).trigger('aartusProductSearch'); }); $(document).on('aartusProductSearch', function(){ $(".aartus-search-result-notice").addClass("hide"); $(".aartus-search-result-loader").addClass("active"); var searchBoxVal = $('.aartus-search-universal').val(); if (searchBoxVal.length > 2) { $.ajax({ url: aartus_secure.ajax_url, type: 'POST', data: { action: 'aartus_ajax_uni_search_func', dataType: 'JSON', data: searchBoxVal, security: aartus_secure.security_nonce }, success: function(responce){ var out_data = JSON.parse(responce); var s_sld_len = out_data[0].sld_count; var s_markup = out_data[0].markup; $(".aartus-search-result-wrap").html(s_markup); $('#menuInput').addClass('open'); $("#searchView").stop().slideDown(speed); jQuery("#searchCarousel .slide").css("width", "1000px"); jQuery("#searchCarousel").slick({ slidesToShow: 3, slidesToScroll: 1, infinite: false }); var resultAreaWidht = $(".aartus-search-result-wrap").width(); var oneItemWidth = resultAreaWidht / 3; if (s_sld_len == 1) { $(".aartus-search-result-wrap .slick-track").css("width", oneItemWidth+"px"); $(".aartus-search-result-wrap .slide").css("width", oneItemWidth+"px"); } else if (s_sld_len == 2) { $(".aartus-search-result-wrap .slick-track").css("width", (oneItemWidth*3)+"px"); $(".aartus-search-result-wrap .slide").css("width", oneItemWidth+"px"); } else if (s_sld_len == 3) { $(".aartus-search-result-wrap .slick-track").css("width", (oneItemWidth*2)+"px"); $(".aartus-search-result-wrap .slide").css("width", oneItemWidth+"px"); } else { console.log(); } if (jQuery(window).width() <= 767) { jQuery("#searchCarousel").slick("unslick"); } $(".aartus-search-result-notice").removeClass("hide"); $(".aartus-search-result-loader").removeClass("active"); }, error: function(responce){ console.log(responce); } }); } }); }); // Aartus OS menu js jQuery(function($) { $(".aartus-menu").on("click", function(){ $(this).addClass("actif"); $(".aartus-menu").addClass("inactif"); $(this).removeClass("inactif"); $('#leftBarMiddle .wrapSubmenu').css("display", "flex").hide().fadeIn(); var unqmenuid = $(this).attr("data-menu-unq"); $('.submenu[data-menu-unq='+unqmenuid+']').fadeIn(300); }); $('#leftBarMiddle .closeMenu').click(function() { $('#leftBarMiddle .wrapSubmenu').hide(); $('#leftBarMiddle .icones .menu').removeClass('actif inactif'); $('.submenu').hide(); }); }); // Aartus gradient menu var speed = 600; jQuery(function($) { $(".buttonMenu").click(function(){ var id = $(this).attr("data-id"); $(".dropDown:not([data-id='" + id + "'])").slideUp(speed); if ($(this).hasClass('slick-current')) { $(".dropDown[data-id='" + id + "']").addClass('first'); } $(".dropDown[data-id='" + id + "']").slideToggle(speed, function() { if (!$(this).is(':visible')) { $(this).removeClass('first'); } }); $("#searchView").stop().slideUp(speed); return false; }); $('#carouselMenus').slick({ slidesToShow: 2, slidesToScroll: 1, infinite: false }); $('#arrow').click(function() { $(".dropDown").stop().slideUp(speed); $('#carouselMenus .slick-next').click(); }); }); // Loader Related jQuery(window).load(function($){ setTimeout(function() { jQuery('.wrap-loader').fadeOut(); }, 2000); }); // Cart drawer related var nbCartDrawerProduct = 3; jQuery(function($) { $('.btnDisplayCart').click(function() { $('#cartDrawer').fadeIn(); if ($(window).width() > viewportMobile) { initCarouselCartDrawer(); } return false; }); $('#cartDrawer .close').click(function() { $('#cartDrawer').fadeOut(); }); $('#productsCarousel').on('afterChange', function(e, slick, cur) { var nbSlides = $('#productsCarousel .productRow').length; if (cur + nbCartDrawerProduct === nbSlides) { console.log('End'); $('#cartDrawer .prevProduct').css('display', 'flex'); $('#cartDrawer .nextProduct').hide(); } else if (cur == 0) { $('#cartDrawer .prevProduct').hide(); $('#cartDrawer .nextProduct').css('display', 'flex'); } else { $('#cartDrawer .nextProduct').css('display', 'flex'); $('#cartDrawer .prevProduct').css('display', 'flex'); } }); $('#cartDrawer .nextProduct').click(function() { $('#productsCarousel .slick-next').click(); }); $('#cartDrawer .prevProduct').click(function() { $('#productsCarousel .slick-prev').click(); }); $(window).resize(function() { if ($(window).width() <= viewportMobile) { $('#carouselContact').slick('slickSetOption', 'slidesToShow', 1); if ($('#productsCarousel.slick-slider').length > 0) { $('#productsCarousel').slick('unslick'); } } else { if ($('#cartDrawer').is(':visible')) { if ($('#productsCarousel.slick-slider').length == 0) { initCarouselCartDrawer(); } resizeCarouselCartDrawer(); $('#productsCarousel').slick('reinit'); } $('#carouselContact').slick('slickSetOption', 'slidesToShow', 6); } }); }); function initCarouselCartDrawer() { if (jQuery('#productsCarousel.slick-slider').length == 0) { jQuery('#productsCarousel').slick({ infinite: false, slidesToShow: nbCartDrawerProduct, slidesToScroll: 1, vertical: true, verticalSwiping: true }); if (jQuery('#productsCarousel .productRow').length > nbCartDrawerProduct) { jQuery('#cartDrawer .nextProduct').css('display', 'flex'); } } resizeCarouselCartDrawer(); } function resizeCarouselCartDrawer() { setTimeout(function() { carouselHeight = jQuery('#productsCarousel').height(); var productRowHeight = carouselHeight/nbCartDrawerProduct; jQuery('#cartDrawer .productRow').css('height', Math.ceil(productRowHeight) + 1); }, 100); } // Drawer Cart Settings jQuery(function($){ // Remover cart item from drawer $(".crt-drawer-remove-item").on("click", function(){ var rmv_itm_key = $(this).attr("item-key"); // ajax remove cart item $.ajax({ url: aartus_secure.ajax_url, type: 'POST', data: { action: 'aartus_remov_cart_item_func', dataType: 'JSON', data: rmv_itm_key, security: aartus_secure.security_nonce }, success: function(responce){ var data_rmv_item = responce; $(".productRow[item-key="+data_rmv_item+"]").remove(); }, error: function(responce){ console.log(responce); } }); }); // QTY $(".aartus-cart-drawer-content").on("click", ".cart-drw-itm-mns", function(){ var drwKey = $(this).attr("item-key"); var currentVal = $(".aartus-qty-cart-drawer[item-key="+drwKey+"]").attr("value"); if (currentVal > 1) { var newVal = parseInt(currentVal - 1); $(".aartus-qty-cart-drawer[item-key="+drwKey+"]").attr("value", newVal); $(".quantity[item-key="+drwKey+"]").text(newVal); } }); $(".aartus-cart-drawer-content").on("click", ".cart-drw-itm-pls", function(){ var drwKey = $(this).attr("item-key"); var currentVal = parseInt($(".aartus-qty-cart-drawer[item-key="+drwKey+"]").attr("value")); if (currentVal > 0) { var newVal = currentVal + 1; $(".aartus-qty-cart-drawer[item-key="+drwKey+"]").attr("value", newVal); $(".quantity[item-key="+drwKey+"]").text(newVal); } }); // update cart functionalities $(".aartus-cart-drawer-content").on("click", ".cart-drw-itm-mns, .cart-drw-itm-pls", function(){ var itemKey = $(this).attr("item-key"); var itemQty = $(".aartus-qty-cart-drawer[item-key="+itemKey+"]").val(); var itemPID = $(this).attr("data-product"); // ajax update cart $.ajax({ url: aartus_secure.ajax_url, type: 'POST', data: { action: 'aartus_update_cart_draw_func', dataType: 'JSON', data: { 'itemKey' : itemKey, 'itemQty' : itemQty, 'itemPID' : itemPID, }, security: aartus_secure.security_nonce }, success: function(responce){ $(".cart-draw-item-price[data-key="+itemKey+"]").text(responce); }, error: function(responce){ console.log(responce); } }); }); }); // Ajx cart drawer update after added to cart jQuery(function($) { $(document.body).on('added_to_cart', function(){ $.ajax({ url: aartus_secure.ajax_url, type: 'POST', data: { action: 'aartus_ajax_cart_drawer_update_func', dataType: 'JSON', data: '1', security: aartus_secure.security_nonce }, success: function(responce){ $(".aartus-cart-drawer-content").html(responce); // Cart drawer related var nbCartDrawerProduct = 3; jQuery(function($) { $('.btnDisplayCart').click(function() { $('#cartDrawer').fadeIn(); if ($(window).width() > viewportMobile) { initCarouselCartDrawer(); } return false; }); $('#cartDrawer .close').click(function() { $('#cartDrawer').fadeOut(); }); $('#productsCarousel').on('afterChange', function(e, slick, cur) { var nbSlides = $('#productsCarousel .productRow').length; if (cur + nbCartDrawerProduct === nbSlides) { console.log('End'); $('#cartDrawer .prevProduct').css('display', 'flex'); $('#cartDrawer .nextProduct').hide(); } else if (cur == 0) { $('#cartDrawer .prevProduct').hide(); $('#cartDrawer .nextProduct').css('display', 'flex'); } else { $('#cartDrawer .nextProduct').css('display', 'flex'); $('#cartDrawer .prevProduct').css('display', 'flex'); } }); $('#cartDrawer .nextProduct').click(function() { $('#productsCarousel .slick-next').click(); }); $('#cartDrawer .prevProduct').click(function() { $('#productsCarousel .slick-prev').click(); }); $(window).resize(function() { if ($(window).width() <= viewportMobile) { $('#carouselContact').slick('slickSetOption', 'slidesToShow', 1); if ($('#productsCarousel.slick-slider').length > 0) { $('#productsCarousel').slick('unslick'); } } else { if ($('#cartDrawer').is(':visible')) { if ($('#productsCarousel.slick-slider').length == 0) { initCarouselCartDrawer(); } resizeCarouselCartDrawer(); $('#productsCarousel').slick('reinit'); } $('#carouselContact').slick('slickSetOption', 'slidesToShow', 6); } }); }); function initCarouselCartDrawer() { if (jQuery('#productsCarousel.slick-slider').length == 0) { jQuery('#productsCarousel').slick({ infinite: false, slidesToShow: nbCartDrawerProduct, slidesToScroll: 1, vertical: true, verticalSwiping: true }); if (jQuery('#productsCarousel .productRow').length > nbCartDrawerProduct) { jQuery('#cartDrawer .nextProduct').css('display', 'flex'); } } resizeCarouselCartDrawer(); } function resizeCarouselCartDrawer() { setTimeout(function() { carouselHeight = jQuery('#productsCarousel').height(); var productRowHeight = carouselHeight/nbCartDrawerProduct; jQuery('#cartDrawer .productRow').css('height', Math.ceil(productRowHeight) + 1); }, 100); } }, error: function(responce){ console.log(responce); } }); }); });