PageSourceSearch

https://credenzagroup.it/wp-content/themes/dfd-ronneby/assets/js/woocommerce_hack.js

js credenzagroup.it collected 2026-10-10 00:48:00 UTC 12,864 bytes, 359 lines download raw bytes

1var add_to_cart_button;
2
3(function($){
4	"use strict";
5	
6	var dfd_WC = window.dfd_WC || {};
7	
8	window.dfd_WC = dfd_WC;
9	
10	dfd_WC.window = $(window);
11	dfd_WC.document = $(document);
12	dfd_WC.windowWidth = dfd_WC.window.width();
13	
14	var supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
15	if (supports_html5_storage) { sessionStorage.clear(); }
16		
17	/* Plus-minus buttons customization */
18	var initArrows = function() {
19		$('.single-product form.cart .quantity, .shop_table .quantity, .woocommerce-grouped-product-list-item__quantity .quantity').each(function(){
20			var inputNumber, min, max, $self = $(this);
21			if($self.length > 0) {
22				$self.prepend('<i class="dfd-icon-down_2 minus">').append('<i class="dfd-icon-up_2 plus">');
23				$self.find('.minus').unbind('click').bind('click', function() {
24					inputNumber = $(this).siblings('.qty');
25					min = inputNumber.attr('min');
26					max = inputNumber.attr('max');
27					var beforeVal = +inputNumber.val();
28					var newVal = (beforeVal > min || !min) ? +beforeVal - 1 : min;
29					inputNumber.val(newVal);
30					$(this).parent().siblings('.single_add_to_cart_button').attr('data-quantity', newVal);
31					if($('.coupon .dfd-submit-wrap .button').length > 0) {
32						$('.coupon .dfd-submit-wrap .button').prop("disabled", false);
33					}
34				});
35				$self.find('.plus').unbind('click').bind('click', function() {
36					inputNumber = $(this).siblings('.qty');
37					min = inputNumber.attr('min');
38					max = inputNumber.attr('max');
39					var beforeVal = +inputNumber.val();
40					var newVal = (beforeVal < max || !max) ? +beforeVal + 1 : max;
41					inputNumber.val(newVal);
42					$(this).parent().siblings('.single_add_to_cart_button').attr('data-quantity', newVal);
43					if($('.coupon .dfd-submit-wrap .button').length > 0) {
44						$('.coupon .dfd-submit-wrap .button').prop("disabled", false);
45					}
46				});
47			}
48			$self.find('.qty').on('input propertychange',function() {
49				$('.single_add_to_cart_button').attr('data-quantity', $(this).val());
50			});
51			if($('.wcmp-quick-view-wrapper').length > 0)
52				$('.wcmp-quick-view-wrapper form.cart .single_add_to_cart_button').removeClass('product_type_simple');
53		});
54	};
55	
56	$(document).ready(function(){
57		var wooInitDropkick = function() {
58			if($('body').hasClass('single-product')) {
59				if ($('.ul-dropdown-toggle').length>0) {
60					$('.ul-dropdown-toggle').dropkick({mobile: true});
61				}
62				if ($('.variations .value select').length>0) {
63					$('.variations .value select').dropkick({mobile: true});
64				}
65			}
66			if($('body.woocommerce-cart .cart-wrap .shipping select').length > 0) {
67				$('body.woocommerce-cart .cart-wrap .shipping select:not(#calc_shipping_country):not(#calc_shipping_state)').dropkick();
68			}
69		};
70		if(!$('html').hasClass('dfd-ie-detected')) {
71			wooInitDropkick();
72			$('.cart-collaterals > .cover').observeDOM(function() {
73				wooInitDropkick();
74			});
75			$('.variations .value select').observeDOM(function() {
76				if ($('.variations .value select').length>0)
77					$('.variations .value select').dropkick('refresh');
78			});
79
80			$('.variations_form').on('click touchend', '.dfd-reset-vars', function(e) {
81				$('table.variations select').dropkick('reset', true);
82			});
83		}
84		
85		$('body').on('adding_to_cart', function(trigger, button) {
86			add_to_cart_button = button;
87		});
88		
89		$('body').on('added_to_cart', function (trigger) {
90			if (add_to_cart_button != undefined) {
91				var $woo_entry_thumb = $(add_to_cart_button).parents('li.product').find('div.woo-entry-thumb');
92				var $added_to_cart_notice = $('<div class="added-to-cart-notice moon-checkmark">Added to cart</div>');
93				
94				if ($woo_entry_thumb.length > 0) {
95					$woo_entry_thumb.append($added_to_cart_notice);
96					$added_to_cart_notice.stop().animate({opacity: 1}, 800).delay( 1800 ).animate({opacity: 0}, 800, function() {$(this).remove()});
97				}
98				add_to_cart_button = null;
99			}
100		});
101		
102		initArrows();
103		
104		var $toggleVariationsButton = $('.single-product .variations_form .variations_button');
105		$('body').on('hide_variation', function () {
106			if($toggleVariationsButton.length > 0) {
107				$toggleVariationsButton.slideUp(200);
108			}
109		});
110		$('body').on('show_variation', function () {
111			if($toggleVariationsButton.length > 0) {
112				$toggleVariationsButton.slideDown(200);
113			}
114		});
115	});
116	
117	var products_li_eq_height = function() {
118		$('.products.row').each(function() {
119			$(this).find('.product').equalHeights();
120		});
121	};
122	
123	$(window).load(products_li_eq_height);
124	$(window).on('load resize', products_li_eq_height);
125	
126	var wrap = $('body.single-product .product .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:first-child');
127	var wrapLeft, wrapTop, wrapWidth, wrapHeight, largeImage, largeImageWidth, largeImageheight, ratioX, ratioY, largeImageSrc, largeAlt;
128	var generateLargeImage = function() {
129		largeImageSrc = wrap.find('.wp-post-image').data('large_image');
130		largeAlt = wrap.find('.wp-post-image').attr('alt');
131		if(largeAlt == '') {
132			largeAlt = 'Large image';
133		}
134		wrap.find('> a').append('<img src="' + largeImageSrc + '" alt="' + largeAlt + '" class="dfd-large-image" />');
135	};
136	
137	var calculateVars = function() {
138		setTimeout(function() {
139			wrapLeft =  wrap.offset().left;
140			wrapTop =  wrap.offset().top;
141			wrapWidth =  wrap.width();
142			wrapHeight =  wrap.height();
143			largeImage = wrap.find('img.dfd-large-image');
144			largeImageWidth = largeImage.width();
145			largeImageheight = largeImage.height();
146			ratioX = largeImageWidth / wrapWidth - 1;
147			ratioY = largeImageheight / wrapHeight - 1;
148		},100);
149	};
150	var magnifierMove = function() {
151		wrap.mousemove(function(e) {
152			if(largeImage) {
153				var coordLeft = (e.pageX - wrapLeft) * ratioX;
154				if(coordLeft < 0) coordLeft = 0;
155				if(coordLeft > largeImageWidth) coordLeft = largeImageWidth;
156				var coordTop = (e.pageY - wrapTop) * ratioY;
157				if(coordTop < 0) coordTop = 0;
158				if(coordTop > largeImageheight) coordTop = largeImageheight;
159				largeImage.css({
160					'left' : -coordLeft,
161					'top' : -coordTop
162				});
163			}
164		});
165	};
166	
167	if(wrap.length > 0) {
168		dfd_WC.document.on('ready', magnifierMove);
169		dfd_WC.window.on("resize load scroll", calculateVars);
170	}
171
172	dfd_WC.initEqHeight = function() {
173		var init = function() {
174			var $productContainer = $('.single-product.woocommerce #layout .product.type-product'),
175				w = dfd_WC.windowWidth;
176			
177			if(!$productContainer.length) {
178				return;
179			}
180			
181			if (w > 800) {
182				$productContainer.find('.equalize-me').equalHeights();
183			} else {
184				$productContainer.find('.equalize-me').equalHeightsDestroy();
185			}
186		};
187		dfd_WC.window.on('load resize', init);
188		dfd_WC.window.one('scroll', init);
189	};
190	
191	dfd_WC.initStickInParent = function() {
192		if (Modernizr.touch === false && !$('html').is('.lt-ie10, .lt-ie9, .lt-ie8') && dfd_WC.windowWidth > 800) {
193			var offset = 0;
194			if( ($('#header-container:not(.header-style-5)').length > 0) && ($('#header-container:not(.header-style-8)').length > 0) && ($('#header-container:not(.header-style-11)').length > 0) ) {
195				offset += 60;
196			}
197			if($('#wpadminbar').length > 0) {
198				offset += $('#wpadminbar').outerHeight();
199			}
200			if($('.dfd-frame-line.line-bottom').length > 0) {
201				offset += $('.dfd-frame-line.line-bottom').outerHeight();
202			}
203			$('.woocommerce.single-product #main-content .product .dfd-single-share-fixed .rrssb-buttons').stick_in_parent({
204				parent: '#main-content .product',
205				sticky_class: 'sticky',
206				offset_top: offset,
207				bottoming: true,
208				inner_scrolling: false
209			});
210			$('.dfd-single-product-desc-wrap .summary').stick_in_parent({
211				sticky_class: 'sticky',
212				offset_top: offset + 20,
213				bottoming: true,
214				inner_scrolling: false
215			});
216		}
217	};
218	
219	dfd_WC.changeProdImageVariable = function() {
220		var $productContainer = $('.single-product.woocommerce #layout .product.type-product'),
221			$trigerImages = $productContainer.find('.images');
222		
223		$trigerImages.on('woocommerce_gallery_reset_slide_position', function() {
224			var $src = $productContainer.find('.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image a').attr('href');
225			$productContainer.find('.dfd-large-image').attr('src', $src);
226			dfd_WC.window.resize();
227		});
228	};
229
230	dfd_WC.singleProdThumbPrettyPhoto = function() {
231		if($('.single-product.woocommerce #layout .product.type-product .woocommerce-product-gallery__wrapper').length > 0) {
232			var $productContainer = $('.single-product.woocommerce #layout .product.type-product'),
233				$dataThumbFirst;
234
235			$dataThumbFirst = $productContainer.find('.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image').data('thumb');
236
237			$productContainer.find('.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image a').attr('data-rel', 'prettyPhoto[woo_single_gal]').attr('data-thumb', $dataThumbFirst).addClass('prettyPhoto');
238		}
239	};
240	
241	dfd_WC.singleProdThumbCaroucel = function() {
242		if($('.single-product.woocommerce #layout .product.type-product .dfd-single-product-thumbnails-wrap').length > 0) {
243			var $productContainer = $('.single-product.woocommerce #layout .product.type-product'),
244				$container = $productContainer.find('.single-product-thumbnails'),
245				$horisontal = false,
246				verticalSwiping = false,
247				$html,
248				$i = 0,
249				$dataThumbFirst;
250
251			if($productContainer.find('.dfd-single-product-media-wrap').hasClass('thumbs-left')) {
252				$horisontal = true,
253				verticalSwiping = true;
254			}
255
256//			$dataThumbFirst = $productContainer.find('.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image').data('thumb');
257
258//			$productContainer.find('.woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image a').attr('data-rel', 'prettyPhoto[woo_single_gal]').attr('data-thumb', $dataThumbFirst).addClass('prettyPhoto');
259
260			$productContainer.find('.dfd-single-product-thumbnails-wrap').append('<div class="hide"></div>');
261
262			$container.find('.woocommerce-product-gallery__image').each(function() {
263				$i++;
264				if( $i === 1 ) {
265					return;
266				}
267
268				var $self = $(this),
269					$img = $self.find('img'),
270					$fullImg = $img.data('src'),
271					$thumbImg = $img.attr('src');
272
273				$html = '<a href="' + $fullImg + '" data-thumb="' + $thumbImg + '" data-rel="prettyPhoto[woo_single_gal]"></a>';
274				$productContainer.find('.hide').append($html);
275			});
276
277			$('body').trigger('post-load');
278
279			$container.products_thumbnails_carousel(4, $horisontal, verticalSwiping);
280			$container.find('.woocommerce-product-gallery__image a').each(function() {
281				var $this = $(this);
282				$this.click(function(e) {
283					setTimeout(function() {
284						dfd_WC.initEqHeight();
285						dfd_WC.window.resize();
286					},100);
287					e.preventDefault();
288					var url = $this.attr('href');
289					var urlFull = $this.find('img').attr('data-large_image');
290
291					$this.parent().parents('.images').find('.woocommerce-product-gallery__wrapper img.wp-post-image').attr('src', url).attr('srcset', url);
292					$productContainer.find('.woocommerce-product-gallery__wrapper img.dfd-large-image').attr('src', urlFull);
293				});
294			});
295		}
296	};
297	
298	dfd_WC.initWooThumbsCarousel = function() {
299		var init = function() {
300			var $carousel = $('.woo-entry-thumb-carousel');
301			if(!$carousel.hasClass('slick-initialized')) {
302				var speed = $carousel.data('speed') ? $carousel.data('speed') : 800;
303				$carousel.slick({
304					infinite: true,
305					slidesToShow: 1,
306					slidesToScroll: 1,
307					arrows: false,
308					dots: false,
309					fade: true,
310					autoplay: true,
311					autoplaySpeed: speed,
312					pauseOnHover: false
313				});
314			}
315		};
316		init();
317	};
318	
319	$('.variations_form').on('hide_variation show_variation', function() {
320		setTimeout(function() {
321			dfd_WC.window.trigger('resize');
322		}, 500);
323	});
324	
325	$('body').on('post-load', function() {
326		dfd_WC.initWooThumbsCarousel();
327	});
328	
329	dfd_WC.window.on('resize', function() {
330		setTimeout(function() {
331			$(document.body).trigger('sticky_kit:recalc');
332		}, 300);
333	});
334	
335	dfd_WC.window.load(function() {
336		dfd_WC.initStickInParent();
337	});
338	
339	dfd_WC.document.ready(function() {
340		generateLargeImage();
341		dfd_WC.changeProdImageVariable();
342		dfd_WC.singleProdThumbPrettyPhoto();
343		dfd_WC.singleProdThumbCaroucel();
344		dfd_WC.initWooThumbsCarousel();
345	});
346	
347	dfd_WC.init = function() {
348		dfd_WC.initEqHeight();
349	};
350	
351	dfd_WC.init();
352	
353	$(document.body).on('updated_wc_div cart_page_refreshed',function() {
354		initArrows();
355		dfd_WC.initWooThumbsCarousel();
356		$( document ).trigger('change input');
357	});
358	
359})(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.