'}}),e(t).on("click","[data-fancybox-share]",function(){var t,o,i=e.fancybox.getInstance(),a=i.current||null;a&&("function"===e.type(a.opts.share.url)&&(t=a.opts.share.url.apply(a,[i,a])),o=a.opts.share.tpl.replace(/\{\{media\}\}/g,"image"===a.type?encodeURIComponent(a.src):"").replace(/\{\{url\}\}/g,encodeURIComponent(t)).replace(/\{\{url_raw\}\}/g,n(t)).replace(/\{\{descr\}\}/g,i.$caption?encodeURIComponent(i.$caption.text()):""),e.fancybox.open({src:i.translate(i,o),type:"html",opts:{touch:!1,animationEffect:!1,afterLoad:function(t,e){i.$refs.container.one("beforeClose.fb",function(){t.close(null,0)}),e.$content.find(".fancybox-share__button").click(function(){return window.open(this.href,"Share","width=550, height=450"),!1})},mobile:{autoFocus:!1}}}))})}(document,jQuery),function(t,e,n){"use strict";function o(){var e=t.location.hash.substr(1),n=e.split("-"),o=n.length>1&&/^\+?\d+$/.test(n[n.length-1])?parseInt(n.pop(-1),10)||1:1,i=n.join("-");return{hash:e,index:o<1?1:o,gallery:i}}function i(t){""!==t.gallery&&n("[data-fancybox='"+n.escapeSelector(t.gallery)+"']").eq(t.index-1).focus().trigger("click.fb-start")}function a(t){var e,n;return!!t&&(e=t.current?t.current.opts:t.opts,""!==(n=e.hash||(e.$orig?e.$orig.data("fancybox")||e.$orig.data("fancybox-trigger"):""))&&n)}n.escapeSelector||(n.escapeSelector=function(t){return(t+"").replace(/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t})}),n(function(){!1!==n.fancybox.defaults.hash&&(n(e).on({"onInit.fb":function(t,e){var n,i;!1!==e.group[e.currIndex].opts.hash&&(n=o(),(i=a(e))&&n.gallery&&i==n.gallery&&(e.currIndex=n.index-1))},"beforeShow.fb":function(n,o,i,s){var r;i&&!1!==i.opts.hash&&(r=a(o))&&(o.currentHash=r+(o.group.length>1?"-"+(i.index+1):""),t.location.hash!=="#"+o.currentHash&&(s&&!o.origHash&&(o.origHash=t.location.hash),o.hashTimer&&clearTimeout(o.hashTimer),o.hashTimer=setTimeout(function(){"replaceState"in t.history?(t.history[s?"pushState":"replaceState"]({},e.title,t.location.pathname+t.location.search+"#"+o.currentHash),s&&(o.hasCreatedHistory=!0)):t.location.hash=o.currentHash,o.hashTimer=null},300)))},"beforeClose.fb":function(n,o,i){i&&!1!==i.opts.hash&&(clearTimeout(o.hashTimer),o.currentHash&&o.hasCreatedHistory?t.history.back():o.currentHash&&("replaceState"in t.history?t.history.replaceState({},e.title,t.location.pathname+t.location.search+(o.origHash||"")):t.location.hash=o.origHash),o.currentHash=null)}}),n(t).on("hashchange.fb",function(){var t=o(),e=null;n.each(n(".fancybox-container").get().reverse(),function(t,o){var i=n(o).data("FancyBox");if(i&&i.currentHash)return e=i,!1}),e?e.currentHash===t.gallery+"-"+t.index||1===t.index&&e.currentHash==t.gallery||(e.currentHash=null,e.close()):""!==t.gallery&&i(t)}),setTimeout(function(){n.fancybox.getInstance()||i(o())},50))})}(window,document,jQuery),function(t,e){"use strict";var n=(new Date).getTime();e(t).on({"onInit.fb":function(t,e,o){e.$refs.stage.on("mousewheel DOMMouseScroll wheel MozMousePixelScroll",function(t){var o=e.current,i=(new Date).getTime();e.group.length<2||!1===o.opts.wheel||"auto"===o.opts.wheel&&"image"!==o.type||(t.preventDefault(),t.stopPropagation(),o.$slide.hasClass("fancybox-animated")||(t=t.originalEvent||t,i-n<250||(n=i,e[(-t.deltaY||-t.deltaX||t.wheelDelta||-t.detail)<0?"next":"previous"]())))})}})}(document,jQuery);	document.addEventListener('lazybeforeunveil', function(e){ if ((e.target.parentElement) && (e.target.nextElementSibling)) { var parent = e.target.parentElement; var sibling = e.target.nextElementSibling; if (sibling.classList.contains('js-lazy-loading-preloader')) { sibling.style.display = 'none'; parent.style.display = 'block'; } } }); window.lazySizesConfig = window.lazySizesConfig || {}; lazySizesConfig.hFac = 0.4; $(document).ready(function(){ $(".js-notification-close").on( "click", function(e) { e.preventDefault(); $(this).closest(".js-notification").hide(); }); var $js_notification_status_page = $(".js-notification-status-page"); if ($js_notification_status_page.size() > 0){ if (LS.shouldShowOrderStatusNotification($js_notification_status_page.data('url'))){ $js_notification_status_page.show(); }; $(".js-notification-status-page-close").on( "click", function(e) { e.preventDefault(); LS.dontShowOrderStatusNotificationAgain($js_notification_status_page.data('url')); }); } var $js_notification_order_cancellation = $(".js-notification-order-cancellation"); if ($js_notification_order_cancellation.size() > 0){ if (LS.shouldShowOrderCancellationNotification($js_notification_order_cancellation.data('url'))){ $js_notification_order_cancellation.show(); $(".js-btn-fixed-bottom").css({"margin-bottom": "40px"}); }; $(".js-notification-order-cancellation-close").on( "click", function(e) { e.preventDefault(); LS.dontShowOrderCancellationNotification($js_notification_order_cancellation.data('url')); }); } $(".js-cart-notification-close").click(function(){ $(".js-alert-added-to-cart").removeClass("notification-visible").addClass("notification-hidden"); setTimeout(function(){ $('.js-cart-notification-item-img').attr('src', ''); $(".js-alert-added-to-cart").hide(); },2000); }); if ($(window).width() < 768) { cleanURLHash = function(){ const uri = window.location.toString(); const clean_uri = uri.substring(0, uri.indexOf("#")); window.history.replaceState({}, document.title, clean_uri); }; goBackBrowser = function(){ cleanURLHash(); history.back(); }; if(window.location.href.indexOf("modal-fullscreen") > -1) { cleanURLHash(); } $(document).on("click", ".js-fullscreen-modal-open", function(e) { e.preventDefault(); var modal_url_hash = $(this).data("modal-url"); window.location.hash = modal_url_hash; }); $(document).on("click", ".js-fullscreen-modal-close", function(e) { e.preventDefault(); goBackBrowser(); }); window.onhashchange = function() { if(window.location.href.indexOf("modal-fullscreen") <= -1) { if($(".js-fullscreen-modal").hasClass("modal-show")){ var $opened_modal = $(".js-fullscreen-modal.modal-show"); var $opened_modal_overlay = $opened_modal.prev(); $opened_modal.removeClass("modal-show").delay(500).hide(0); $opened_modal_overlay.fadeOut(500); } } } } $(document).on("click", ".js-modal-open", function(e) { e.preventDefault(); var modal_id = $(this).data('toggle'); var $overlay_id = $('.js-modal-overlay[data-modal-id="' + modal_id + '"]'); if ($(modal_id).hasClass("modal-show")) { $(modal_id).removeClass("modal-show").delay(500).hide(0); } else { $overlay_id.fadeIn(400); $(modal_id).detach().appendTo("body"); $overlay_id.detach().insertBefore(modal_id); $(modal_id).show(0).addClass("modal-show"); } }); $(document).on("click", ".js-modal-close", function(e) { e.preventDefault(); var $modal = $(this).closest(".js-modal"); var modal_id = $modal.attr('id'); var $overlay_id = $('.js-modal-overlay[data-modal-id="#' + modal_id + '"]'); $modal.removeClass("modal-show").delay(500).hide(0); $overlay_id.fadeOut(500); if (($(window).width() < 768) && ($(this).hasClass(".js-fullscreen-modal-close"))) { goBackBrowser(); } }); $(document).on("click", ".js-modal-overlay", function(e) { e.preventDefault(); var modal_id = $(this).data('modal-id'); $(modal_id).removeClass("modal-show").delay(500).hide(0); $(this).fadeOut(500); }); var $tab_open = $('.js-tab'); $tab_open.click(function (e) { e.preventDefault(); var $tab_container = $(this).closest(".js-tab-container"); $tab_container.find(".js-tab, .js-tab-panel").removeClass("active"); $(this).addClass("active"); var tab_to_show = $(this).find(".js-tab-link").attr("href"); $tab_container.find(tab_to_show).addClass("active"); }); $(document).on("click", ".js-card-collapse-toggle", function(e) { e.preventDefault(); $(this).toggleClass('active'); $(this).closest(".js-card-collapse").toggleClass('active'); }); $(document).on("click", ".js-accordion-toggle", function(e) { e.preventDefault(); if($(this).hasClass("js-accordion-show-only")){ $(this).hide(); }else{ $(this).find(".js-accordion-toggle-inactive").toggle(); $(this).find(".js-accordion-toggle-active").toggle(); } $(this).prev(".js-accordion-container").slideToggle(); }); function applyOffset(selector){ // Get nav height on load if ($(window).width() > 768) { var head_height = $(".js-head-main").height(); $(selector).css("padding-top", head_height); }else{ var head_height = 0; } // Apply offset nav height on load $(window).resize(function() { // Get nav height on resize var head_height = $(".js-head-main").height(); // Apply offset on resize if ($(window).width() > 768) { $(selector).css("padding-top", head_height); }else{ $(selector).css("padding-top", 0); } }); } applyOffset(".js-head-offset"); var didScroll; var lastScrollTop = 0; var delta = 30; var navbarHeight = $(".js-head-main").outerHeight(); var topbarHeight = $(".js-topbar").outerHeight(); $(window).scroll(function(event){ didScroll = true; }); setInterval(function() { if (didScroll) { hasScrolled(); didScroll = false; } }, 250); function hasScrolled() { var st = $(this).scrollTop(); // Make sure they scroll more than delta if(Math.abs(lastScrollTop - st) <= delta) return; // If they scrolled down and are past the navbar, add class .move-up. if (st > lastScrollTop && st > navbarHeight){ $(".js-head-main").addClass('compress').css('top', - topbarHeight ); if ($(window).width() < 768) { $category_controls.css('top', (navbarHeight - topbarHeight - 2) ); } } else { // Scroll Up if(st + $(window).height() < $(document).height()) { $(".js-head-main").removeClass('compress').css('top', 0 ); if ($(window).width() < 768) { $category_controls.css('top', navbarHeight ); } } } lastScrollTop = st; } $(".js-utilities-item").hover(function(e) { e.preventDefault(); $(this).toggleClass("active").find(".js-subutility-list").stop(true, true).fadeToggle(300); }); var $top_nav = $(".js-mobile-nav"); var $page_main_content = $(".js-main-content"); var $search_backdrop = $(".js-search-backdrop"); $top_nav.addClass("move-down").removeClass("move-up"); $(".js-toggle-page-accordion").click(function (e) { e.preventDefault(); $(this).toggleClass("active").closest(".js-nav-list-toggle-accordion").next(".js-pages-accordion").slideToggle(300); }); var win_height = window.innerHeight; var head_height = $(".js-head-main").height(); $(".js-desktop-dropdown").css('max-height', win_height - head_height - 50); $(".js-item-subitems-desktop").hover(function (e) { $(this).addClass("active").children(".js-desktop-dropdown").stop(true, true).fadeIn(300); }, function() { $(this).removeClass("active").children(".js-desktop-dropdown").stop(true, true).fadeOut(300); }); $(".js-toggle-search").click(function (e) { e.preventDefault; $(".js-search-input").focus(); }); LS.search($(".js-search-input"), function (html, count) { $search_suggests = $(this).closest(".js-search-container").next(".js-search-suggest"); if (count > 0) { $search_suggests.html(html).show(); } else { $search_suggests.hide(); } if ($(this).val().length == 0) { $search_suggests.hide(); } }, { snipplet: 'header/header-search-results.tpl' }); if ($(window).width() > 768) { $("body").click(function () { $(".js-search-suggest").hide(); }); $(document).on("click", ".js-search-suggest a", function () { $(".js-search-suggest").show(); }); } $(".js-search-suggest").on("click", ".js-search-suggest-all-link", function (e) { e.preventDefault(); $this_closest_form = $(this).closest(".js-search-suggest").prev(".js-search-form"); $this_closest_form.submit(); }); var relatedSwiper = new Swiper ('.js-swiper-related', { lazy: true, watchOverflow: true, centerInsufficientSlides: true, threshold: 5, watchSlideProgress: true, watchSlidesVisibility: true, slideVisibleClass: 'js-swiper-slide-visible', slidesPerView: 1.5, navigation: { nextEl: '.js-swiper-related-next', prevEl: '.js-swiper-related-prev', }, breakpoints: { 640: { slidesPerView: 4, } } }); var width = window.innerWidth; if (width < 767) { var swiperInformative = new Swiper ('.js-informative-banners', { slidesPerView: 1.2, watchOverflow: true, centerInsufficientSlides: true, pagination: { el: '.js-informative-banners-pagination', clickable: true, }, breakpoints: { 640: { slidesPerView: 3, } } }); } var $category_controls = $(".js-category-controls"); var mobile_nav_height = $(".js-head-main").innerHeight(); $(document).on("click", ".js-item-buy-open", function(e) { e.preventDefault(); $(this).toggleClass("btn-primary btn-secondary"); $(this).closest(".js-quickshop-container").find(".js-item-variants").fadeToggle(300); var elementTop = $(this).closest(".js-product-container").offset().top; var viewportTop = $(window).scrollTop(); if(elementTop < viewportTop){ $([document.documentElement, document.body]).animate({ scrollTop: $(this).closest(".js-product-container").offset().top - 180 }, 400); } }); $(document).on("click", ".js-item-buy-close", function(e) { e.preventDefault(); $(this).closest(".js-item-variants").fadeToggle(300); $(this).closest(".js-quickshop-container").find(".js-item-buy-open").toggleClass("btn-primary btn-secondary"); }); LS.registerOnChangeVariant(function(variant){ var current_image = $('.js-item-image', '.js-item-product[data-product-id="'+variant.product_id+'"]'); current_image.attr('srcset', variant.image_url); }); function get_max_installments_without_interests(number_of_installment, installment_data, max_installments_without_interests) { if (parseInt(number_of_installment) > parseInt(max_installments_without_interests[0])) { if (installment_data.without_interests) { return [number_of_installment, installment_data.installment_value.toFixed(2)]; } } return max_installments_without_interests; } function get_max_installments_with_interests(number_of_installment, installment_data, max_installments_with_interests) { if (parseInt(number_of_installment) > parseInt(max_installments_with_interests[0])) { if (installment_data.without_interests == false) { return [number_of_installment, installment_data.installment_value.toFixed(2)]; } } return max_installments_with_interests; } function refreshInstallmentv2(price){ $(".js-modal-installment-price" ).each(function( index ) { const installment = Number($(this).data('installment')); $(this).text(LS.currency.display_short + (price/installment).toLocaleString('de-DE', {maximumFractionDigits: 2, minimumFractionDigits: 2})); }); } function changeVariant(variant) { $(".js-product-detail .js-shipping-calculator-response").hide(); $("#shipping-variant-id").val(variant.id); var parent = $("body"); if (variant.element) { parent = $(variant.element); } var sku = parent.find('#sku'); if(sku.length) { sku.text(variant.sku).show(); } var installment_helper = function($element, amount, price){ $element.find('.js-installment-amount').text(amount); $element.find('.js-installment-price').attr("data-value", price); $element.find('.js-installment-price').text(LS.currency.display_short + parseFloat(price).toLocaleString('de-DE', { minimumFractionDigits: 2 })); if(variant.price_short && Math.abs(variant.price_number - price * amount) < 1) { $element.find('.js-installment-total-price').text((variant.price_short).toLocaleString('de-DE', { minimumFractionDigits: 2 })); } else { $element.find('.js-installment-total-price').text(LS.currency.display_short + (price * amount).toLocaleString('de-DE', { minimumFractionDigits: 2 })); } }; if (variant.installments_data) { var variant_installments = JSON.parse(variant.installments_data); var max_installments_without_interests = [0,0]; var max_installments_with_interests = [0,0]; $.each(variant_installments, function(payment_method, installments) { $.each(installments, function(number_of_installment, installment_data) { max_installments_without_interests = get_max_installments_without_interests(number_of_installment, installment_data, max_installments_without_interests); max_installments_with_interests = get_max_installments_with_interests(number_of_installment, installment_data, max_installments_with_interests); var installment_container_selector = '#installment_' + payment_method + '_' + number_of_installment; if(!parent.hasClass("js-quickshop-container")){ installment_helper($(installment_container_selector), number_of_installment, installment_data.installment_value.toFixed(2)); } }); }); var $installments_container = $(variant.element + ' .js-max-installments-container .js-max-installments'); var $installments_modal_link = $(variant.element + ' #btn-installments'); var $payments_module = $(variant.element + ' .js-product-payments-container'); var $installmens_card_icon = $(variant.element + ' .js-installments-credit-card-icon'); var installments_to_use = max_installments_without_interests[0] > 1 ? max_installments_without_interests : max_installments_with_interests; if(installments_to_use[0] <= 1 ) { $installments_container.hide(); $installments_modal_link.hide(); $payments_module.hide(); $installmens_card_icon.hide(); } else { $installments_container.show(); $installments_modal_link.show(); $payments_module.show(); $installmens_card_icon.show(); installment_helper($installments_container, installments_to_use[0], installments_to_use[1]); } } if(!parent.hasClass("js-quickshop-container")){ $('#installments-modal .js-installments-one-payment').text(variant.price_short).attr("data-value", variant.price_number); } if (variant.price_short){ var variant_price_clean = variant.price_short.replace('$', '').replace('R', '').replace(',', '').replace('.', ''); var variant_price_raw = parseInt(variant_price_clean, 10); parent.find('.js-price-display').text(variant.price_short).show(); parent.find('.js-price-display').attr("content", variant.price_number).data('product-price', variant_price_raw); } else { parent.find('.js-price-display').hide(); } if ((variant.compare_at_price_short) && !(parent.find(".js-price-display").css("display") == "none")) { parent.find('.js-compare-price-display').text(variant.compare_at_price_short).show(); } else { parent.find('.js-compare-price-display').hide(); } var button = parent.find('.js-addtocart'); button.removeClass('cart').removeClass('contact').removeClass('nostock'); var $product_shipping_calculator = parent.find("#product-shipping-container"); if (!variant.available){ button.val('Out of stock'); button.addClass('nostock'); button.attr('disabled', 'disabled'); $product_shipping_calculator.hide(); } else if (variant.contact) { button.val('Contact for price'); button.addClass('contact'); button.removeAttr('disabled'); $product_shipping_calculator.hide(); } else { button.val('Add to cart'); button.addClass('cart'); button.removeAttr('disabled'); $product_shipping_calculator.show(); } const base_price = Number($("#price_display").attr("content")); refreshInstallmentv2(base_price); LS.updateShippingProduct(); zipcode_on_changevariant = $("#product-shipping-container .js-shipping-input").val(); $("#product-shipping-container .js-shipping-calculator-current-zip").text(zipcode_on_changevariant); } $(document).on("change", ".js-variation-option", function(e) { var $parent = $(this).closest(".js-product-variants"); var $variants_group = $(this).closest(".js-product-variants-group"); var quick_id = $(this).closest(".js-quickshop-container").attr("id"); if($parent.hasClass("js-product-quickshop-variants")){ LS.changeVariant(changeVariant, '#' + quick_id); } else { LS.changeVariant(changeVariant, '#single-product'); } var $this_compare_price = $(this).closest(".js-product-container").find(".js-compare-price-display"); var $this_price = $(this).closest(".js-product-container").find(".js-price-display"); var $installment_container = $(this).closest(".js-product-container").find(".js-product-payments-container"); var $installment_text = $(this).closest(".js-product-container").find(".js-max-installments-container"); var $this_product_container = $(this).closest(".js-product-container"); var $this_add_to_cart = $(this).closest(".js-product-container").find(".js-prod-submit-form"); // Get the current product discount percentage value var current_percentage_value = $this_product_container.find(".js-offer-percentage"); // Get the current product price and promotional price var compare_price_value = $this_compare_price.html(); var price_value = $this_price.html(); // Filter prices to only have numbers old_price_value_filtered = parseInt(compare_price_value.replace(/[^0-9]/gi, ''), 10)/100; current_price_value_filtered = parseInt(price_value.replace(/[^0-9]/gi, ''), 10)/100; // Calculate new discount percentage based on difference between filtered old and new prices price_difference = (old_price_value_filtered-current_price_value_filtered); updated_discount_percentage = Math.round(((price_difference*100)/old_price_value_filtered)); $this_product_container.find(".js-offer-percentage").html(updated_discount_percentage); if ($this_compare_price.css("display") == "none") { $this_product_container.find(".js-offer-label").hide(); } else { $this_product_container.find(".js-offer-label").css("display" , "table"); } if ($this_add_to_cart.hasClass("nostock")) { $this_product_container.find(".js-stock-label").show(); } else { $this_product_container.find(".js-stock-label").hide(); } if ($this_price.css('display') == 'none'){ $installment_container.hide(); $installment_text.hide(); }else{ $installment_text.show(); } }); $(".js-product-form").submit(function (e) { var button = $(this).find(':submit'); button.attr('disabled', 'disabled'); if ((button.hasClass('contact')) || (button.hasClass('catalog'))) { e.preventDefault(); var product_id = $(this).find("input[name='add_to_cart']").val(); window.location = "\x2Fus\x2Fcontact\x2F?product=" + product_id; } else if (button.hasClass('cart')) { button.val('Adding...'); } }); var width = window.innerWidth; if (width > 767) { var speedVal = 0; var spaceBetweenVal = 0; var slidesPerViewVal = 1; } else { var speedVal = 300; var spaceBetweenVal = 10; var slidesPerViewVal = 1.2; } var productSwiper = new Swiper ('.js-swiper-product', { lazy: true, speed: speedVal, slidesPerView: slidesPerViewVal, centeredSlides: true, spaceBetween: spaceBetweenVal, pagination: { el: '.js-swiper-product-pagination', type: 'fraction', clickable: true, }, navigation: { nextEl: '.js-swiper-product-next', prevEl: '.js-swiper-product-prev', }, on: { init: function () { $(".js-product-slider-placeholder").hide(); $(".js-swiper-product").css({"visibility" : "visible" , "height" : "auto"}); }, }, }); $().fancybox({ selector : '[data-fancybox="product-gallery"]', toolbar : false, smallBtn : true, beforeClose : function(instance) { // Update position of the slider productSwiper.slideTo( instance.currIndex, 0 ); $(".js-product-thumb").removeClass("selected"); var $product_thumbnail = $(".js-product-thumb[data-thumb-loop='"+instance.currIndex+"']").addClass("selected"); if($product_thumbnail.length){ $product_thumbnail.addClass("selected"); }else{ $(".js-product-thumb[data-thumb-loop='4']").addClass("selected"); } }, }); LS.registerOnChangeVariant(function(variant){ var liImage = $('.js-swiper-product').find("[data-image='"+variant.image+"']"); var selectedPosition = liImage.data('image-position'); var slideToGo = parseInt(selectedPosition); productSwiper.slideTo(slideToGo); $(".js-product-slide-img").removeClass("js-active-variant"); liImage.find(".js-product-slide-img").addClass("js-active-variant"); }); $(".js-product-thumb").click(function(e){ e.preventDefault(); $(".js-product-thumb").removeClass("selected"); $(this).addClass("selected"); var thumbLoop = $(this).data("thumb-loop"); var slideToGo = parseInt(thumbLoop); productSwiper.slideTo(slideToGo); if($(this).hasClass("js-product-thumb-modal")){ $('.js-swiper-product').find("[data-image-position='"+slideToGo+"'] .js-product-slide-link").click(); } }); $('.js-pinterest-share').click(function(e){ e.preventDefault(); $(".pinterest-hidden a")[0].click(); }); if (window.innerWidth > 767) { $("#product-description").show(); }else{ $("#product-description").insertAfter("#product_form").show(); } $('.js-quantity .js-quantity-up').on('click', function() { $quantity_input = $(this).closest(".js-quantity").find(".js-quantity-input"); $quantity_input.val( parseInt($quantity_input.val(), 10) + 1); }); $('.js-quantity .js-quantity-down').on('click', function() { $quantity_input = $(this).closest(".js-quantity").find(".js-quantity-input"); quantity_input_val = $quantity_input.val(); if (quantity_input_val>1) { $quantity_input.val( parseInt($quantity_input.val(), 10) - 1); } }); var head_height = $(".js-head-main").outerHeight(); if ($(window).width() > 768) { $("#cart-sticky-summary").css("top" , head_height + 10); } $(document).on("click", ".js-addtocart:not(.js-addtocart-placeholder)", function (e) { var $productContainer = $(this).closest('.js-product-container'); var $productVariants = $productContainer.find(".js-variation-option"); var $productButton = $productContainer.find("input[type='submit'].js-addtocart"); var $productButtonPlaceholder = $productContainer.find(".js-addtocart-placeholder"); var $productButtonText = $productButtonPlaceholder.find(".js-addtocart-text"); var $productButtonAdding = $productButtonPlaceholder.find(".js-addtocart-adding"); var $productButtonSuccess = $productButtonPlaceholder.find(".js-addtocart-success"); var productButttonHeight = $productButton.height(); var isQuickShop = $productContainer.hasClass('js-quickshop-container'); if (!isQuickShop) { if($(".js-product-slide-img.js-active-variant").length) { var imageSrc = $($productContainer.find('.js-product-slide-img.js-active-variant')[0]).data('srcset').split(' ')[0]; } else { var imageSrc = $($productContainer.find('.js-product-slide-img')[0]).attr('srcset').split(' ')[0]; } var quantity = $productContainer.find('.js-quantity-input').val(); var name = $productContainer.find('.js-product-name').text(); var price = $productContainer.find('.js-price-display').text(); var addedToCartCopy = "Add to cart"; } else { var imageSrc = $(this).closest('.js-quickshop-container').find('img').attr('srcset').split(' ')[0]; var quantity = 1; var name = $productContainer.find('.js-item-name').text(); var price = $productContainer.find('.js-price-display').text().trim(); var addedToCartCopy = "Buy"; if ($productContainer.hasClass("js-quickshop-has-variants")) { var addedToCartCopy = "Add to cart"; }else{ var addedToCartCopy = "Buy"; } } if (!$(this).hasClass('contact')) { e.preventDefault(); $productButton.hide(); $productButtonPlaceholder.show(); $productButtonPlaceholder.height(productButttonHeight); $productButtonText.fadeOut(); $productButtonAdding.addClass("active"); var callback_add_to_cart = function(){ $(".js-cart-widget-amount").addClass("swing"); setTimeout(function(){ $(".js-cart-widget-amount").removeClass("swing"); },6000); $('.js-cart-notification-item-img').attr('srcset', imageSrc); $('.js-cart-notification-item-name').text(name); $('.js-cart-notification-item-quantity').text(quantity); $('.js-cart-notification-item-price').text(price); if($productVariants.length){ var output = []; $productVariants.each( function(){ var variants = $(this); output.push(variants.val()); }); $(".js-cart-notification-item-variant-container").show(); $(".js-cart-notification-item-variant").text(output.join(', ')) }else{ $(".js-cart-notification-item-variant-container").hide(); } var cartItemsAmount = $(".js-cart-widget-amount").first().text(); if(cartItemsAmount > 1){ $(".js-cart-counts-plural").show(); $(".js-cart-counts-singular").hide(); }else{ $(".js-cart-counts-singular").show(); $(".js-cart-counts-plural").hide(); } $productButtonAdding.removeClass("active"); $productButtonSuccess.addClass("active"); setTimeout(function(){ $productButtonSuccess.removeClass("active"); $productButtonText.fadeIn(); },2000); setTimeout(function(){ $productButtonPlaceholder.removeAttr("style").hide(); $productButton.show(); },3000); $productContainer.find(".js-added-to-cart-product-message").slideDown(); setTimeout(function(){ $(".js-alert-added-to-cart").show().addClass("notification-visible").removeClass("notification-hidden"); },500); if (typeof $.cookie('first_product_added_successfully') === 'undefined') { $.cookie('first_product_added_successfully', true, { path: '/', expires: 7 }); } else{ setTimeout(function(){ $(".js-alert-added-to-cart").removeClass("notification-visible").addClass("notification-hidden"); setTimeout(function(){ $('.js-cart-notification-item-img').attr('src', ''); $(".js-alert-added-to-cart").hide(); },2000); },8000); } if ($("#product-shipping-container .js-shipping-input").val()) { zipcode_on_addtocart = $("#product-shipping-container .js-shipping-input").val(); $("#cart-shipping-container .js-shipping-input").val(zipcode_on_addtocart); $(".js-shipping-calculator-current-zip").text(zipcode_on_addtocart); } else if (!!$.cookie('calculator_zipcode')){ var zipcode_from_cookie = $.cookie("calculator_zipcode"); $('.js-shipping-input').val(zipcode_from_cookie); $(".js-shipping-calculator-current-zip").text(zipcode_from_cookie); } } var callback_error = function(){ $productButtonAdding.removeClass("active"); $productButtonText.fadeIn(); $productButtonPlaceholder.removeAttr("style").hide(); $productButton.show(); } $prod_form = $(this).closest("form"); LS.addToCartEnhanced( $prod_form, addedToCartCopy, 'Adding...', 'Oops! We don't have enough stock left to add this product to the shopping cart.', false, callback_add_to_cart, callback_error ); } }); $(document).on("keypress", ".js-cart-quantity-input", function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false; } }); $(document).on("focusout", ".js-cart-quantity-input", function (e) { $(".js-shipping-calculator-response").hide().empty(); $(".js-go-checkout-btn").prop("disabled", true); var itemID = $(this).attr("data-item-id"); var itemVAL = $(this).val(); if (itemVAL == 0) { var r = confirm("Are you sure you want to delete this item?"); if (r == true) { LS.removeItem(itemID, true); } else { $(this).val(1); } } else { LS.changeQuantity(itemID, itemVAL, true); } }); $(".js-trigger-empty-cart-alert").click(function (e) { e.preventDefault(); $(".js-mobile-nav-empty-cart-alert").fadeIn(100).delay(1500).fadeOut(500); }); $('form[action="\x2Fus\x2Fbuy\x2F"]').submit(function() { $.removeCookie('first_product_added_successfully', { path: '/' }); }); if ($('.js-selected-shipping-method').length) { var shipping_cost = $('.js-selected-shipping-method').data("cost"); var $shippingCost = $("#shipping-cost"); $shippingCost.text(shipping_cost); $shippingCost.removeClass('opacity-40'); } selectShippingOption = function(elem, save_option) { $(".js-shipping-method, .js-branch-method").removeClass('js-selected-shipping-method'); $(elem).addClass('js-selected-shipping-method'); var shipping_cost = $(elem).data("cost"); var shipping_price_clean = $(elem).data("price"); if(shipping_price_clean = 0.00){ var shipping_cost = '' } // Updates shipping (ship and pickup) cost on cart var $shippingCost = $("#shipping-cost"); $shippingCost.text(shipping_cost); $shippingCost.removeClass('opacity-40'); if (save_option) { LS.saveCalculatedShipping(true); } if ($(elem).hasClass("js-shipping-method-hidden")) { if ($(elem).hasClass("js-pickup-option")) { $(".js-other-pickup-options, .js-show-other-pickup-options .js-shipping-see-less").show(); $(".js-show-other-pickup-options .js-shipping-see-more").hide(); } else { $(".js-other-shipping-options, .js-show-more-shipping-options .js-shipping-see-less").show(); $(".js-show-more-shipping-options .js-shipping-see-more").hide() } } }; if (!!$.cookie('calculator_zipcode')) { var zipcode_from_cookie = $.cookie("calculator_zipcode"); $('#product-shipping-container .js-shipping-input').val(zipcode_from_cookie); $(".js-shipping-calculator-current-zip").text(zipcode_from_cookie); $(".js-shipping-calculator-head").addClass("with-zip").removeClass("with-form"); $(".js-shipping-calculator-with-zipcode").addClass("transition-up-active"); $(".js-shipping-calculator-spinner").show(); } else { $(".js-shipping-calculator-form").addClass("transition-up-active"); } removeShippingSuboptions = function(){ var shipping_suboptions_id = $(".js-modal-shipping-suboptions").attr("id"); $("#" + shipping_suboptions_id).remove(); $('.js-modal-overlay[data-modal-id="#' + shipping_suboptions_id + '"').remove(); }; $(".js-calculate-shipping").click(function (e) { e.preventDefault(); let shipping_input_val = $(this).closest(".js-shipping-calculator-form").find(".js-shipping-input").val(); $(".js-shipping-input").val(shipping_input_val); LS.calculateShippingAjax( $('#product-shipping-container').find(".js-shipping-input").val(), '\x2Fus\x2Fshipping\x2F', $("#product-shipping-container").closest(".js-shipping-calculator-container") ); if ($(".js-cart-item").length) { LS.calculateShippingAjax( $('#cart-shipping-container').find(".js-shipping-input").val(), '\x2Fus\x2Fshipping\x2F', $("#cart-shipping-container").closest(".js-shipping-calculator-container") ); } $(".js-shipping-calculator-current-zip").html(shipping_input_val); removeShippingSuboptions(); }); $(".js-shipping-input").keydown(function (e) { var key = e.which ? e.which : e.keyCode; var enterKey = 13; if (key === enterKey) { e.preventDefault(); $(this).closest(".js-shipping-calculator-form").find(".js-calculate-shipping").click(); if ($(window).width() < 768) { $(this).blur(); } } }); $(document).on("change", ".js-shipping-method, .js-branch-method", function () { selectShippingOption(this, true); $(".js-shipping-method-unavailable").hide(); }); $('.js-shipping-method:checked').livequery(function () { let shippingPrice = $(this).attr("data-price"); LS.addToTotal(shippingPrice); let total = (LS.data.cart.total / 100) + parseFloat(shippingPrice); $(".js-cart-widget-total").html(LS.formatToCurrency(total)); selectShippingOption(this, false); }); $(document).on("click", ".js-toggle-branches", function (e) { e.preventDefault(); $(".js-store-branches-container").slideToggle("fast"); $(".js-see-branches, .js-hide-branches").toggle(); }); $(document).on("click", ".js-toggle-more-shipping-options", function(e) { e.preventDefault(); if($(this).hasClass("js-show-other-pickup-options")){ $(".js-other-pickup-options").slideToggle(600); $(".js-show-other-pickup-options .js-shipping-see-less, .js-show-other-pickup-options .js-shipping-see-more").toggle(); }else{ $(".js-other-shipping-options").slideToggle(600); $(".js-show-more-shipping-options .js-shipping-see-less, .js-show-more-shipping-options .js-shipping-see-more").toggle(); } }); calculateCartShippingOnLoad = function() { if ($("#cart-shipping-container .js-shipping-input").val()) { // If user already had calculated shipping: recalculate shipping setTimeout(function() { LS.calculateShippingAjax( $('#cart-shipping-container').find(".js-shipping-input").val(), '\x2Fus\x2Fshipping\x2F', $("#cart-shipping-container").closest(".js-shipping-calculator-container") ); removeShippingSuboptions(); }, 100); } if ($(".js-branch-method").hasClass('js-selected-shipping-method')) { } }; if($('#product-shipping-container').find(".js-shipping-input").val()){ setTimeout(function() { LS.calculateShippingAjax( $('#product-shipping-container').find(".js-shipping-input").val(), '\x2Fus\x2Fshipping\x2F', $("#product-shipping-container").closest(".js-shipping-calculator-container") ); removeShippingSuboptions(); }, 100); } $(document).on("click", ".js-shipping-calculator-change-zipcode", function(e) { e.preventDefault(); $(".js-shipping-calculator-response").fadeOut(100); $(".js-shipping-calculator-head").addClass("with-form").removeClass("with-zip"); $(".js-shipping-calculator-with-zipcode").removeClass("transition-up-active"); $(".js-shipping-calculator-form").addClass("transition-up-active"); }); $(document).on("click", ".js-save-shipping-country", function(e) { e.preventDefault(); var selected_country_url = $(this).closest(".js-modal-shipping-country").find(".js-shipping-country-select option:selected").attr("data-country-url"); location.href = selected_country_url; $(this).text('Aplying...').addClass("disabled"); }); $(".js-winnie-pooh-form").submit(function (e) { $(this).attr('action', ''); }); $('.js-password-view').click(function () { $(this).toggleClass('password-view'); if($(this).hasClass('password-view')){ $(this).parent().find(".js-password-input").attr('type', ''); $(this).find(".js-eye-open, .js-eye-closed").toggle(); } else { $(this).parent().find(".js-password-input").attr('type', 'password'); $(this).find(".js-eye-open, .js-eye-closed").toggle(); } }); }); $( function() { var today = new Date(); var day = today.getDate(); var week = today.getDay(); var month = today.getMonth(); var year = today.getFullYear(); var hours = today.getHours(); /* # Dias da semana 0 = Domingo 1 = Segunda 2 = Terça 3 = Quarta 4 = Quinta 5 = Sexta 6 = Sábado */ // week = 6; // hours = 17; console.log("today: "+today); console.log("day: "+day); console.log("week: "+week); console.log("month-1: "+month); console.log("year: "+year); console.log("hours: "+hours); monthNames = [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ]; dayNamesMin = [ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb" ]; var differenceDates = function(){ var Difference_In_Time = today.getTime() - $( "#datepicker" ).datepicker( "getDate" ).getTime(); var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24) * (-1); return Difference_In_Days; } if(week==6 && hours<12) //sábado < 12h { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("week==6 && hours<12"); // console.log(differenceDates()); // if(differenceDates()<=7 && $( "#datepicker" ).datepicker( "getDate" ).getDay()==1 ){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // }else if(differenceDates()<=0 ){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // } else { // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); // } }, }; } else if(week==6 && hours>=12) //sábado > 12h { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day+2), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("week==6 && hours>=12"); console.log(differenceDates()); if(differenceDates()<=7 && $( "#datepicker" ).datepicker( "getDate" ).getDay()==0 || $( "#datepicker" ).datepicker( "getDate" ).getDay()==1 ){ $('#shipping-hour').html(` Tarde (13h00 - 19h00) `); } else { $('#shipping-hour').html(` Horário Comercial (09h00 - 17h00) Manhã (07h30 - 12h00) Tarde (13h00 - 19h00) `); } }, }; } else if(week==6 && hours>=17) //sábado > 17h { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day+2), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("week==6 && hours>=17"); // console.log(differenceDates()); // if(differenceDates()<=7 && $( "#datepicker" ).datepicker( "getDate" ).getDay()==1 ){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // } else { // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); // } }, }; } else if(week==7) //domingo { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day+1), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("week==7"); // console.log(differenceDates()); // if(differenceDates()<=7 && $( "#datepicker" ).datepicker( "getDate" ).getDay()==1 ){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // } else { // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); // } }, }; } else if(hours>=17) // >17h { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day+1), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("hours>=17"); // console.log(differenceDates()); // if(differenceDates()<=1){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // } else { // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); // } }, }; } else if(hours<17) // <17h { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("hours<=12"); // console.log(differenceDates()); // if(differenceDates()<=0){ // $('#shipping-hour').html(` // Tarde (13h00 - 19h00) // `); // } else { // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); // } }, }; } else { config = { monthNames: monthNames, dateFormat: "dd/mm/yy", dayNamesMin: dayNamesMin, minDate: new Date(year, month, day), // beforeShowDay: function(date) { // var day = date.getDay(); // return [(day != 0), '']; // }, onSelect: function(){ console.log("else"); // console.log( differenceDates() ); // $('#shipping-hour').html(` // Horário Comercial (09h00 - 17h00) // Manhã (07h30 - 12h00) // Tarde (13h00 - 19h00) // `); }, }; } console.log(config); $( "#datepicker" ).datepicker(config); } ); /* $('#shipping-hour').html(` Horário Comercial (09h00 - 17h00) Manhã (07h30 - 12h00) Tarde (13h00 - 19h00) `); */ });