1(function ($) { 2 'use strict'; 3 /*Product Details*/ 4 var productDetails = function () { 5 $('.product-image-slider').slick({ 6 slidesToShow: 1, 7 slidesToScroll: 1, 8 arrows: false, 9 fade: false, 10 asNavFor: '.slider-nav-thumbnails', 11 }); 12 13 $('.slider-nav-thumbnails').slick({ 14 slidesToShow: 4, 15 slidesToScroll: 1, 16 asNavFor: '.product-image-slider', 17 dots: false, 18 focusOnSelect: true, 19 prevArrow: '<button type="button" class="slick-prev slick-arrow"><i class="fi-rs-arrow-small-left"></i></button>', 20 nextArrow: '<button type="button" class="slick-next slick-arrow"><i class="fi-rs-arrow-small-right"></i></button>' 21 }); 22 23 // Remove active class from all thumbnail slides 24 $('.slider-nav-thumbnails .slick-slide').removeClass('slick-active'); 25 26 // Set active class to first thumbnail slides 27 $('.slider-nav-thumbnails .slick-slide').eq(0).addClass('slick-active'); 28 29 // On before slide change match active thumbnail to current slide 30 $('.product-image-slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) { 31 var mySlideNumber = nextSlide; 32 $('.slider-nav-thumbnails .slick-slide').removeClass('slick-active'); 33 $('.slider-nav-thumbnails .slick-slide').eq(mySlideNumber).addClass('slick-active'); 34 }); 35 36 $('.product-image-slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) { 37 var img = $(slick.$slides[nextSlide]).find("img"); 38 $('.zoomWindowContainer,.zoomContainer').remove(); 39 if ($(window).width() > 768) { 40 $(img).elevateZoom({ 41 zoomType: "inner", 42 cursor: "crosshair", 43 zoomWindowFadeIn: 500, 44 zoomWindowFadeOut: 750 45 }); 46 } 47 }); 48 //Elevate Zoom 49 if ( $(".product-image-slider").length ) { 50 if ($(window).width() > 768) { 51 $('.product-image-slider .slick-active img').elevateZoom({ 52 zoomType: "inner", 53 cursor: "crosshair", 54 zoomWindowFadeIn: 500, 55 zoomWindowFadeOut: 750 56 }); 57 } 58 } 59 //Filter color/Size 60 $('.list-filter').each(function () { 61 $(this).find('a').on('click', function (event) { 62 event.preventDefault(); 63 $(this).parent().siblings().removeClass('active'); 64 $(this).parent().toggleClass('active'); 65 $(this).parents('.attr-detail').find('.current-size').text($(this).text()); 66 $(this).parents('.attr-detail').find('.current-color').text($(this).attr('data-color')); 67 }); 68 }); 69 70 //Qty Up-Down 71 function getQtyRules($input) { 72 if ($input.attr('data-enforce-qty-rules') !== '1') { 73 return { step: 1, minQty: 1, enforce: false }; 74 } 75 var multiple = parseFloat($input.attr('data-purchase-multiple')) || 0; 76 var minStock = parseInt($input.attr('data-min-stock'), 10) || 0; 77 var step = multiple > 0 ? multiple : 1; 78 var minQty = minStock > 0 ? minStock : step; 79 return { step: step, minQty: minQty, enforce: true }; 80 } 81 82 function normalizeDetailQty(qty, rules) { 83 qty = parseInt(qty, 10); 84 if (isNaN(qty) || qty <= 0) { 85 return 0; 86 } 87 if (!rules.enforce) { 88 return qty; 89 } 90 if (qty < rules.minQty) { 91 return rules.minQty; 92 } 93 var remainder = (qty - rules.minQty) % rules.step; 94 if (remainder !== 0) { 95 qty -= remainder; 96 } 97 return qty; 98 } 99 100 function applyDetailQtyFromInput($input) { 101 var raw = $input.val(); 102 if (raw === '' || raw === null) { 103 $input.val(0); 104 return 0; 105 } 106 var rules = getQtyRules($input); 107 var normalized = normalizeDetailQty(raw, rules); 108 if (parseInt(raw, 10) !== normalized) { 109 $input.val(normalized); 110 } 111 return normalized; 112 } 113 114 window.normalizeProductDetailQtyInputs = function () { 115 $('.accordion-detail .qty-val').each(function () { 116 applyDetailQtyFromInput($(this)); 117 }); 118 }; 119 120 $('.detail-qty').each(function () { 121 var $qtyInput = $(this).find(".qty-val"); 122 if ($qtyInput.hasClass('update-quantity')) { 123 return; 124 } 125 126 $qtyInput.on('blur change', function () { 127 applyDetailQtyFromInput($(this)); 128 }); 129 130 $(this).find('.qty-up').on('click', function (event) { 131 event.preventDefault(); 132 var qtyval = parseInt($qtyInput.val(), 10) || 0; 133 var rules = getQtyRules($qtyInput); 134 qtyval = qtyval === 0 ? rules.minQty : qtyval + rules.step; 135 $qtyInput.val(qtyval); 136 }); 137 138 $(this).find(".qty-down").on("click", function (event) { 139 event.preventDefault(); 140 var qtyval = parseInt($qtyInput.val(), 10) || 0; 141 var rules = getQtyRules($qtyInput); 142 qtyval = qtyval <= rules.minQty ? 0 : qtyval - rules.step; 143 $qtyInput.val(qtyval); 144 }); 145 }); 146 147 $('.dropdown-menu .cart_list').on('click', function (event) { 148 event.stopPropagation(); 149 }); 150 }; 151 152 //Load functions 153 $(document).ready(function () { 154 productDetails(); 155 }); 156 157})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.