PageSourceSearch

https://viplash.ru/wp-content/plugins/woo-gifts/js/main.js?ver=1.1.0

js viplash.ru collected 2026-10-07 11:42:39 UTC 1,730 bytes, 57 lines download raw bytes

1jQuery(document).ready(($) => {
2	$(document).on('added_to_cart', (data1, data2, data3, $button) => {
3		const $product = $($button.parents('div.product')[0]);
4		const $WOO_GIFTS = $($product.find('.woo-gifts')[0]);
5		const $WOO_GIFT = $WOO_GIFTS.find('input[name="product-gift"]:checked');
6		const PARENT_PRODUCT = $WOO_GIFT.data('parent');
7		const GIFT_ID = $WOO_GIFT.val();
8
9		$.post('/woo-gifts/gift/select', {
10			idGiftProduct: GIFT_ID,
11			idParentGiftProduct: PARENT_PRODUCT,
12			quantity: +$('.qty').val()
13		}, (response) => {
14			console.log(response);
15		});
16	});
17
18	$(document).on('woocommerce_variation_has_changed', (e, isUpdate) => {
19		const $target = $(e.target);
20		let $product;
21		let $wooGifts;
22
23		if (!isUpdate) {
24			if (!$target.is('form')) return;
25			$product = $($target.parents('div.product')[0]);
26		} else {
27			$product = $($('div.product')[0]);
28		}
29
30		$wooGifts = $($product.find('.woo-gifts')[0]);
31
32		$.get('/woo-gifts/gift/get?idParentGiftProduct=' + $target.find('.variation_id').val(), (gifts) => {
33			if (!gifts.length) return $('.woo-gifts').addClass('hidden');
34
35			if (!$wooGifts.hasClass('backend')) $wooGifts.removeClass('hidden');
36
37			$wooGifts.find('.gifts .gift').remove();
38	
39			let isFirst = true;
40			for (let gift of gifts) {
41				$wooGifts.find('.gifts').append(`
42					<div class="gift">
43						<img src="${gift.img.src}" class="image">
44						<div class="name">${gift.name}</div>
45						<input ${isFirst ? 'checked' : ''} type="radio" name="product-gift" value="${gift.id}" data-parent="${gift.parentProdcutId}">
46					</div>
47				`);
48
49				isFirst = false;
50			}
51		})
52	});
53	
54	$(document).on('woo_variation_swatches_init', () => {
55		$(document).trigger('woocommerce_variation_has_changed', true);
56	});
57});

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.