PageSourceSearch

https://daslager.ru/bitrix/templates/ishop/js/general.js

js daslager.ru collected 2026-10-08 14:18:28 UTC 15,206 bytes, 416 lines download raw bytes

1$(window).resize(function() { $('.menu .cat_menu').width($('ul.menu').width()+7);});
2
3$.fn.keyupDelay = function( cb, delay )
4{
5	if ( delay == null ) { delay = 1000; }
6	var timer = 0;
7	return $(this).on('keyup',function() { clearTimeout(timer); timer = setTimeout( cb , delay ); });
8}
9
10function onLoadjqm(name, hash)
11{
12	hash.w.addClass('show').css({
13		'margin-left': ($(window).width() > hash.w.outerWidth() ? '-' + hash.w.outerWidth() / 2 + 'px' : '-' + $(window).width() / 2 + 'px'),
14		'top': $(document).scrollTop() + (($(window).height() > hash.w.outerHeight() ? ($(window).height() - hash.w.outerHeight()) / 2 : 10))   + 'px'
15	});
16	
17	if( name == 'found_cheaper' ) { $('input.item_name').val($(hash.t).attr('item-name')); }
18	else if( name == 'resume_send' ) { $('input.vacancy').val($(hash.t).attr('jobs')); }
19	else if( name == 'staff_send' ) { $('input.staff_fio').val($(hash.t).attr('item-name')); $('input.staff_email').val($(hash.t).attr('item-mail')); }
20	else if ( name == 'one_click_buy' || name == 'one_click_buy_basket')
21	{	
22		$('#one_click_buy_form').validate({
23			'submitHandler':
24//		$('#one_click_buy_form').submit(
25				function(form, event) 
26				{
27					var strAction = $(form).attr('action');
28					var newStrAction = '';			
29					if( strAction.indexOf('/') === 0 ) newStrAction = strAction;
30					else newStrAction = '/' + strAction;
31
32					$.ajax({
33						url: newStrAction,
34						data: $(form).serialize(),
35						type: 'POST',
36						dataType: 'json',
37						error: function(data) { alert('Error connecting server'); },
38						success: function(data) 
39						{
40							if(data.result=='Y') {
41								$('.one_click_buy_result').show();
42								$('.one_click_buy_result_success').show();
43								$('#one_click_buy_form').parents(".popup").addClass("pagereload");
44							} 
45							else {
46								$('.one_click_buy_result').show();
47								$('.one_click_buy_result_fail').show();
48								$('.one_click_buy_result_text').text(data.message);
49							}
50							$('.one_click_buy_modules_button', self).removeClass('disabled');
51							$('#one_click_buy_form').hide();
52							$('#one_click_buy_form_result').show();
53						}
54					});
55					return false;
56				}
57			}
58		);
59		
60		$('#one_click_buy_form').parents(".popup").jqmAddClose('.jqmClose');
61	}
62	
63	if (name =='show_offer_stores'){$(".offers_stores_frame").css("marginLeft", -$(".offers_stores_frame").width()/2);}
64	$('.'+name+'_frame').show();
65}
66
67/* ajax cart */
68function UpdateCart(res)
69{
70	jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_cart.php', 'basket', false);
71	jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_small_cart.php', 'basket_small', false);
72}
73
74function UpdateCompare(res)
75{
76	jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_compare.php', 'compare', true);
77	jsAjaxUtil.CloseLocalWaitWindow('wait_id', 'ajax_fade');
78	$('#ajax_fade').prop('id', '');
79}
80
81function SetQuantity( div, type )
82{
83	var count = parseFloat(div.parent().find('.text').val());
84	if( type == '+' ){count++;}else if( type == '-' && count > 1 ){count--;}
85	div.parent().find('.text').val(count);
86}
87
88function oneClickBuy(elementID, iblockID)
89{	
90	var elementQuantity = $(".middle_info").find("input[name=count_items]").val(); 
91	if (typeof elementQuantity == "undefined") { elementQuantity = 1; }
92	$('body').append('<span class="one_click_buy_item_popup"></span>');
93
94	$('.one_click_buy_frame').jqm({
95		trigger: '.one_click_buy_item_popup', 
96		onLoad: function(hash){
97			onLoadjqm('one_click_buy', hash);
98		},
99		onHide: function(hash){
100			if(hash.w.hasClass("pagereload")){
101				location.href = location.href;
102			}
103			hash.w.removeClass('show');
104			hash.o.remove();
105			hash.w.empty();
106			hash.w.css({'display': 'none'});
107		},
108		ajax: arIShopOptions["SITE_DIR"]+'ajax/one_click_buy.php?ELEMENT_ID='+elementID+'&IBLOCK_ID='+iblockID+'&ELEMENT_QUANTITY='+elementQuantity
109	});
110	$('.one_click_buy_item_popup').click();
111}
112		
113
114function oneClickBuyBasket ()
115{	
116	$('body').append('<span class="one_click_buy_item_popup"></span>');
117	$('.one_click_buy_frame').jqm({
118		trigger: '.one_click_buy_item_popup',
119		onLoad: function(hash){
120			onLoadjqm('one_click_buy', hash);
121		},
122		onHide: function(hash){
123			if(hash.w.hasClass("pagereload")){
124				location.href = location.href;
125			}
126			hash.w.removeClass('show');
127			hash.o.remove();
128			hash.w.empty();
129			hash.w.css({'display': 'none'});
130		},
131		ajax: arIShopOptions["SITE_DIR"]+'ajax/one_click_buy_basket.php'
132	});
133	$('.one_click_buy_item_popup').click();
134}
135
136function showOffersStores(ELEMENT_ID, MIN_AMOUNT, USE_MIN_AMOUNT, USE_STORE_SCHEDULE, USE_STORE_PHONE, STORE_PATH)
137{	
138	$('body').append('<span class="offers_stores_popup"></span>');
139	$('.offers_stores_frame').jqm({trigger: '.offers_stores_popup', onLoad: function(hash){ onLoadjqm('show_offer_stores', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/offer_stores.php?ELEMENT_ID='+ELEMENT_ID+'&MIN_AMOUNT='+MIN_AMOUNT+'&USE_MIN_AMOUNT='+USE_MIN_AMOUNT+'&USE_STORE_SCHEDULE='+USE_STORE_SCHEDULE+'&STORE_PATH='+STORE_PATH});
140	$('.offers_stores_popup').click();
141}
142
143function addToCart(element, mode, text, type, basketAddr, element_id, sku_id)
144{
145	if( !element && !element.href ) return;
146	var href = element.href;
147	var button = $(element);
148	button.unbind('click').removeAttr("onclick").attr("href", basketAddr).find("span").text(text);
149	if (!button.hasClass("add_item")){button.text(text);}
150	button.addClass("added");
151	$('body').append('<span class="add_item_popup"></span>');
152	if (sku_id) { $('.add_item_frame').jqm({trigger: '.add_item_popup', onLoad: function(hash){ onLoadjqm('add_item', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/add_item.php?ELEMENT_ID='+element_id+'&SKU_ID='+sku_id}); }
153	else { $('.add_item_frame').jqm({trigger: '.add_item_popup', onLoad: function(hash){ onLoadjqm('add_item', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/add_item.php?ELEMENT_ID='+element_id}); }
154	$('.add_item_popup').click();
155	
156	var quantity = button.parents(".middle_info").find("input[name=count_items]").val() || 1; 
157	
158	if (href)
159		$.get( href+"&quantity="+quantity+"&ajax_buy=1", $.proxy(
160			function(data) 
161			{
162				jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_cart.php', 'basket', false);
163				jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_small_cart.php', 'basket_small', false);
164			}, button)
165		);
166	return false;
167}
168
169function addToSubscribe(element, text)
170{
171	var href = element.href;
172	if (href)$.get(href, function() {		});
173	return false;
174}
175
176function addToCompare(element, mode, deleteUrl) 
177{
178	if (!element && !element.href) return;
179	var href = element.href;
180	var button = $(element);
181	if( mode == 'list' )
182	{
183		//var removeCompare = '<input type="checkbox" class="addtoCompareCheckbox"/ checked><span class="checkbox_text">'+text+'</span>';
184		//button.html(removeCompare);
185		//button.attr("href", deleteUrl);
186		//button.attr("onclick", "return deleteFromCompare(this, \'"+mode+"\', \'"+text+"\', \'"+href+"\');");
187	}
188	else if( mode == 'detail' )
189	{
190		button.attr("href", deleteUrl);
191		button.toggleClass('active');
192		button.attr("onclick", "return deleteFromCompare(this, \'"+mode+"\', \'"+href+"\');");
193	}
194	
195	var element_id = button.attr("element_id");
196	element_id=element_id.substring(1 ,element_id.length);
197	jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_compare.php?add='+element_id, 'compare', false);
198	return false;
199}
200
201function deleteFromCompare(element, mode, addUrl) 
202{
203	if (!element && !element.href) return;
204	var href = element.href;
205	var button = $(element);
206	if( mode == 'list' )
207	{
208		//var removeCompare = '<input type="checkbox" class="addtoCompareCheckbox"/ checked><span class="checkbox_text">'+text+'</span>';
209		//button.html(removeCompare);
210		//button.attr("href", deleteUrl);
211		//button.attr("onclick", "return deleteFromCompare(this, \'"+mode+"\', \'"+text+"\', \'"+href+"\');");
212	}
213	else if( mode == 'detail' )
214	{
215		button.attr("href", addUrl);
216		button.toggleClass('active');;
217		button.attr("onclick", "return addToCompare(this, \'"+mode+"\', \'"+href+"\');");
218	}
219	var element_id = button.attr("element_id");
220	element_id=element_id.substring(1 ,element_id.length);
221	jsAjaxUtil.InsertDataToNode(arIShopOptions["SITE_DIR"]+'ajax/show_compare.php?add='+element_id, 'compare', false);
222	return false;
223}
224
225$(document).ready(function() 
226{
227    $('#oferta').prop('checked', true);//checked oferta
228    $('#USER_REMEMBER').prop('checked', true); //checked USER_REMEMBER
229    $('#doc1').prop('checked', true);//checked
230    $('#doc2').prop('checked', true);//checked
231
232	$('.table_item img').load(function()
233	{
234		var w = $(this).width();
235		if( w % 2 == 1 ){$(this).css('width', w+1+'px');}
236	});
237	
238	$('.menu .cat_menu').width($('ul.menu').width()+7);
239	$('.group_item .image').each(function(){ /*$(this).css('width', $(this).css('height'))*/});
240	
241	 $('.flexslider').flexslider({
242		animation: "slide",
243		slideshow: true,
244		slideshowSpeed: 5000,
245		animationSpeed: 600,
246		directionNav: false,
247		pauseOnHover: true,
248		video: true
249	});
250	
251	$.elastislide.prototype._setCurrentValues = function()
252	{
253		this.itemW			= this.$items.outerWidth(true); 		// the total space occupied by one item
254		this.sliderW		= this.itemW * this.itemsCount; // total width of the slider / <ul> // this will eventually change on window resize
255		this.visibleWidth	= this.$esCarousel.width(); // the ul parent's (div.es-carousel) width is the "visible" width
256		var b_w = this.visibleWidth;
257		var b_c = Math.floor(b_w / 185);
258		var b_w_n = Math.floor(this.visibleWidth / b_c);
259		this._setDim(b_w_n);
260		this.fitCount		= Math.floor( this.visibleWidth / this.itemW ); // how many items fit with the current width
261	}
262	
263	var b_w = $('.brands_list').width();
264	var b_c = Math.floor(b_w / 185);
265	var b_w_n = $('.brands_list').width() / b_c;
266	
267	$('.brands_list').elastislide
268	({
269		margin: 0,
270		imageW: b_w_n,
271		border: 0,
272		min_imageW: 185
273	});
274	
275	$('.news_wr .tabs i').click(function()
276	{
277		left = $(this).attr('id').replace('tab','');
278		$(".news_cols ul").css('left',-left);
279		$('.news_wr .tabs i').removeClass('active');
280		$(this).addClass('active');
281	});
282
283	$('.fancy').fancybox();
284	
285/* popup */
286	$('.found_cheaper_frame').jqm({trigger: '.found_cheaper', onLoad: function(hash){ onLoadjqm('found_cheaper', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/form_found_cheaper.php'});
287	$('.staff_send_frame').jqm({trigger: '.staff_send', onLoad: function(hash){ onLoadjqm('staff_send', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/form_staff_send.php'});
288	$('.resume_send_frame').jqm({trigger: '.resume_send', onLoad: function(hash){ onLoadjqm('resume_send', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/form_resume_send.php'});
289	$('.compare_frame').jqm({trigger: '.go_to_compare', onLoad: function(hash){ onLoadjqm('compare', hash); }, ajax: arIShopOptions["SITE_DIR"]+'ajax/show_compare_list.php'});
290	
291/* breadcrumb */
292	$('.drop_section .name').mouseover( function(){$(this).parent().find('.section_list').show();});
293	$('.drop_section .section_list').mouseleave( function(){$(this).hide();});
294
295/* show number */
296	$('.drop_number .number').mouseover( function(){$(this).parent().find('.number_list').show();});
297	$('.drop_number .number_list').mouseleave( function(){$(this).hide();});
298	
299/* compare */
300	
301	/*$('.compare .link').toggle(function(e)
302	{
303		e.preventDefault();
304		$('.compare_list').show();
305	},
306	function(e){
307		e.preventDefault();
308		$('.compare_list').hide();
309	})
310	
311	$('.compare_list a.close').live('click', function(e){
312		e.preventDefault();
313		$('.compare_list').hide();
314	})*/
315	
316/* wish item */
317	
318	$('.wish_item').live( 'click', function(e)
319	{
320		if( !$(this).attr('href') ) return;
321		e.preventDefault();
322		var href = $(this).attr('href');
323		$(this).unbind('click').removeAttr("href");
324		$(this).closest('.item_ws').prop('id', 'ajax_fade');
325		var item_id = href;
326		item_id = item_id.substring(1);
327		var wish = '';
328		if( $(this).hasClass('active') ) { $(this).removeClass('active'); wish = 'N';}
329		else { $(this).addClass('active'); wish = 'Y'; }
330		data = {"item_id" : item_id,"wish_item" : wish	};
331		BX.ajax.post(arIShopOptions["SITE_DIR"]+'ajax/item.php', data,	function(res){ setTimeout( UpdateCart(res), 1000 ); })
332	})
333	
334/* item detail */
335	$('.slides').mouseover(function(){	$(this).find('span.lupa').show();})
336	$('.slides').mouseout(function(){$(this).find('span.lupa').hide();})
337	$('.counter_block input').keypress(function(event){
338		var key, keyChar;
339		if(!event) var event = window.event;
340		if (event.keyCode) key = event.keyCode;
341		else if(event.which) key = event.which;
342		if(key == null || key == 0 || key == 8 || key == 13 || key == 9 || key == 46 || key == 37 || key == 39 ) return true;
343		keyChar = String.fromCharCode(key);
344		if(!/\d/.test(keyChar)) return false;
345	});
346	
347	$('.counter_block input').live('change', function() { if( $(this).val() == '0' ){ $(this).val(1); }	});
348	
349/* thumbs */
350	$('.slides li').not('.current').hide();
351	$('.thumbs li a').live("click", function(e)
352	{
353		e.preventDefault();
354		$('.thumbs li').removeClass('current');
355		$(this).closest('li').toggleClass('current');
356		$('.slides li').hide();
357		$('.slides li'+$(this).attr('href')).show();
358	});
359	
360/* tabs */
361	$('.add_review').live('click', function() { $('.tabs_section ul.tabs li#reviews').click(); } );
362	$('.tabs_section ul.tabs').delegate('li:not(.current)', 'click', function(e)
363	{
364		e.preventDefault();
365		$(this).addClass('current').siblings().removeClass('current')
366		.parents('.tabs_section').find('.box').eq($(this).index()).fadeIn(100).siblings('.box').hide();
367	})
368	
369/* accordion */
370	$('.accordion_list .item_list').hide().first().show();
371	$('.accordion_list .item_name').live('click', function(e) { e.preventDefault(); $(this).next('.item_list').slideToggle(); })
372	
373/* plus minus */
374	$('.counter_block .plus').live('click', function() { SetQuantity($(this), '+');})
375	$('.counter_block .minus').live('click', function() { SetQuantity($(this), '-');})
376	
377/* differences */
378	$('.differences .left_arrow, .differences .right_arrow').live("click", function(){
379		var pos_start = $('input[name$="start_position"]').val();
380		var pos_end = $('input[name$="end_position"]').val();
381		var count_items = $('.differences td.item_td').length;
382		if( $(this).hasClass('inc') && pos_end < count_items )
383		{
384			$('input[name$="start_position"]').val(++pos_start);
385			$('input[name$="end_position"]').val(++pos_end);
386		}
387		else if( $(this).hasClass('dec') && pos_start > 1 )
388		{
389			$('input[name$="start_position"]').val(--pos_start);
390			$('input[name$="end_position"]').val(--pos_end);
391		}
392		$('.differences td.item_td').each(function()
393		{
394			var index = $(this).index();
395			if( index < pos_start || index > pos_end ) { $(this).hide(); }else{ $(this).show(); }
396		})
397		$('.differences td.prop_item').each(function()
398		{
399			var index = $(this).index();
400			if( index < pos_start || index > pos_end ){ $(this).hide(); }else{ $(this).show(); }
401		})
402	});
403	
404	$('.mini-menu').click(function() {
405		if(!$('ul.menu').hasClass('visible-menu')){
406			$(this).css('margin-bottom', '0');
407			$('ul.menu').addClass('visible-menu');
408			$('ul.menu').removeClass('hidable-menu');
409		}
410		else{
411			$(this).css('margin-bottom', '17px');
412			$('ul.menu').addClass('hidable-menu');
413			$('ul.menu').removeClass('visible-menu');
414		}
415	});
416});

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.