PageSourceSearch

https://www.1mf.ru/bitrix/templates/aspro_max_new/components/bitrix/sale.basket.basket/fly/script.js

js 1mf.ru collected 2026-09-29 15:58:03 UTC 6,753 bytes, 193 lines download raw bytes

1var basketTimeout;
2var totalSum;
3var timerBasketUpdate = false;
4
5function setQuantityFly(basketId, ratio, direction){
6	var currentValue = BX("QUANTITY_INPUT_" + basketId).value, newVal;
7
8	var isDblQuantity = $("#QUANTITY_INPUT_" + basketId).data('float_ratio'),
9		maxQuantity = $("#QUANTITY_INPUT_" + basketId).attr('max'),
10		ratio=( isDblQuantity ? parseFloat(ratio) : parseInt(ratio, 10));
11
12	if(isDblQuantity)
13		ratio = Math.round(ratio*arMaxOptions.JS_ITEM_CLICK.precisionFactor)/arMaxOptions.JS_ITEM_CLICK.precisionFactor;
14
15	curValue = (isDblQuantity ? parseFloat(currentValue) : parseInt(currentValue, 10));
16
17	curValue = (direction == 'up') ? curValue + ratio : curValue - ratio;
18
19	if (isDblQuantity){
20		curValue = Math.round(curValue*arMaxOptions.JS_ITEM_CLICK.precisionFactor)/arMaxOptions.JS_ITEM_CLICK.precisionFactor;
21	}
22
23	if (curValue < 0) curValue = 0;
24	if (curValue > 0) {
25
26		//check quantity more availiable amount
27		if(maxQuantity > 0){
28			if(curValue > maxQuantity) {
29				curValue = maxQuantity;
30				return;
31			}
32		}
33		/**/
34		
35		BX("QUANTITY_INPUT_" + basketId).value = curValue;
36		BX("QUANTITY_INPUT_" + basketId).defaultValue = currentValue;
37
38		totalSum=0;
39		$('#basket_line .basket_fly .item[data-id='+basketId+']').each(function(i, element) {
40			id=$(element).attr("data-id");
41			count=BX("QUANTITY_INPUT_" + id).value;
42
43			price = $(document).find("#basket_form input[name=item_price_"+id+"]").val();
44			sum = count*price;
45			totalSum += sum;
46			$(document).find("#basket_form [data-id="+id+"] .summ .price").html(jsPriceFormat(sum));
47		});
48
49		$("#basket_form .foot .wrap_prices .price:not(.discount)").html(jsPriceFormat(totalSum));
50		$("#basket_form .foot .wrap_prices div.discount").fadeTo( "slow" , 0.2);
51
52
53		if(timerBasketUpdate){
54			clearTimeout(timerBasketUpdate);
55			timerBasketUpdate = false;
56		}
57
58		timerBasketUpdate = setTimeout(function(){
59			updateQuantityFly('QUANTITY_INPUT_' + basketId, basketId, ratio);
60			timerBasketUpdate=false;
61		}, 700);
62	}
63}
64
65function updateQuantityFly(controlId, basketId, ratio, animate) {
66
67	var oldVal = BX(controlId).defaultValue, newVal = parseFloat(BX(controlId).value) || 0; bValidChange = false; // if quantity is correct for this ratio
68	var maxQuantity = $("#QUANTITY_INPUT_" + basketId).attr('max');
69
70	if (!newVal) {
71		bValidChange = false;
72		BX(controlId).value = oldVal;
73	}
74	if($("#"+controlId).hasClass('focus'))
75		newVal -= newVal % ratio;
76	var is_int_ratio = (ratio % 1 == 0);
77	newVal = is_int_ratio ? parseInt(newVal) : parseFloat(newVal).toFixed(1);
78
79	if (isRealValue(BX("QUANTITY_SELECT_" + basketId))) { var option, options = BX("QUANTITY_SELECT_" + basketId).options, i = options.length; }
80	while (i--) {
81		option = options[i];
82		if (parseFloat(option.value).toFixed(2) == parseFloat(newVal).toFixed(2)) option.selected = true;
83	}
84
85	BX("QUANTITY_" + basketId).value = newVal; // set hidden real quantity value (will be used in POST)
86	BX("QUANTITY_INPUT_" + basketId).value = newVal; // set hidden real quantity value (will be used in POST)
87
88	$('form[name^=basket_form]').prepend('<input type="hidden" name="BasketRefresh" value="Y" />');
89
90	$.post( arMaxOptions['SITE_DIR']+'ajax/basket_fly.php', $("form[name^=basket_form]").serialize(), $.proxy(function( data){
91		if (timerBasketUpdate==false) {
92			basketFly('open');
93		}
94		$('form[name^=basket_form] input[name=BasketRefresh]').remove();
95	}));
96}
97
98function delete_all_items(type, item_section, correctSpeed){
99	var index=(type=="delay" ? "2" : "1");
100	if(type == "na")
101		index = 4;
102	$.post( arMaxOptions['SITE_DIR']+'ajax/show_basket_fly.php', 'PARAMS='+$("#basket_form").find("input#fly_basket_params").val()+'&TYPE='+index+'&CLEAR_ALL=Y', $.proxy(function( data ) {
103		basketFly('open');
104
105		$('.in-cart').hide();
106		$('.in-cart').each(function(){
107			if ($(this).closest('.counter_wrapp').find('.counter_block').length) {
108				$(this).closest('.button_block').removeClass('wide')
109			}
110		})
111		$('.to-cart').show();
112		$('.to-cart').removeClass("clicked");
113		$('.counter_block').closest('.counter_block_inner').show();
114		$('.counter_block').show();
115		//$('.wish_item').removeClass("added");
116		$('.wish_item.added').hide();
117		$('.wish_item:not(.added)').show();
118		$('.wish_item.to').show();
119		$('.wish_item.in').hide();
120		$('.banner_buttons.with_actions .wraps_buttons .basket_item_add').removeClass('added');
121		$('.banner_buttons.with_actions .wraps_buttons .wish_item_add').removeClass('added');
122
123		getActualBasket();
124
125		if ($('#headerfixed .but-cell .type_block').length) {
126			$('#headerfixed .but-cell .type_block span').text(BX.message('MORE_INFO_SKU'));
127			$('#headerfixed .but-cell .type_block .svg-inline-fw').remove();
128		}
129
130		var eventdata = {action:'loadBasket'};
131		BX.onCustomEvent('onCompleteAction', [eventdata]);
132
133	}));
134}
135
136function deleteProduct(basketId, itemSection, item, th){
137	function _deleteProduct(basketId, itemSection, product_id){
138		arStatusBasketAspro = {};
139		//$.post( arMaxOptions['SITE_DIR']+'ajax/item.php', 'delete_item=Y&item='+product_id, $.proxy(function( data ){
140		$.post( arMaxOptions['SITE_DIR']+'ajax/item.php', 'product_id='+ product_id +'&delete_basket_id='+basketId, $.proxy(function( data ){
141			basketFly('open');
142			getActualBasket();
143			$('.to-cart[data-item='+product_id+']').removeClass("clicked");
144		}));
145	}
146	var product_id=th.attr("product-id");
147	if(checkCounters()){
148		delFromBasketCounter(item);
149		setTimeout(function(){
150			_deleteProduct(basketId, itemSection, product_id);
151		}, 100);
152	}
153	else{
154		_deleteProduct(basketId, itemSection, product_id);
155	}
156}
157
158function delayProduct(basketId, itemSection, th){
159	var product_id=th.attr("product-id");
160	$.post( arMaxOptions['SITE_DIR']+'ajax/item.php', 'wish_item=Y&item='+product_id+'&quantity='+th.find('#QUANTITY_'+basketId).val(), $.proxy(function( data ){
161		basketFly('open');
162		getActualBasket(th.attr('data-iblockid'));
163		$('.to-cart[data-item='+product_id+']').removeClass("clicked");
164		arStatusBasketAspro = {};
165		var eventdata = {action:'loadBasket'};
166		BX.onCustomEvent('onCompleteAction', [eventdata]);
167	}));
168}
169
170function addProduct(basketId, itemSection, th){
171	var product_id=th.attr("product-id");
172	$.post( arMaxOptions['SITE_DIR']+'ajax/item.php', 'add_item=Y&item='+product_id+'&quantity='+th.find('#QUANTITY_'+basketId).val(), $.proxy(function( data ) {
173		basketFly('open');
174		getActualBasket(th.attr('data-iblockid'));
175		arStatusBasketAspro = {};
176		var eventdata = {action:'loadBasket'};
177		BX.onCustomEvent('onCompleteAction', [eventdata]);
178	}));
179}
180
181function checkOutFly(event){
182	event = event || window.event;
183	var th=$(event.target).parent();
184	if(checkCounters('google')){
185		checkoutCounter(1, th.data('text'), th.data('href'));
186	}
187	setTimeout(function(){
188		location.href=th.data('href');		
189	}, 50);
190	
191	return true;
192}
193

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.