PageSourceSearch

https://obl.ru/local/templates/obl/js/global.js?154582556550953

js obl.ru collected 2026-09-24 08:36:35 UTC 50,953 bytes, 1,729 lines download raw bytes

1// Обработка отсутствующего console.log
2if(window.console === undefined) {
3	window.console = {
4		log: function () {
5			return false;
6		}
7	}
8}
9
10// Кроссбраузерный requestAnimationFrame
11window.requestAnimFrame =
12window.requestAnimationFrame       ||
13window.webkitRequestAnimationFrame ||
14window.mozRequestAnimationFrame    ||
15window.oRequestAnimationFrame      ||
16window.msRequestAnimationFrame     ||
17function(callback, element){
18	callback();
19};
20
21// Сообщаяем блокам о готовности API карт
22ymapAPIready = false;
23
24if(typeof ymaps !== 'undefined') {
25	ymaps.ready(function () {
26		ymapAPIready = true;
27		$(document).trigger('ymapAPIready');
28	});
29}
30
31// Предотвращаем всплытие блочных событий
32$(function () {
33	$('.bem').on('resize.block', function (e) {
34		e.stopPropagation();
35	});
36});
37//
38// Узнаем ширину скролла
39$(function getScrollBarWidth () {
40var inner = document.createElement('p');
41inner.style.width = '100%';
42inner.style.height = '200px';
43
44var outer = document.createElement('div');
45outer.style.position = 'absolute';
46outer.style.top = '0px';
47outer.style.left = '0px';
48outer.style.visibility = 'hidden';
49outer.style.width = '200px';
50outer.style.height = '150px';
51outer.style.overflow = 'hidden';
52outer.appendChild (inner);
53
54document.body.appendChild (outer);
55var w1 = inner.offsetWidth;
56outer.style.overflow = 'scroll';
57var w2 = inner.offsetWidth;
58if (w1 == w2)
59    w2 = outer.clientWidth;
60document.body.removeChild (outer);
61
62
63	$('head').append('<style type="text/css">.scroll-fixer{margin-right: -' + (w1 - w2) + 'px;overflow-y: scroll;}</style>');
64	$('head').append('<style type="text/css">.scroll-fixer-pos{right: -' + (w1 - w2) + 'px;overflow-y: scroll;}</style>');
65	$('head').append('<style type="text/css">html.fancybox-margin .fancyfixer{right: ' + (w1 - w2) + 'px;}</style>');
66	// .fancyfixer на фиксированно спозиционированные элементы для ремона fancybox
67});
68
69// Предобработка ресайза, для отсечения лишних событий (в основном для мобил)
70(function () {
71	var windowWidth = $(window).width();
72
73	$(window).on('resize', function () {
74		var newWindowWidth = $(window).width();
75		if(newWindowWidth != windowWidth) {
76			windowWidth = newWindowWidth;
77			$(window).trigger('resizeWidth');
78		}
79	});
80})();
81
82// Функции WP
83var Webprofy = {
84	toggleLabel : function($elements, enable){
85		var disabled = !enable;
86		$elements.each(function(){
87			$(this).toggleClass('disabled', disabled).find('input').prop('disabled', disabled);
88		});
89		return this;
90	},
91	setInputStatus : function($elements, ok, message){
92		var html = '<span class="status-' + (ok ? 'ok' : 'error') + '">' + (message || '') + '</span>';
93		$elements.each(function(){
94			$(this).closest('.field').find('.status').html(html);
95		});
96		return this;
97	},
98	oldIeCheck : $('html').hasClass('bx-ie9') || $('html').hasClass('bx-ie8'),
99
100	isOldIe: function(){
101		return this.oldIeCheck;
102	}
103};
104
105function initSliders(){
106	$('.bxslider').bxSlider({
107		pager: false,
108		adaptiveHeight: true
109	});
110}
111
112sameheight = function(container){
113	var currentTallest = 0,
114		currentRowStart = 0,
115		rowDivs = [],
116		$el,
117		topPosition = 0;
118	$(container).each(function() {
119		$el = $(this);
120		$($el).height('auto');
121		topPostion = $el.position().top;
122
123		if (currentRowStart != topPostion) {
124			for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
125				rowDivs[currentDiv].height(currentTallest);
126			}
127			rowDivs.length = 0; // empty the array
128			currentRowStart = topPostion;
129			currentTallest = $el.height();
130			rowDivs.push($el);
131		} else {
132			rowDivs.push($el);
133			currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
134		}
135		for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
136			rowDivs[currentDiv].height(currentTallest);
137		}
138	});
139};
140
141$(window).load(function() {
142  sameheight('.is-sameheight');
143});
144
145
146$(window).resize(function(){
147  sameheight('.is-sameheight');
148});
149
150
151$.fn.promoSlider = function(_options) {
152
153	var options = $.extend({
154		rotate: true,
155		rotateSpeed: 5000,
156		transitionTime: 1000,
157		transition: function(olditem, newitem, step){
158			newitem.css({'opacity': step});
159		},
160		transitionStart: function(olditem, newitem){
161			// do nothing
162		},
163		transitionEnd: function(olditem, newitem){
164			// do nothing
165		}
166	}, _options);
167
168	if(typeof(this.data('promoSlider')) != "undefined"){
169		return this.data('promoSlider');
170	} else {
171		return this.each(function(){
172
173			var promo = $(this);
174			var items = promo.find('.main-promo-item');
175			var current = items.filter('.active');
176			if(current.length != 1){
177				current = items.eq(0);
178			}
179
180			var timeout;
181
182			// Reset active and create pagination
183
184			items.removeClass('active');
185			current.addClass('active');
186			promo.find('.promo-slider-paginator').remove();
187			promo.append('<ul class="promo-slider-paginator"></ul>');
188			var paginator = promo.find('.promo-slider-paginator');
189			items.each(function(){
190				if($(this).is('.active')){
191					paginator.append('<li class="active"></li>');
192				} else {
193					paginator.append('<li></li>');
194				}
195			});
196
197			// Set Height
198			promo.find('.promo-slider').height(current.height());
199
200			// Set Rotation
201			if(options.rotate){
202				timeout = setInterval(next, options.rotateSpeed);
203			}
204
205			function getNext(){
206				var index = items.index(items.filter('.active'));
207				index++;
208				if(index >= items.length)
209					index = 0;
210				return index;
211			}
212
213			function getPrev(){
214				var index = items.index(items.filter('.active'));
215				index--;
216				if(index < 0)
217					index = items.length - 1;
218				return index;
219			}
220
221			function switchTo(i){
222				items.filter('.active').addClass('transition-from');
223				items.eq(i).addClass('transition-to');
224				var olditem = items.filter('.active');
225				var newitem = items.eq(i);
226				options.transitionStart(olditem, newitem);
227				$({'step': 0}).animate({'step': 1}, {
228					duration: options.transitionTime,
229					step: function(val){
230						options.transition(olditem, newitem, val);
231					},
232					complete: function(){
233						options.transitionEnd(olditem, newitem);
234						items.removeClass('active transition-from transition-to').eq(i).addClass('active');
235						paginator.find('li').removeClass('active').eq(i).addClass('active');
236					}
237				});
238			}
239
240			function next(){
241				switchTo(getNext());
242			}
243			function prev(){
244				switchTo(getPrev());
245			}
246
247			var promoSlider = {
248				next: next,
249				prev: prev
250			};
251
252			$(this).data('promoSlider', promoSlider);
253		});
254	}
255};
256
257function initClickToChange(){
258	$(document).on('click', '.click-to-change-link', function(e){
259		e.preventDefault();
260		var ctc = $(this).parents('.click-to-change');
261		ctc.find('input[name="'+ctc.data('state-input')+'"]').val("1");
262		ctc.find('.state-view').hide();
263		ctc.find('.state-edit').show();
264	});
265	$(document).on('click', '.click-to-cancel-link', function(e){
266		e.preventDefault();
267		var ctc = $(this).parents('.click-to-change');
268		ctc.find('input[name="'+ctc.data('state-input')+'"]').val("");
269		ctc.find('.state-view').show();
270		ctc.find('.state-edit').hide();
271	});
272}
273
274
275
276function initSidebar(){
277	$('header .menu-button').on('click', function(e){
278		$('body').toggleClass('sidebar-opened');
279		e.preventDefault();
280	});
281	$('.container').on('click', function(e){
282		if($(e.target).is('.menu-button'))
283			return;
284		if($('body').is('.sidebar-opened')){
285			$('body').removeClass('sidebar-opened');
286		}
287	});
288}
289
290function initDropdownMenu(){
291	var WAIT_TIME = 500;
292
293	function closeAll(){
294		$('.header-dropdown-menu').removeClass('opened');
295		$('header').removeClass('dropdown-opened');
296		$('.header-menu a').find('span').css({'width': 0});
297	}
298
299	$('.header-menu a[data-dropdown-menu]').each(function(){
300		var dropdown = $('#' + $(this).data('dropdown-menu'));
301		var header = $(this).parents('header');
302
303		$(this).on('mouseover', function(){
304			if(!dropdown.is('.opened')){
305				timestart = new Date().getTime();
306				$(this).find('span').stop(true).animate({'width': '100%'}, WAIT_TIME, function(){
307					$('.header-dropdown-menu').removeClass('opened');
308					dropdown.addClass('opened');
309					header.addClass('dropdown-opened');
310					$('.header-menu a').find('span').css({'width': 0});
311					$(this).css({'width': '100%'});
312				});
313			}
314		});
315		$(this).on('mouseout', function(){
316			if(!dropdown.is('.opened')){
317				$(this).find('span').stop(true).css({'width': '0'});
318			}
319		});
320	});
321	$('header').on('mouseleave', function(){
322		closeAll();
323	});
324	$('header .menu-button').on('click', function(){
325		closeAll();
326	});
327}
328
329function initFixedHeader() {
330	var headerBottom = $('.header-bottom');
331    $(window).scroll(function() {
332        if ($(this).scrollTop() > 1) {
333            headerBottom.addClass("fixed");
334        }
335        else {
336            headerBottom.removeClass("fixed");
337        }
338    });
339}
340
341$.fn.selectRange = function(start, end) {
342    if(!end) end = start;
343    return this.each(function() {
344        if (this.setSelectionRange) {
345            this.focus();
346            this.setSelectionRange(start, end);
347        } else if (this.createTextRange) {
348            var range = this.createTextRange();
349            range.collapse(true);
350            range.moveEnd('character', end);
351            range.moveStart('character', start);
352            range.select();
353        }
354    });
355};
356
357function initFilter(){
358	function numberWithSpaces(x) {
359		return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
360	}
361	function formatPrice(x, significant_digits, convert_factor) {
362
363		if(!convert_factor){
364			convert_factor = 1;
365		}
366		x = Math.round(x * convert_factor);
367
368		var digits = x.toString().length;
369		var divider = 1;
370		if(digits > significant_digits){
371			divider = Math.pow(10, digits - significant_digits);
372		}
373
374		x = x - (x % divider);
375		return numberWithSpaces(x);
376	}
377	function bound(_number, _min, _max){
378		return Math.max(Math.min(_number, _max), _min);
379	}
380
381	$('.bx_filter').each(function(){
382		var CF = $(this);
383
384		// Range control
385		CF.find('.numbers-range-control').each(function(){
386			var RC = $(this);
387			var log = (RC.data('log') == '1');
388			var field_min = RC.find('.range-min');
389			var field_max = RC.find('.range-max');
390			var realfield_min = $('#' + field_min.data('name') );
391			var realfield_max = $('#' + field_max.data('name') );
392			var data_min = RC.data('min');
393			var data_max = RC.data('max');
394			var significant_digits = RC.data('significant-digits') | 3;
395			var convert_factor = RC.data('convert-factor') | 1;
396
397			console.log("Convert factor", convert_factor);
398
399			function updateRealFields(){
400				realfield_min.val(field_min.val().toString().replace(/[^\d]/g, '') / convert_factor);
401				realfield_max.val(field_max.val().toString().replace(/[^\d]/g, '') / convert_factor);
402				realfield_min.change();
403				realfield_max.change();
404			}
405
406			function updateFields(values){
407				if(log){
408					var min = Math.exp(values[0]);
409					var max = Math.exp(values[1]);
410					min = bound(min, data_min, data_max);
411					max = bound(max, data_min, data_max);
412					field_min.val(formatPrice(min, significant_digits, convert_factor));
413					field_max.val(formatPrice(max, significant_digits, convert_factor));
414				} else {
415					field_min.val(formatPrice(values[0], significant_digits, convert_factor));
416					field_max.val(formatPrice(values[1], significant_digits, convert_factor));
417				}
418				updateRealFields();
419			}
420
421			function updateSlider(onchange){
422				var min = field_min.val().toString().replace(/[^\d]/g, '') / convert_factor;
423				var max = field_max.val().toString().replace(/[^\d]/g, '') / convert_factor;
424
425				min = parseInt(min, 10);
426				max = parseInt(max, 10);
427
428				if(isNaN(min) || isNaN(max))
429					return;
430
431				if(onchange){
432					if(max < min) {
433						max = Math.round(min * 1.1);
434					}
435					min = bound(min, data_min, data_max);
436					max = bound(max, data_min, data_max);
437
438				}
439
440				field_min.val(numberWithSpaces(min * convert_factor));
441				field_max.val(numberWithSpaces(max * convert_factor));
442
443				updateRealFields();
444
445				if(log){
446					RC.find('.range-slider').slider({"values": [Math.log(min), Math.log(max)], range: true,
447						min: min,
448						max: max});
449				} else {
450					RC.find('.range-slider').slider({"values": [min, max], range: true,
451						min: min,
452						max: max});
453				}
454			}
455
456			if(parseInt(data_min) == 0 && log){
457				data_min = 1; // Logaryphmic slider can't handle values < 1
458			}
459			if(parseInt(data_max) == 0){
460				console.log('Zero price slider');
461				return;
462			}
463
464			var options = {
465				range: true,
466				max: data_max,
467				min: data_min,
468				values: [RC.data('left'), RC.data('right')],
469				step: 1,
470				slide: function(e, ui){
471					updateFields(ui.values);
472				}
473			}
474
475			if(log){
476				options.step = 0.00001;
477				options.max = Math.log(options.max) + options.step;
478				options.min = Math.log(options.min) - options.step;
479				options.values = [Math.log(options.values[0]), Math.log(options.values[1])];
480			}
481
482			RC.find('.range-slider').slider(options);
483			updateFields(options.values);
484
485			/* RC.find('.range-min, .range-max').on('keydown', function(e){
486				if(e.which > 57){
487					e.preventDefault();
488					return false;
489				}
490			}); */
491
492			RC.find('.range-min, .range-max').on('keyup', function(e){
493				console.log(e.which);
494				if(e.which > 47 || e.which == 8){
495					 // store current positions in variables
496					var start = this.selectionStart;
497					var l = this.value.length;
498					updateSlider();
499					if(this.value.length != l){
500						start += (this.value.length - l);
501					}
502					this.setSelectionRange(start, start);
503				}
504			});
505			RC.find('.range-min, .range-max').on('change blur', function(e){
506				updateSlider(true);
507			});
508		});
509	});
510}
511
512function customSliderItemsSlideOut(items, step){
513	var TIMEALIVE = 0.3;
514	var length = items.length;
515	var timestep = (1 - TIMEALIVE) / length;
516
517	items.each(function(key){
518		var resampledstep = (step - timestep * key) / TIMEALIVE;
519		if(resampledstep < 0)
520			resampledstep = 0;
521		if(resampledstep > 1)
522			resampledstep = 1;
523		$(this).css({
524			'opacity': (1 - resampledstep),
525			'left': (- resampledstep * 200) + 'px'
526		});
527	});
528}
529
530function customSliderItemsSlideIn(items, step){
531	var TIMEALIVE = 0.4;
532	var length = items.length;
533	var timestep = (1 - TIMEALIVE) / length;
534
535	items.each(function(key){
536		var resampledstep = (step - timestep * key) / TIMEALIVE;
537		if(resampledstep < 0)
538			resampledstep = 0;
539		if(resampledstep > 1)
540			resampledstep = 1;
541		$(this).css({
542			'opacity': resampledstep,
543			'top': ((1 - resampledstep) * 200) + 'px'
544		});
545	});
546}
547
548function customSliderTransition(olditem, newitem, step){
549	if(step < 0.33333){
550		step = step * 3; // map back to 0-1
551		customSliderItemsSlideOut(olditem.find('.promo-text > div'), step);
552	} else if (step < 0.66666){
553		step = (step-0.33333) * 3; // map back to 0-1
554		newitem.css({'opacity': (step-0.25) * 2});
555	} else {
556		step = (step-0.66666) * 3; // map back to 0-1
557		//newitem.find('.promo-text').css({'opacity': (step-0.75) * 4});
558		customSliderItemsSlideIn(newitem.find('.promo-text > div'), step);
559	}
560}
561
562function initForms(){
563	// Checkboxes
564	$(document).find('input[type="checkbox"], input[type="radio"]').not('.unstyled').each(function(){
565		$(this).iCheck();
566		$(this).on('ifToggled', function(e){
567			$(this).trigger('change').trigger('click'); // Trigger default event
568		});
569	});
570
571	$(document).on('comparePageReloaded', function(){
572		$('#bx_catalog_compare_block').find('input[type="checkbox"], input[type="radio"]').not('.unstyled').each(function(){
573			$(this).iCheck();
574			$(this).on('ifToggled', function(e){
575				$(this).trigger('change').trigger('click'); // Trigger default event
576			});
577		});
578	});
579}
580
581function initOrderForm(){
582	$('.order-page').each(function(){
583		var $page = $(this),
584			payway = new function(){
585				var $payway = $page.find('.payway-holder'),
586					$radios = $payway.find('.payway-radio');
587
588				$.extend(this, {
589					enableForDelivery : function(delivery){
590						var changeValue = false;
591						$radios.each(function(){
592							var $radio = $(this),
593								deliveryValues = eval($radio.attr('data-deliveries')),
594								disabled = ($.inArray(delivery, deliveryValues) == -1);
595							Webprofy.toggleLabel($radio.closest('label'), !disabled);
596							if(disabled && $radio.is(':checked')){
597								changeValue = true;
598								$radio.prop('checked', false);
599							}
600						});
601
602						if(changeValue){
603							$radios.filter(':enabled:first').prop('checked', true);
604						}
605					}
606				});
607			},
608			delivery = new function(){
609				var $holder = $page.find('.delivery-holder').eq(0),
610					$showPickup = $page.find('.show-pickup'),
611					$hidePickup = $page.find('.hide-pickup'),
612					pickupValues = eval($holder.attr('data-pickup-values')),
613					$radios = $holder.find('.delivery-radio').change(function(){
614						var $radio = $(this),
615							value = $radio.val(),
616							isPickup = $.inArray(value, pickupValues) > -1;
617						$showPickup.toggle(isPickup);
618						$hidePickup.toggle(!isPickup);
619						payway.enableForDelivery(value);
620					}),
621					$radio = $radios.filter(':checked');
622
623				if(!$radio.length){
624					$radio = $radios.eq(0).prop('checked', true);
625				}
626				$radio.trigger('change');
627			}
628	});
629}
630
631var wpCart = function(){
632	var self = this;
633	this.showPopupItemAdded = function(item){
634		$.fancybox(
635			Mustache.render(this.popupTemplate, {
636				item: item,
637				cart_url: "/cart/",
638				messages: self.messages
639			})
640		);
641		BX.onCustomEvent(window,'OnBasketChange');
642	};
643
644	this.popupTemplate = '' +
645	'<div class="item-added-to-cart">' +
646		'<div class="item-added-action-title">{{messages.item_added_to_cart}}</div>' +
647		'<div class="item-added-image"><img src="{{item.image}}" /></div>' +
648		'<div class="item-added-title">{{item.title}}</div>' +
649		'<div class="buttons">' +
650			'<a href="#" class="close button">{{messages.continue_shopping}}</a> ' +
651			'<a href="{{cart_url}}" class="button go-to-cart">{{messages.go_to_cart}}</a>' +
652		'</div>' +
653	'</div>';
654
655	this.messages = {
656		item_added_to_cart: 'Товар добавлен в корзин
656у',
657		continue_shopping: 'Продолжить покупки',
658		go_to_cart: 'Перейти в корзину'
659	};
660};
661
662// Вариант с зумом
663function initCatalogGallery(){
664	$('.image-gallery-slider-with-thumbnails').each(function(){
665		var gallery = $(this);
666		var items = gallery.find('.more-images li');
667		var container = gallery.find('.image');
668		var image = container.find('img');
669
670		if(image.data('fullimage') != image.attr('src')){
671			image.addClass('fancyzoom');
672		}
673
674		items.on('click', function(){
675			if(!$(this).is('.active')){
676				$(this).addClass('active').siblings().removeClass('active');
677				var img = $(this).find('img');
678				container.addClass('loading');
679				image.one('load', function(){
680					container.removeClass('loading');
681				});
682				image.attr('src', img.data('image'));
683				image.attr('data-fullimage', img.data('fullimage'));
684
685				if(image.data('fullimage') != image.attr('src')){
686					image.addClass('fancyzoom');
687				} else {
688					image.removeClass('fancyzoom');
689				}
690			}
691		});
692	});
693
694	$(document).on('mouseover', '.image-gallery-slider-with-thumbnails .image img.fancyzoom', function(e){
695		$('.fancyview-zoom').remove();
696		var zoom = $(this).clone();
697		zoom.attr('src', zoom.data('fullimage'));
698		zoom.insertAfter($(this)).wrap('<div class="fancyview-zoom"></div>');
699
700		$(document).one('mouseout', '.image-gallery-slider-with-thumbnails .image', function(e){
701			//console.log('remove');
702			$('.fancyview-zoom').remove();
703		});
704
705	});
706	$(document).on('mousemove', '.image-gallery-slider-with-thumbnails .image img.fancyzoom', function(e){
707		if($('.fancyview-zoom').length == 0){
708			$(this).mouseover();
709		}
710
711		if(!e.offsetX){
712			posx = e.pageX-$(this).offset().left;
713			posy = e.pageY-$(this).offset().top;
714		} else {
715			posx = e.offsetX;
716			posy = e.offsetY;
717		}
718
719		percentx = posx / $(this).parent().width();
720		percenty = posy / $(this).parent().height();
721
722		$('.fancyview-zoom').css({
723			left: (posx - $('.fancyview-zoom').width() / 2) + 'px',
724			top: (posy - $('.fancyview-zoom').height() / 2) + 'px'
725		});
726
727		$('.fancyview-zoom img').css({
728			left: ($('.fancyview-zoom').width() / 2 - percentx * $('.fancyview-zoom img').width()) + 'px',
729			top: ($('.fancyview-zoom').height() / 2 - percenty * $('.fancyview-zoom img').height()) + 'px'
730		});
731	});
732}
733
734// Вариант без зума
735function initCatalogGallery2(){
736	$('.image-gallery-slider-with-thumbnails').each(function(){
737		var gallery = $(this);
738		var items = gallery.find('.more-images li');
739		var container = gallery.find('.image');
740		var image = container.find('img');
741
742		if(image.data('fullimage') != image.attr('src')){
743			image.addClass('fancyzoom');
744		}
745
746		items.on('click', function(){
747			if(!$(this).is('.active')){
748				$(this).addClass('active').siblings().removeClass('active');
749				var img = $(this).find('img');
750				container.addClass('loading');
751				image.one('load', function(){
752					container.removeClass('loading');
753				});
754				image.attr('src', img.data('image'));
755				image.attr('data-fullimage', img.data('fullimage'));
756
757				/* if(image.data('fullimage') != image.attr('src')){
758					image.addClass('fancyzoom');
759				} else {
760					image.removeClass('fancyzoom');
761				} */
762			}
763		});
764
765		image.on('click', function(){
766			var links = [];
767			items.each(function(){
768				links.push($(this).find('img').data('fullimage'));
769			});
770			var index = items.index(items.filter('.active'));
771			links = links.concat(links.splice(0,index));
772			$.fancybox(links);
773		});
774
775	});
776}
777
778$(function(){
779	// initSliders();
780	// initClickToChange();
781	// initShowOnCondition();
782	// initSidebar();
783	// initDropdownMenu();
784	// initFilter();
785	// initForms();
786	// initOrderForm();
787
788	initCatalogGallery();
789
790	$('.main-promo').promoSlider({
791		transition: customSliderTransition,
792		transitionStart: function(olditem, newitem){
793			newitem.css({opacity: 0});
794			//newitem.find('.promo-text').css({'opacity': 1});
795			newitem.find('.promo-text > div').css({'opacity': 0, 'top': '200px'});
796		},
797		transitionEnd: function(olditem, newitem){
798			//olditem.find('.promo-text').css({'opacity': 1});
799			olditem.find('.promo-text > div').css({'opacity': 1, 'left': 0});
800			//newitem.find('.promo-text').css({'opacity': 1});
801		},
802		transitionTime: 2000
803	});
804
805	$('.catalog-sort-and-view select').each(function(){
806		$(this).select2({
807			minimumResultsForSearch: 20
808		});
809	});
810	$('.bx_filter select').select2({
811		minimumResultsForSearch: 20
812	});
813});
814
815function startPreventBodyScroll(){
816	$('body').addClass('is-fixed');
817	if($(window).width() < 768){
818		$('body').css({'position': 'fixed', width: $('body').width() + 'px'});
819	}
820	
821}
822function endPreventBodyScroll(){
823	$('body').removeClass('is-fixed');
824	if($(window).width() < 768){
825		$('body').css({'position': 'static', 'width': 'auto'});
826	}
827}
828
829// Переносит картинки в бэкграунд родителя
830function jsBgImage(){
831	$('.js-bg-image').each(function(){
832		$this = $(this);
833		$src = $this.attr('src');
834		if($this.data('at-2x') && window.devicePixelRatio > 1.5){
835			$src = $(this).data('at-2x');
836		}
837		$this.parent().css({ 'background-image': 'url("' + $src + '")'});
838		$this.hide();
839	});
840}
841
842$(function(){
843	jsBgImage();
844});
845
846// Прижимаем футер
847$(function () {
848	if($('html').hasClass('is-footer-fixed')) {
849		var body = $('body');
850		var footer = $('.layout__footer');
851		var footerHeight = footer.height() + parseInt(footer.css('margin-top'));
852		body.css('margin-bottom', footerHeight);
853	}
854});
855
856
857
858$(function () {
859	// Модальные окна
860	$('body').on('click', 'a.pupop, .js-modal', function (e) {
861		var target = $(this).data('href') || $(this).attr('href');
862		var additionalTitle = $(this).attr("data-additional-title");
863		var wrapCSS = $(this).attr("data-wrap-css");
864
865		if(!additionalTitle || typeof additionalTitle == 'undefined')
866		{
867			additionalTitle = '';
868		}
869		if(!wrapCSS || typeof wrapCSS == 'undefined')
870		{
871			wrapCSS = '';
872		}
873		
874		if(target.substr(0,1) == '#'){
875			var $target = $(target);
876		} else {
877			$.get(target, function(data){
878				$target = $(data);
879				open(additionalTitle);
880			});
881			return false;
882		}
883
884		if($.fancybox.isOpen) {
885			$.fancybox.close(true);
886			setTimeout(function() {open(additionalTitle);}, 250);
887		} else {
888			open(additionalTitle);
889		}
890		
891		
892
893		function open(additionalTitle) {
894			$.fancybox.open(
895				$target,
896				{
897					padding: 0,
898					margin: 20,
899					closeEffect: 'none',
900					wrapCSS: 'is-default' + ' ' + wrapCSS,
901					closeSpeed: 0,
902					openSpeed: 0,
903					openEffect: 'none',
904					openOpacity: false,
905					closeOpacity: false,
906					fitToView: true,
907					scrolling: 'visible',
908                    touch: false,
909
910					beforeShow: function () {
911						$('html').addClass('fancybox-margin fancybox-lock');
912						$('.fancybox-wrap').livequery(function(){
913							var $context = $(this);
914							var goodField = $context.find(".good-name");
915
916							var checkVal = function ($input, regExp) {
917								var result = regExp.test($input.val());
918								if (result) {
919									$input.closest('.form-standart__field').removeClass('is-error');
920								} else {
921									$input.closest('.form-standart__field').addClass('is-error');
922								}
923
924								return result;
925							};
926							$('[data-mask="phone"]', $context).each(function(){
927								$(this).mask('+7 (999) 999-99-99');
928							});
929							$('[data-mask="email"]', $context).change(function () {
930
931								var regExp = /^([A-Za-z0-9_-]+\.)*[A-Za-z0-9\+_-]+@[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*\.[a-z]{2,6}$/g;
932								checkVal($(this), regExp);
933								return true;
934							});
935							
936							if(additionalTitle)
937							{
938								var formTitle = $(".form-standart__title", $context);
939								formTitle.text(formTitle.text() + ' ' + additionalTitle);
940							}
941							
942							if(goodField.length > 0 && additionalTitle)
943							{
944								goodField.val(additionalTitle);
945							}
946						});
947					}
948				}
949			);
950		}
951
952		return false;
953	});
954
955	// Модальные окна ajax
956	$('.js-modal-ajax').on('click',  function() {
957		var href =  $(this).attr('href');
958		// console.warn('.js-modal-ajax '+href);
959		$.fancybox.open(
960			{
961				href: href,
962                touch: false
963			},
964			{
965				wrapCSS: 'is-ajax',
966				type: 'ajax',
967				fitToView: true,
968				autoResize: true,
969				padding: 20,
970				margin: 20,
971				maxWidth: 1000,
972				afterLoad: function (current, previous) {
973					var $content = $(current.content);
974
975					$content.addClass('_ajax-append');
976					current.content = $('<div>').append($content.clone()).html();
977					$.fancybox.showLoading();
978				},
979				afterShow: function () {
980					$('.fancybox-wrap').livequery();
981					setTimeout(function () {
982						$('.fancybox-wrap .bem').trigger('resize.block');
983						$.fancybox .hideLoading();
984						$('.fancybox-wrap').removeClass('is-ajax');
985					}, 600);
986				}
987			}
988		);
989		return false;
990	});
991
992});
993
994// Плейсхолдеры
995$(function () {
996	$('input[placeholder], textarea[placeholder]').placeholder();
997});
998
999// Стилизация селектов
1000$(function () {
1001	$('select.select2').each(function () {
1002		var placeholder = $(this).attr('placeholder');
1003		var templateSR = function (state) {
1004			var $thstate = $(state.element);
1005
1006			var $state = $(
1007				'<span>' + state.text  + '</span>'
1008			);
1009			if($thstate.data('img')){
1010				$('<span class="is-img-point" style="background-image: url('+ $thstate.data('img') +')"></span>').prependTo($state);
1011			}
1012			if($thstate.data('format')) $state.addClass('is-format-'+ $(state.element).data('format'));
1013			return $state;
1014		};
1015
1016		$(this).select2({
1017			minimumResultsForSearch: 8,
1018			placeholder: placeholder,
1019			templateResult: templateSR,
1020			templateSelection: templateSR
1021		});
1022	});
1023});
1024
1025
1026// Стилизация радиокнопок и чекбоксов
1027$(function () {
1028	$('input[type="checkbox"], input[type="radio"]').not('.unstyled').each(function(){
1029		$(this).iCheck();
1030		$(this).on('ifToggled', function(e){
1031			$(this).trigger('change').trigger('click'); // Trigger default event
1032		});
1033	});
1034});
1035
1036// Скрипт для форм form.result.new
1037$.fn.initWebFormCallback = function(block, options) {
1038/*
1039WP_SUCCESS_MODE
1040
1041S1 - Редирект на страницу "Спасибо"
1042S2 - Редирект на текущую страницу (перезагрузка страницы)
1043S3 - Редирект на текущую страницу с показом информационного попапа, после загрузки страницы
1044S4 - Замена содержимого формы на сообщение об успешной отправке без изменения размера формы
1045S5 - Замена содержимого формы на сообщение об успешной отправке с изменением размера формы
1046S6 - Замена содержимого формы на сообщение об успешной отправке с последующим полным скрытием формы после небольшой паузы (закрыванием попапа).
1047S7 - Показ сообщения об успешной отправке в попапе и очистка (сброс) формы.
1048S8 - Показ сообщения об успешной отправке в попапе БЕЗ очистки (сброса) формы.
1049*/
1050
1051	var default_options = {
1052		WP_SUCCESS_MODE: 'S5'
1053	};
1054
1055	options = $.extend({}, default_options, options);
1056
1057	var $form = $(this);
1058	var blockName = $form.find('input[name=block_name]').val() || block || 'form-standart';
1059	var $context = $form.closest('.'+blockName);
1060
1061	var $inputs = $form.find('[data-fieldname]');
1062	var $fields = $('.' + blockName + '__field', $context);
1063	var $successMessage = $('.success-message-modal',$context);
1064	var isAjax = $context.hasClass('js-ajax') || $form.hasClass('js-ajax');
1065
1066	var MESS = {
1067		'browser': 'Браузер',
1068		'windowsize': 'Размер окна',
1069		'utm_source': 'UTM источник',
1070		'utm_campaign': 'UTM кампания',
1071		'utm_medium': 'UTM медиа',
1072		'utm_keyword': 'UTM ключевые слова',
1073		'location': 'Текущая страница',
1074		'message_sent': 'Сообщение отправлено'
1075	};
1076
1077	if($form.data('form-initiated') !== undefined) return;
1078	$form.data('form-initiated', true);
1079
1080	prepareFieldsValidation();
1081	initFormSubmit();
1082
1083	function getFieldsData(){
1084		var data = {};
1085		$form.find('[data-fieldname]').each(function(){
1086			data[$(this).data('fieldname')] = $(this).val();
1087		});
1088		return data;
1089	}
1090
1091	function getCookie(name) {
1092	  var matches = document.cookie.match(new RegExp(
1093	    "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
1094	  ));
1095	  return matches ? decodeURIComponent(matches[1]) : undefined;
1096	}
1097
1098	function getUtms() {
1099		var utm = getCookie('__utmz');
1100		utms = {};
1101		if(utm){
1102			eval(utm.replace(/.*?(utm.*?)=([^|]*)[|]?/g, "utms['$1'] = '$2';\n"));
1103		}
1104		return utms;
1105	}
1106
1107	function getUserInfo(){
1108		var userinfo = {};
1109		userinfo['browser'] = navigator.userAgent;
1110		userinfo['windowsize'] = $(window).width() + "×" + $(window).height();
1111		userinfo['location'] = document.location.href;
1112		utms = getUtms();
1113		if(utms.utmcsr){
1114			userinfo['utm_source'] = utms.utmcsr;
1115		}
1116		if(utms.utmccn){
1117			userinfo['utm_campaign'] = utms.utmccn;
1118		}
1119		if(utms.utmcmd){
1120			userinfo['utm_medium'] = utms.utmcmd;
1121		}
1122		if(utms.utmcmd){
1123			userinfo['utm_keyword'] = utms.utmctr;
1124		}
1125
1126		var stringresult = "";
1127		$.each(userinfo, function(key, value){
1128			stringresult += MESS[key] + ": " + value + "\n";
1129		});
1130		return stringresult;
1131	}
1132
1133	function prepareFieldsValidation () {
1134		// Обеспечиваем совместимость с предыдущим решением
1135		$fields.filter('[data-necessary]').each(function () {
1136			var $field = $(this);
1137			var $inputs = $('input, textarea, select', $field);
1138
1139			$inputs.each(function () {
1140				var $this = $(this);
1141				$this.removeAttr('required').data('required', true);
1142
1143				$this.on('click keydown change', function() {
1144					$(this).closest('.'+blockName+'__field').removeClass('is-none');
1145				});
1146			});
1147		});
1148
1149		$('input[data-necessary], textarea[data-necessary], select[data-necessary]', $form).each(function () {
1150			var $this = $(this);
1151
1152			$this.data('required', true);
1153
1154			$this.on('click keydown change', function() {
1155				$(this).closest('.'+blockName+'__field').removeClass('is-none');
1156			});
1157		});
1158
1159		// Меняем дефолтное поведение обязательных полей
1160		$('input[required], textarea[required], select[required]', $form).each(function () {
1161			var $this = $(this);
1162
1163			$this.removeAttr('required').data('required', true);
1164
1165			$this.on('click keydown change', function() {
1166				$(this).closest('.'+blockName+'__field').removeClass('is-none');
1167			});
1168		});
1169	}
1170
1171	function initFormSubmit () {
1172		if(isAjax) {
1173			$form.ajaxForm({
1174				dataType: (Webprofy.isOldIe() ? 'text' : 'json'),
1175				beforeSerialize: function(){
1176					$form.find('input[name="confirm"]').remove();
1177					$form.find('input[data-fieldname="_utm"]').val(getUserInfo());
1178				},
1179				beforeSubmit: function(){
1180					var preValidation = checkFields();
1181
1182					/* Очищаем все ошибки формы*/
1183					var $all_error = $('.'+blockName+'__common-error-placeholder', $context);
1184					if($all_error.length) $all_error.html('');
1185					if(preValidation) {
1186						$form
1187							.find('input[type="submit"]')
1188							.prop( "disabled", true)
1189							.addClass('is-disabled');
1190					}
1191
1192					return preValidation;
1193				},
1194				success: ajaxSuccessHandler,
1195				error: ajaxErrorHandler
1196			});
1197		} else {
1198			$form.on('submit', checkFields);
1199		}
1200	}
1201
1202	function ajaxSuccessHandler (data) {
1203		//console.log(data);
1204
1205		$form.find('input[type="submit"]').prop( "disabled", false).removeClass('is-disabled');
1206		$form.find('.error-text').remove();
1207		$form.find('.is-error').removeClass('is-error');
1208
1209		if(Webprofy.isOldIe()) {
1210			eval('var data=' + data);
1211		}
1212
1213		// console.log(data);
1214
1215		if(data.status == 'error'){
1216			var errorCommonContainer = $('.'+blockName+'__common-error-placeholder', $context);
1217			$.each(data.errors, function(key, value){
1218				var $input = $form.find('[data-fieldname="' + key + '"]');
1219				var $container = $input.closest('.'+blockName+'__field');
1220				var $error;
1221
1222				if($container.length > 0){
1223					$error = $container.find('.'+blockName+'__error');
1224					if($error.length==0)
1225						$error = $('<div class="'+blockName+'__error"></div>').appendTo($container);
1226
1227					$error.text(value);
1228					$container.addClass('is-error');
1229
1230					$input.on('change',function(){
1231						$container.removeClass('is-error');
1232					});
1233
1234				} else {
1235					if(errorCommonContainer.length > 0){
1236						$container = errorCommonContainer;
1237					}else{
1238						$form.append('<div class="'+blockName+'__common-error-placeholder"></div>');
1239						errorCommonContainer = $('.'+blockName+'__common-error-placeholder', $context);
1240					}
1241
1242					$(errorCommonContainer).append(
1243						'<div class="'+blockName+'__common-error"><div class="'+blockName+'__common-error-text">'  + value + '</div></div>'
1244					);
1245				}
1246			});
1247			$(document).trigger('webform.error', [$form.attr('name'), data, getFieldsData()]);
1248		}
1249
1250		if(data.status == 'success'){
1251			$(document).trigger('webform.success', [$form.attr('name'), getFieldsData()]);
1252			//console.log(options.WP_SUCCESS_MODE);
1253			//console.log(options);
1254
1255			if (data.message == undefined) {
1256				data.message = options.WP_DEFAULT_SUCCESS_MESSAGE;
1257			}
1258
1259			switch (options.WP_SUCCESS_MODE) {
1260				case 'S1':
1261					if(data.redirect) {
1262						window.location = data.redirect;
1263					} else {
1264						window.location.reload();
1265					}
1266				    break;
1267				case 'S2':
1268					window.location.reload();
1269				    break;
1270				case 'S3':
1271					var loc = window.location;
1272					if(window.location.href.indexOf('?') + 1) {
1273						var popup_get = '&' + options.WP_FORM_ID + '=Y';
1274					} else {
1275						var popup_get = '?' + options.WP_FORM_ID + '=Y';
1276					}
1277					window.location = window.location.href + popup_get;
1278				    break;
1279				case 'S4':
1280					// доработать - Замена содержимого формы на сообщение об успешной отправке без изменения размера формы
1281					$form.parent().html('<div class="success-message">' + data.message + '</div>');
1282				    break;
1283				case 'S5':
1284					$form.parent().html('<div class="success-message">' + data.message + '</div>');
1285				    break;
1286				case 'S6':
1287					// доработать - Замена содержимого формы на сообщение об успешной отправке с последующим полным скрытием формы после небольшой паузы (закрыванием попапа)
1288					$form.parent().html('<div class="success-message">' + data.message + '</div>');
1289				    break;
1290				case 'S8':
1291					/** Используется в Личном кабинете */
1292					$.fancybox.close();
1293					$.fancybox($successMessage , {
1294						afterClose: function(){
1295							if($successMessage.hasClass('js-reload-page')){
1296								window.location = window.location;
1297							}
1298						},
1299						wrapCSS: 'modal-theme',
1300						autoCenter: false,
1301						padding: 0,
1302						fitToView: false
1303					});
1304					break;
1305				case 'S7':
1306				default:
1307					$.fancybox.close();
1308					$.fancybox($successMessage , {
1309						afterClose: function(){
1310							if($successMessage.hasClass('js-reload-page')){
1311								window.location = window.location;
1312							}
1313							$context.find('form').trigger('reset'); // todo: доработать - сброс формы на дефолтное состояние
1314						},
1315						wrapCSS: 'modal-theme',
1316						autoCenter: false,
1317						padding: 0,
1318						fitToView: false
1319					});
1320				    break;
1321
1322			}
1323
1324			/*
1325				if(data.redirect){
1326					document.location = data.redirect;
1327				} else if(data.message) {
1328					$form.parent().html('<div class="success-message">' + data.message + '</div>');
1329				} else {
1330					$.fancybox($successMessage , {
1331						afterClose: function(){
1332							if($successMessage.hasClass('js-reload-page')){
1333								window.location = window.location;
1334							}
1335						},
1336						wrapCSS: 'modal-theme',
1337						autoCenter: false,
1338						padding: 0,
1339						fitToView: false
1340					});
1341				}
1342			*/
1343		}
1344	}
1345
1346	function ajaxErrorHandler (data) {
1347	//	console.log(data);
1348		
1349		if(typeof window.isLocalBuild !== 'undefined') {
1350			data.status = 'success';
1351			ajaxSuccessHandler(data);
1352		} else {
1353			$form.find('input[type="submit"]').prop( "disabled", false).removeClass('disabled');
1354			$form.find('.is-captcha-field').addClass('is-error');
1355		}
1356	}
1357
1358	function checkFields () {
1359		var result = true;
1360
1361		$fields.each(function () {
1362			var $field = $(this);
1363			var $inputs = $('input, textarea, select', $field);
1364			if($field.hasClass('is-error') || $field.hasClass('is-none')) {
1365				result = false;
1366				return;
1367			}
1368
1369			$inputs.each(function () {
1370				var $input = $(this);
1371				var checkResult = true;
1372				var isContinue = true;
1373
1374				if($input.data('required') == undefined) return;
1375
1376				switch($input.attr('type')) {
1377					case 'checkbox':
1378						if(!$input.data('required')) {
1379							checkResult = true && checkResult;
1380						} else if($inputs.filter(':checked').length == 0) {
1381							checkResult = false;
1382							$field.addClass('is-none');
1383						}
1384						result = checkResult && result;
1385						break;
1386
1387					case 'radio':
1388						if(!$input.data('required')) {
1389							checkResult = true && checkResult;
1390						} else if($inputs.filter(':checked').length == 0) {
1391							checkResult = false;
1392							$field.addClass('is-none');
1393						}
1394						result = checkResult && result;
1395						break;
1396
1397					default:
1398						if(!$input.data('required')) {
1399							checkResult = true && checkResult;
1400						} else if($input.val() == '') {
1401							checkResult = false;
1402							$field.addClass('is-none');
1403						}
1404						result = checkResult && result;
1405						break;
1406				}
1407			});
1408		});
1409
1410		return result;
1411	}
1412};
1413
1414$.fn.initWebForm = function(){
1415    var form = $(this);
1416    var fields = $(this).find('[data-fieldname]');
1417
1418    var Webprofy = {
1419        oldIeCheck : $('html').hasClass('bx-ie9') || $('html').hasClass('bx-ie8'),
1420
1421        isOldIe: function(){
1422            return this.oldIeCheck;
1423        }
1424    };
1425
1426
1427    var MESS = {
1428        'browser': 'Браузер',
1429        'windowsize': 'Размер окна',
1430        'utm_source': 'UTM источник',
1431        'utm_campaign': 'UTM кампания',
1432        'utm_medium': 'UTM медиа',
1433        'utm_keyword': 'UTM ключевые слова',
1434        'location': 'Текущая страница',
1435        'message_sent': 'Спасибо. Ваше сообщение отправлено!'
1436    };
1437
1438    function getFieldsData(){
1439        var data = {};
1440        form.find('[data-fieldname]').each(function(){
1441            data[$(this).data('fieldname')] = $(this).val();
1442        });
1443        return data;
1444    }
1445
1446    function getCookie(name) {
1447        var matches = document.cookie.match(new RegExp(
1448            "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
1449        ));
1450        return matches ? decodeURIComponent(matches[1]) : undefined;
1451    }
1452
1453    function getUtms() {
1454        var utm = getCookie('__utmz');
1455        utms = {};
1456        if(utm){
1457            eval(utm.replace(/.*?(utm.*?)=([^|]*)[|]?/g, "utms['$1'] = '$2';\n"));
1458        }
1459        return utms;
1460    }
1461
1462    function getUserInfo(){
1463        var userinfo = {};
1464        userinfo['browser'] = navigator.userAgent;
1465        userinfo['windowsize'] = $(window).width() + "×" + $(window).height();
1466        userinfo['location'] = document.location.href;
1467        utms = getUtms();
1468        if(utms.utmcsr){
1469            userinfo['utm_source'] = utms.utmcsr;
1470        }
1471        if(utms.utmccn){
1472            userinfo['utm_campaign'] = utms.utmccn;
1473        }
1474        if(utms.utmcmd){
1475            userinfo['utm_medium'] = utms.utmcmd;
1476        }
1477        if(utms.utmcmd){
1478            userinfo['utm_keyword'] = utms.utmctr;
1479        }
1480
1481        var stringresult = "";
1482        $.each(userinfo, function(key, value){
1483            stringresult += MESS[key] + ": " + value + "\n";
1484        });
1485        return stringresult;
1486    }
1487
1488    $(this).ajaxForm({
1489        dataType: (Webprofy.isOldIe() ? 'text' : 'json'),
1490        beforeSerialize: function(){
1491            form.find('input[name="confirm"]').remove();
1492            form.find('input[data-fieldname="_utm"]').val(getUserInfo());
1493        },
1494        beforeSubmit: function(){
1495            form.find('input[type="submit"]').prop( "disabled", true).addClass('disabled');
1496        },
1497        success: function(data){
1498            form.find('input[type="submit"]').prop( "disabled", false).removeClass('disabled');
1499            form.find('.error-text').remove();
1500            form.find('.error').removeClass('error');
1501            if(Webprofy.isOldIe()) {
1502                eval('var data=' + data);
1503            }
1504            if(data.status == 'error'){
1505                $.each(data.errors, function(key, value){
1506                    var container = form.find('[data-fieldname="' + key + '"]');
1507                    if(container.length > 0){
1508                        container.addClass('error');
1509                    } else {
1510                        //container = form;
1511                    }
1512                });
1513                $(document).trigger('webform.error', [form.attr('name'), data, getFieldsData()]);
1514            } else if(data.status == 'success'){
1515                if(data.redirect){
1516                    document.location = data.redirect;
1517                } else if(data.message) {
1518                	if($("#is_white_form").val()==1){
1519                        if(location.href.indexOf("en")+1){
1520                            form.parent().html('<div class="request__form success-message logo_eng_white_form">' + data.message + '</div>');
1521                        }else{
1522                            form.parent().html('<div class="request__form success-message for_white_form">' + data.message + '</div>');
1523						}
1524					}else{
1525
1526                        form.parent().html('<div class="request__form success-message">' + data.message + '</div>');
1527					}
1528                } else {
1529                    if($("#is_white_form").val()==1){
1530                        form.parent().html('<div class="request__form success-message for_white_form">' + data.message + '</div>');
1531					}else{
1532                        form.parent().html('<div class="request__form success-message">' + data.message + '</div>');
1533					}
1534                }
1535            }
1536        },
1537        error: function(){
1538            form.find('input[type="submit"]').prop( "disabled", false).removeClass('disabled');
1539            alert("Server not available");
1540        }
1541    });
1542};
1543
1544//Обновляем последние просмотренные товары
1545function updateViewList(site_id, product_id, parent_id) {
1546	var href="/bitrix/components/bitrix/catalog.element/ajax.php";
1547	$.ajax({
1548		type: "POST",
1549		url: href,
1550		dataType: "text",
1551		data: {
1552			AJAX: "Y",
1553			SITE_ID: site_id,
1554			PRODUCT_ID: product_id,
1555			PARENT_ID: parent_id
1556		}
1557	}).done(function(resp) {
1558		//Thanks, bitrix
1559		eval('var response='+resp);
1560		if(response.STATUS == 'SUCCESS') {
1561			// console.log('updateViewList.ok');
1562		}else{
1563			console.warn('updateViewList.error');
1564		}
1565	});
1566}
1567
1568// контент зависимый от чекбокса .show-on-condition
1569function initShowOnCondition(){
1570	$('[data-watch]').each(function(){
1571		var $this = $(this),
1572			watch = $this.attr('data-watch'),
1573			$that = $(watch);
1574
1575		var change = $this.attr('data-change');
1576		if(change){
1577			$that.change(function(){
1578				try{
1579					eval(change);
1580				}
1581				catch(e){
1582					console.error('bad data-change');
1583				}
1584			}).eq(0).trigger('change');
1585			return;
1586		}
1587
1588		var showSelectEquals = $this.attr('data-show-select-equals');
1589		if(showSelectEquals){
1590			$this.change(function(){
1591				$that.filter(':checked').val('');
1592			});
1593		}
1594	});
1595
1596	var listeners = [];
1597
1598	$('.show-on-condition').each(function(){
1599		var self = $(this);
1600		var condition = self.data('condition');
1601
1602		// Complex parser :)
1603		var conditions = condition.split(" and ");
1604
1605		$.each(conditions, function(key, value){
1606			var operands = value.split(" ");
1607			if(operands.length == 3){
1608				listeners.push({
1609					input: operands[0],
1610					conditions: conditions,
1611					object: self
1612				});
1613			}
1614		});
1615	});
1616
1617	$(document).on('change', 'input, textarea, select', function(){
1618		var name = $(this).attr('name');
1619		updateConditions(name);
1620	});
1621
1622	function updateConditions(name){
1623		$.each(listeners, function(key, value){
1624
1625			if(typeof(name) === 'string' && value.input != name)
1626				return; // skip this one;
1627
1628			var result = true;
1629			$.each(value.conditions, function(k, v){
1630				var operands = v.split(" ");
1631				if(operands.length == 3){
1632					var input = $('[name="' + operands[0] + '"]');
1633					if(input.length >= 1){
1634						var input_value;
1635						if(input.length == 1){
1636							input_value = input.val();
1637						} else {
1638							input_value = input.filter(':checked').val();
1639						}
1640
1641						if(input_value == operands[2]){
1642							result = result & (operands[1] == "is");
1643						} else {
1644							result = result & (operands[1] == "not");
1645						}
1646					} else {
1647						result = false;
1648					}
1649				} else {
1650					result = false;
1651				}
1652			});
1653			if(result){
1654				value.object.show();
1655			} else {
1656				value.object.hide();
1657			}
1658		});
1659	}
1660	updateConditions();
1661}
1662$(function(){
1663	initShowOnCondition();
1664});
1665
1666$(function(){
1667	// Content table wrapper
1668	$('.content-area table').each(function(){
1669		$(this).wrap('<div class="layout__content-table"></div>');
1670	});
1671});
1672
1673// Layout-overflow
1674// Фиксит горизонтальный скролл из-за неверной ширины экрана с учётом скроллбара
1675$(function(){
1676	function recalculateOverflow(){
1677		if(window.innerWidth < 1024){
1678			// Не применимо для малых разрешений
1679			$('.layout__overflow[style]').removeAttr('style');
1680		} else {
1681			var ratio = document.body.clientWidth * 100 / window.innerWidth;
1682			var margin = ratio / -1.995;
1683			$('.layout__overflow').each(function(){
1684				$(this).css({
1685					'width': ratio + 'vw',
1686					'margin-left': margin + 'vw'
1687				});
1688			});
1689		}
1690	}
1691	if(document.body.clientWidth < window.innerWidth){
1692		recalculateOverflow();
1693		$(window).on('resize', recalculateOverflow);
1694	}
1695});
1696
1697function plural(n,f){n%=100;if(n>10&&n<20)return f[2];n%=10;return f[n>1&&n<5?1:n==1?0:2]}
1698
1699
1700$(function(){
1701    $('[data-mask="phone"]', '.formfeedback').each(function(){
1702        $(this).mask('+7 (999) 999-99-99');
1703    });
1704});
1705
1706$(document).on("ready", function () {
1707	$(".traffic").click(function () {
1708		$(".marine_overlay").css("pointer-events","all");
1709    });
1710    /*$(document).on("click",".delete_news_element", function () { //close на новостях
1711    	$this = $(this);
1712        $.ajax({
1713            type: "POST",
1714            url: "/ajax/add_news_element.php",
1715            data: {
1716              	offset: $("#news_offset").val()
1717            },
1718			success: function (result) {
1719                result = JSON.parse(result);
1720            	if(!result.not_remove){
1721                    $this.parents().eq(1).remove();
1722                    $("#news_offset").val(Number($("#news_offset").val())+Number(1));
1723                    $(".news_block").append(result.element_to_add);
1724				}
1725
1726            }
1727        })
1728    });*/
1729});

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.