https://fieradelmobile-bergamo.it/wp-content/themes/norebro/assets/js/woocommerce-hack.js?ver=6.8.11
1jQuery(function($){ 2 "use strict"; 3 4 // Quantities - plus, minus 5 $("body").on("click", ".woo-quantity .plus", function(){ 6 var input = $(this).parent().find("input"); 7 8 if(input.attr("max") != input.attr("value")){ 9 input.attr("value", parseInt(input.attr("value")) + 1); 10 } 11 12 input.change(); 13 }); 14 15 $("body").on("click", ".woo-quantity .minus", function(){ 16 var input = $(this).parent().find("input"); 17 if(input.attr("min") != input.attr("value") && parseInt(input.attr("value")) > 1 ){ 18 input.attr("value", parseInt(input.attr("value")) - 1); 19 } 20 21 input.change(); 22 }); 23 24 // Fixed wishlist button in single page 25 if($('.summary .yith-wcwl-add-to-wishlist').length) { 26 $('.single_add_to_cart_button').after($('.summary .yith-wcwl-add-to-wishlist').clone()); 27 $('.summary .yith-wcwl-add-to-wishlist').eq(1).remove(); 28 } 29 30 var checkoutFormRight = function(){ 31 var order = $("#order_review"), customer = $('#customer_details'); 32 33 if( order && customer){ 34 var cHeight = customer.outerHeight(); 35 var oHeight = order.outerHeight(); 36 37 $(".wc-checkout-wrap").css("min-height", ((cHeight > oHeight) ? cHeight : oHeight) + 100 + "px"); 38 } 39 }; 40 41 // Reviews link 42 $("a.woo-review-link").on("click", function(){ 43 var reviewTab = $('#accordion-reviews'); 44 45 if ( reviewTab.length ) { 46 reviewTab.closest('.accordion-box')[0].accordionToggle( reviewTab.closest('.item').index() ); 47 48 $('.woo-summary-content').animate({ 49 scrollTop: $(".accordion-box").offset().top - 170 50 }, 800); 51 } 52 }); 53 54 $('.norebro-slider .woo-products').removeClass('norebro-masonry'); 55 56 // Single product price 57 var fixedPrice = function(price){ 58 var ins = price.find('ins'); 59 var del = price.find('del'); 60 61 if( price.length && ins.length == 1 && del.length && price.find('.price-percent').length == 0 ) { 62 var regular = parseInt(del.text().match(/(\d|\.)+/g)[0]); 63 var sale = parseInt(ins.text().match(/(\d|\.)+/g)[0]); 64 var percent = $(document.createElement('div')); 65 66 if ( price.find('.amount').length == 2 ) { 67 var saleText = 'SALE'; 68 if( price.attr('data-sale-text') ) { 69 saleText = price.attr('data-sale-text'); 70 } 71 percent.addClass('price-percent').html( '-' + parseInt( 100 - sale * 100 / regular ) + '% ' + saleText ); 72 price.append(percent); 73 } 74 75 del.insertAfter(ins); 76 } 77 }; 78 79 // Single product slider 80 var handleSingleProduct = function(){ 81 if ( $(window).width() > 768 ){ 82 83 var image = $('.woocommerce-product-gallery__wrapper img') 84 85 image.each(function(){ 86 var self = $(this); 87 var imgWidth = $(this).width(); 88 var imgHeight = $(this).height(); 89 var containerWidth = $('.slider').width(); 90 var containerHeight = $('.slider').height(); 91 var newPosition = 0; 92 93 if( imgWidth > imgHeight || imgWidth == imgHeight) { 94 $(this).addClass('horizontal-img'); 95 } 96 97 centeredImage(self, imgWidth, imgHeight, containerHeight, containerWidth, newPosition); 98 }); 99 } 100 101 function centeredImage(self, imgWidth, imgHeight, containerHeight, containerWidth, newPosition){ 102 if ( imgWidth < imgHeight ){ 103 104 newPosition = (imgHeight - containerHeight) / 2; 105 self.css("transform", "translatey(-" + newPosition + "px)"); 106 107 } 108 else { 109 110 imgWidth = self.width(); 111 112 if( imgWidth < containerWidth ) { 113 114 self.css({'width': '100%'}); 115 imgWidth = self.width(); 116 newPosition = (containerWidth - imgWidth ) / 2; 117 self.css("transform", "translatex(-" + newPosition + "px)"); 118 119 } 120 else { 121 122 newPosition = (imgWidth - containerWidth) / 2; 123 self.css("transform", "translatex(-" + newPosition + "px)"); 124 125 } 126 127 } 128 } 129 }; 130 131 if($('[data-wc-slider] img').length > 1) { 132 $('[data-wc-slider]').owlCarousel({ 133 items: 1, 134 slideBy: 1, 135 nav: false, 136 dots: true, 137 loop: false, 138 autoHeight: true, 139 autoplay: false, 140 mouseDrag: true, 141 touchDrag: true 142 }).on('changed.owl.carousel', function(obj){ 143 var currentItem = obj.item.index; 144 $('#product-thumbnails .image').removeClass('selected'); 145 $($('#product-thumbnails .image')[currentItem]).addClass('selected'); 146 }); 147 148 $('[data-wc-toggle-image]').on('click', function(){ 149 $('[data-wc-slider]').trigger('to.owl.carousel', [parseInt($(this).attr('data-wc-toggle-image')), 0, true]); 150 }); 151 } else { 152 $('[data-wc-slider]').addClass('empty'); 153 } 154 155 156 function refreshWooCategory(){ 157 $('li.product-category').each(function(){ 158 var info = $(this).find('.info-wrap'), 159 contentCenter = $(this).find('.content-center'); 160 161 $(this).find('>.wrap').css('height','0'); 162 163 var ratio = $(this).width() / this.imgWidth; 164 var padding = info.innerHeight() - info.height(); 165 var height = this.imgHeight * ratio; 166 167 $(this).find('>.wrap').css({ 168 'height': height + 'px', 169 'min-height': (contentCenter.outerHeight() + padding ) + 'px' 170 }); 171 }); 172 } 173 174 175 $(window).on('load', function(){ 176 177 // Shop product gallery 178 $('[data-product-item] .slider').each(function(){ 179 if($(this).find('img').length > 1) { 180 var slider = $(this); 181 182 var options = { 183 items: 1, 184 slideBy: 1, 185 nav: false, 186 dots: true, 187 loop: true, 188 autoHeight: true 189 }; 190 191 if( $(this).attr('data-autoplay') ){ 192 options.autoplay = true; 193 options.autoplayTimeout = 5000; 194 options.autoplayHoverPause = true; 195 options.autoplaySpeed = 1000; 196 } 197 198 slider.owlCarousel( options ); 199 } 200 }); 201 202 $('.woocommerce .images .slider, .woo-products .slider').addClass('visible'); 203 204 handleSingleProduct(); 205 fixedPrice( $('.product .summary p.price').eq(0) ); 206 207 // Change single product variations price 208 $('.variations select').on('change', function(){ 209 setTimeout(function(){
210 fixedPrice( $('.woo-variation-price') ); 211 handleSingleProduct(); 212 }, 10); 213 }); 214 215 // If variation changed main image 216 var mainImage = $('[data-wc-slider]').find('img').eq(0); 217 var oldSrc = mainImage.attr('src'); 218 mainImage.on('load', function(){ 219 if( oldSrc != mainImage.attr('src') ){ 220 $('[data-wc-slider]').trigger('to.owl.carousel', [0, 0, true]); 221 handleSingleProduct(); 222 } 223 }); 224 225 fixedPrice( $('.woo-variation-price') ); 226 checkoutFormRight(); 227 228 // Magic woo category list 229 $('li.product-category').each(function(){ 230 var img = $(this).find('img'), 231 wrap = $(this).find('>.wrap'); 232 233 234 wrap.css({ 235 'background-image': 'url("' + img[0].src + '")', 236 'height': wrap.height() + 'px' 237 }); 238 239 this.imgWidth = img.width(); 240 this.imgHeight = img.height(); 241 242 img.remove(); 243 }); 244 refreshWooCategory(); 245 }); 246 247 $(window).on('resize', function(){ 248 handleSingleProduct(); 249 checkoutFormRight(); 250 setTimeout( refreshWooCategory, 100 ); 251 }); 252 253 refreshWooCategory(); 254 255 256 // function updateOptions() { 257 // $('.register_attr').empty(); 258 // $.each( $('.custom_select'), function( index ) { 259 // console.log($(this)); 260 // $.each( $(this).find('option'), function( index2 ) { 261 // if (index2 > 0) { 262 // $(this).closest('.custom_select').siblings('.register_attr').append('<a href="javascript:void(0);" class="variation_button">' + 263 // '<span class="phoen_swatches">' + $(this).text() + '</span>' + 264 // '</a>'); 265 // } 266 // }); 267 // }); 268 // } 269 // 270 // $(document).on('change', '.custom_select select', function () { 271 // updateOptions(); 272 // }); 273 274 $(document).on('click', '.variation_button', function (event) { 275 $(this).siblings('*').removeClass('selected').addClass('unselected'); 276 $(this).removeClass('unselected').addClass('selected'); 277 var select = $(this).closest('.variation').find('select'); 278 select.val($(this).find('span').attr('data-option')); 279 select.change(); 280 }); 281 282 $('.reset_variations').click(function () { 283 $('.variation_button').removeClass('selected').addClass('unselected'); 284 }); 285});
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.