PageSourceSearch

https://pk-intellekt.ru/bitrix/templates/aspro_next/components/bitrix/catalog.smart.filter/main/script.js

js pk-intellekt.ru collected 2026-10-08 20:36:50 UTC 28,139 bytes, 1,063 lines download raw bytes

1$(document).ready(function(){
2	$(".bx_filter_parameters_box_title").click( function(e){
3		if(!$(e.target).hasClass('tooltip')){
4			var active=2;
5			if ($(this).closest(".bx_filter_parameters_box").hasClass("active")) { $(this).next(".bx_filter_block").slideUp(100); }
6			else { $(this).next(".bx_filter_block").slideDown(200); }
7			$(this).closest(".bx_filter_parameters_box").toggleClass("active");
8
9			if($(this).closest(".bx_filter_parameters_box").hasClass("active")){
10				active=3;
11			}
12
13			$.cookie.json = true;
14			$.cookie("NEXT_filter_prop_"+$(this).closest(".bx_filter_parameters_box").data('prop_code'), active,{
15				path: '/',
16				domain: '',
17				expires: 360
18			});
19		}
20	});
21	$('.bx_filter_parameters_box').each(function(){
22		if($.cookie("NEXT_filter_prop_"+$(this).data('prop_code'))==2){
23			$(this).removeClass('active');
24			$(this).find('.bx_filter_block').hide();
25		}else if($.cookie("NEXT_filter_prop_"+$(this).data('prop_code'))==3){
26			$(this).addClass('active');
27			$(this).find('.bx_filter_block').show();
28		}
29	})
30	$(".hint .icon").click(function(e){
31		e.stopPropagation();
32		var tooltipWrapp = $(this).parents(".hint");
33		var bActive = tooltipWrapp.is('.active');
34		$('.bx_filter .hint.active').removeClass("active").find(".tooltip").slideUp(200);
35		if(!bActive){
36			tooltipWrapp.addClass("active").find(".tooltip").slideDown(200);
37			tooltipWrapp.find(".tooltip_close").click(function(e) { e.stopPropagation(); tooltipWrapp.removeClass("active").find(".tooltip").slideUp(200);});
38		}
39	});
40	$(document).click(function(e) {
41		if(!$(e.target).hasClass('tooltip')){
42			$('.bx_filter .hint.active').removeClass("active").find(".tooltip").slideUp(200);
43		}
44	});
45})
46
47function JCSmartFilter(ajaxURL, viewMode, params)
48{
49	this.ajaxURL = ajaxURL;
50	this.form = null;
51	this.timer = null;
52	this.cacheKey = '';
53	this.cache = [];
54	this.viewMode = viewMode;
55	if (params && params.SEF_SET_FILTER_URL)
56	{
57		this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL);
58		this.sef = true;
59	}
60	if (params && params.SEF_DEL_FILTER_URL)
61	{
62		this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL);
63	}
64}
65
66JCSmartFilter.prototype.keyup = function(input)
67{
68	if(!!this.timer)
69	{
70		clearTimeout(this.timer);
71	}
72	if(!$(input).hasClass('disabled')){
73		this.timer = setTimeout(BX.delegate(function(){
74			this.reload(input);
75		}, this), 500);
76	}
77};
78
79JCSmartFilter.prototype.click = function(checkbox)
80{
81	if(!!this.timer)
82	{
83		clearTimeout(this.timer);
84	}
85	this.timer = setTimeout(BX.delegate(function(){
86		this.reload(checkbox);
87	}, this), 500);
88};
89
90JCSmartFilter.prototype.reload = function(input)
91{
92	if (this.cacheKey !== '')
93	{
94		//Postprone backend query
95		if(!!this.timer)
96		{
97			clearTimeout(this.timer);
98		}
99		this.timer = setTimeout(BX.delegate(function(){
100			this.reload(input);
101		}, this), 1000);
102		return;
103	}
104	this.cacheKey = '|';
105
106	var isSelecBox  = false;
107	isSelecBox = $(input).closest('.bx_filter_select_container').length;
108
109	this.position_input = 0;
110
111	this.label_input = $('label[data-role=label_'+$(input).attr('id').replace("all_", "")+']');
112	if(isSelecBox)
113	{
114		this.label_input = $(input).closest('.bx_filter_select_container');
115	}
116	if(this.label_input.length)
117	{
118		this.position_input = this.label_input.offset().top - this.label_input.height() / 2;
119		if(this.label_input.hasClass('nab')){
120			this.position_input += 7;
121		}
122		if(isSelecBox)
123		{
124			this.position_input += 10;
125		}
126	}
127
128	this.position = BX.pos(input, true);
129	this.form = BX.findParent(input, {'tag':'form'});
130	if (this.form)
131	{
132		var values = [];
133		values[0] = {name: 'ajax', value: 'y'};
134		this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true));
135
136		for (var i = 0; i < values.length; i++)
137			this.cacheKey += values[i].name + ':' + values[i].value + '|';
138
139		if (this.cache[this.cacheKey])
140		{
141			this.curFilterinput = input;
142			this.postHandler(this.cache[this.cacheKey], true);
143		}
144		else
145		{
146			if (this.sef)
147			{
148				var set_filter = BX('set_filter');
149				set_filter.disabled = true;
150			}
151
152			this.curFilterinput = input;
153			BX.ajax.loadJSON(
154				this.ajaxURL,
155				this.values2post(values),
156				BX.delegate(this.postHandler, this)
157			);
158		}
159	}
160};
161
162JCSmartFilter.prototype.updateItem = function (PID, arItem)
163{
164	if (arItem.PROPERTY_TYPE === 'N' || arItem.PRICE)
165	{
166		var trackBar = window['trackBar' + PID];
167		if (!trackBar && arItem.ENCODED_ID)
168			trackBar = window['trackBar' + arItem.ENCODED_ID];
169
170		if (trackBar && arItem.VALUES)
171		{
172			if (arItem.VALUES.MIN)
173			{
174				if (arItem.VALUES.MIN.FILTERED_VALUE)
175					trackBar.setMinFilteredValue(arItem.VALUES.MIN.FILTERED_VALUE);
176				else
177					trackBar.setMinFilteredValue(arItem.VALUES.MIN.VALUE);
178			}
179
180			if (arItem.VALUES.MAX)
181			{
182				if (arItem.VALUES.MAX.FILTERED_VALUE)
183					trackBar.setMaxFilteredValue(arItem.VALUES.MAX.FILTERED_VALUE);
184				else
185					trackBar.setMaxFilteredValue(arItem.VALUES.MAX.VALUE);
186			}
187		}
188	}
189	else if (arItem.VALUES)
190	{
191		for (var i in arItem.VALUES)
192		{
193			if (arItem.VALUES.hasOwnProperty(i))
194			{
195				var value = arItem.VALUES[i];
196				var control = BX(value.CONTROL_ID);
197
198				if (!!control)
199				{
200					var label = document.querySelector('[data-role="label_'+value.CONTROL_ID+'"]');
201						input = document.querySelector('[id="'+value.CONTROL_ID+'"]');
202					if (value.DISABLED)
203					{
204						if (label){
205							BX.addClass(label, 'disabled');
206							if(input){
207								input.setAttribute('disabled','disabled');
208								BX.addClass(input, 'disabled');
209							}
210						}else{
211							BX.addClass(control.parentNode, 'disabled');
212						}
213
214
215					}
216					else
217					{
218						if (label){
219							BX.removeClass(label, 'disabled');
220							if(input){
221								input.removeAttribute('disabled');
222								BX.removeClass(input, 'disabled');
223							}
224						}else
225							BX.removeClass(control.parentNode, 'disabled');
226					}
227
228					if (value.hasOwnProperty('ELEMENT_COUNT'))
229					{
230						label = document.querySelector('[data-role="count_'+value.CONTROL_ID+'"]');
231						if (label)
232							label.innerHTML = value.ELEMENT_COUNT;
233					}
234				}
235			}
236		}
237	}
238};
239
240JCSmartFilter.prototype.postHandler = function (result, fromCache)
241{
242	var hrefFILTER, url, curProp;
243	var modef = BX('modef');
244	var modef_mobile = BX('modef_mobile');
245	var modef_num = BX('modef_num');
246	var modef_num_mobile = BX('modef_num_mobile');
247
248	if (!!result && !!result.ITEMS)
249	{
250		for(var PID in result.ITEMS)
251		{
252			if (result.ITEMS.hasOwnProperty(PID))
253			{
254				this.updateItem(PID, result.ITEMS[PID]);
255			}
256		}
257
258		if (!!modef && !!modef_num)
259		{
260			if(this.position_input)
261				$('#modef').css({'top':this.position_input - $(".smartfilter").offset().top})
262			else
263				$('#modef').css({'top':'auto'})
264
265			modef_num.innerHTML = result.ELEMENT_COUNT;
266			modef_num_mobile.innerHTML = result.ELEMENT_COUNT;
267			hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true);
268			hrefFILTER_mobile = BX.findChildren(modef_mobile, {tag: 'A'}, true);
269
270			if (result.FILTER_URL && hrefFILTER)
271			{
272				hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/'));
273				hrefFILTER_mobile[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/'));
274			}
275
276			if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID)
277			{
278				BX.unbindAll(hrefFILTER[0]);
279				BX.unbindAll(hrefFILTER_mobile[0]);
280				BX.bind(hrefFILTER[0], 'click', function(e)
281				{
282					url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
283					BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
284					return BX.PreventDefault(e);
285				});
286			}
287
288			if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID)
289			{
290				url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
291				BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
292			}
293			else
294			{
295				if (modef.style.display === 'none')
296				{
297					modef.style.display = 'inline-block';
298					modef_mobile.style.display = 'inline-block';
299				}
300				if (this.viewMode == "vertical")
301			{
302					curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class':'bx_filter_parameters_box'}), {'class':'bx_filter_container_modef'}, true, false);
303					curProp.appendChild(modef);
304				}
305
306				if (result.SEF_SET_FILTER_URL)
307				{
308					this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL);
309				}
310			}
311		}
312	}
313
314	if (this.sef)
315	{
316		var set_filter = BX('set_filter');
317		set_filter.disabled = false;
318	}
319
320	if (!fromCache && this.cacheKey !== '')
321	{
322		this.cache[this.cacheKey] = result;
323	}
324	this.cacheKey = '';
325};
326
327JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url)
328{
329	var button = BX(buttonId);
330	if (button)
331	{
332		var proxy = function(j, func)
333		{
334			return function()
335			{
336				return func(j);
337			}
338		};
339
340		if (button.type == 'submit')
341			button.type = 'button';
342
343		BX.bind(button, 'click', proxy(url, function(url)
344		{
345			window.location.href = url;
346			return false;
347		}));
348	}
349};
350
351JCSmartFilter.prototype.gatherInputsValues = function (values, elements)
352{
353	if(elements)
354	{
355		for(var i = 0; i < elements.length; i++)
356		{
357			var el = elements[i];
358			if (el.disabled || !el.type)
359				continue;
360
361			switch(el.type.toLowerCase())
362			{
363				case 'text':
364				case 'textarea':
365				case 'password':
366				case 'hidden':
367				case 'select-one':
368					if(el.value.length)
369						values[values.length] = {name : el.name, value : el.value};
370					break;
371				case 'radio':
372				case 'checkbox':
373					if(el.checked)
374						values[values.length] = {name : el.name, value : el.value};
375					break;
376				case 'select-multiple':
377					for (var j = 0; j < el.options.length; j++)
378					{
379						if (el.options[j].selected)
380							values[values.length] = {name : el.name, value : el.options[j].value};
381					}
382					break;
383				default:
384					break;
385			}
386		}
387	}
388};
389
390JCSmartFilter.prototype.values2post = function (values)
391{
392	var post = [];
393	var current = post;
394	var i = 0;
395
396	while(i < values.length)
397	{
398		var p = values[i].name.indexOf('[');
399		if(p == -1)
400		{
401			current[values[i].name] = values[i].value;
402			current = post;
403			i++;
404		}
405		else
406		{
407			var name = values[i].name.substring(0, p);
408			var rest = values[i].name.substring(p+1);
409			if(!current[name])
410				current[name] = [];
411
412			var pp = rest.indexOf(']');
413			if(pp == -1)
414			{
415				//Error - not balanced brackets
416				current = post;
417				i++;
418			}
419			else if(pp == 0)
420			{
421				//No index specified - so take the next integer
422				current = current[name];
423				values[i].name = '' + current.length;
424			}
425			else
426			{
427				//Now index name becomes and name and we go deeper into the array
428				current = current[name];
429				values[i].name = rest.substring(0, pp) + rest.substring(pp+1);
430			}
431		}
432	}
433	return post;
434};
435
436JCSmartFilter.prototype.hideFilterProps = function(element)
437{
438	var obj = element.parentNode,
439		filterBlock = obj.querySelector("[data-role='bx_filter_block']"),
440		propAngle = obj.querySelector("[data-role='prop_angle']");
441
442	if(BX.hasClass(obj, "bx-active"))
443	{
444		new BX.easing({
445			duration : 300,
446			start : { opacity: 1,  height: filterBlock.offsetHeight },
447			finish : { opacity: 0, height:0 },
448			transition : BX.easing.transitions.quart,
449			step : function(state){
450				filterBlock.style.opacity = state.opacity;
451				filterBlock.style.height = state.height + "px";
452			},
453			complete : function() {
454				filterBlock.setAttribute("style", "");
455				BX.removeClass(obj, "bx-active");
456			}
457		}).animate();
458
459		BX.addClass(propAngle, "fa-angle-down");
460		BX.removeClass(propAngle, "fa-angle-up");
461	}
462	else
463	{
464		filterBlock.style.display = "block";
465		filterBlock.style.opacity = 0;
466		filterBlock.style.height = "auto";
467
468		var obj_children_height = filterBlock.offsetHeight;
469		filterBlock.style.height = 0;
470
471		new BX.easing({
472			duration : 300,
473			start : { opacity: 0,  height: 0 },
474			finish : { opacity: 1, height: obj_children_height },
475			transition : BX.easing.transitions.quart,
476			step : function(state){
477				filterBlock.style.opacity = state.opacity;
478				filterBlock.style.height = state.height + "px";
479			},
480			complete : function() {
481			}
482		}).animate();
483
484		BX.addClass(obj, "bx-active");
485		BX.removeClass(propAngle, "fa-angle-down");
486		BX.addClass(propAngle, "fa-angle-up");
487	}
488};
489
490JCSmartFilter.prototype.showDropDownPopup = function(element, popupId)
491{
492	var contentNode = element.querySelector('[data-role="dropdownContent"]'),
493		offset=$(element).offset();
494	BX.PopupWindowManager.create("smartFilterDropDown"+popupId, element, {
495		autoHide: true,
496		offsetLeft: 0,
497		offsetTop: 0,
498		overlay : false,
499		draggable: {restrict:true},
500		closeByEsc: true,
501		content: contentNode
502	}).show();
503	$("#smartFilterDropDown"+popupId).css({'top':offset.top+30, 'left':offset.left});
504};
505
506JCSmartFilter.prototype.selectDropDownItem = function(element, controlId)
507{
508	if(!BX.hasClass(element,'disabled')){
509		this.keyup(BX(controlId));
510
511		var wrapContainer = BX.findParent(BX(controlId), {className:"bx_filter_select_container"}, false);
512
513		var currentOption = wrapContainer.querySelector('[data-role="currentOption"]');
514
515		currentOption.innerHTML = element.innerHTML;
516		$(element).closest('.bx_filter_select_popup').find('label').removeClass('selected');
517		BX.addClass(element, "selected");
518		BX.PopupWindowManager.getCurrentPopup().close();
519	}
520};
521
522BX.namespace("BX.Iblock.SmartFilter");
523BX.Iblock.SmartFilter = (function()
524{
525	var SmartFilter = function(arParams)
526	{
527		if (typeof arParams === 'object')
528		{
529			this.leftSlider = BX(arParams.leftSlider);
530			this.rightSlider = BX(arParams.rightSlider);
531			this.tracker = BX(arParams.tracker);
532			this.trackerWrap = BX(arParams.trackerWrap);
533
534			this.minInput = BX(arParams.minInputId);
535			this.maxInput = BX(arParams.maxInputId);
536
537			this.minPrice = parseFloat(arParams.minPrice);
538			this.maxPrice = parseFloat(arParams.maxPrice);
539
540			this.curMinPrice = parseFloat(arParams.curMinPrice);
541			this.curMaxPrice = parseFloat(arParams.curMaxPrice);
542
543			this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice);
544			this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice);
545
546			this.precision = arParams.precision || 0;
547
548			this.priceDiff = this.maxPrice - this.minPrice;
549
550			this.leftPercent = arParams.leftPercent ? parseFloat(arParams.leftPercent) : 0;
551			this.rightPercent = arParams.rightPercent ? parseFloat(arParams.rightPercent) : 0;
552
553			this.fltMinPercent = 0;
554			this.fltMaxPercent = 0;
555
556			this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray
557			this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue
558			this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue
559
560			this.isTouch = false;
561
562			this.init();
563
564			if ('ontouchstart' in document.documentElement || 'ontouchstart' in window)
565			{
566				this.isTouch = true;
567
568				BX.bind(this.leftSlider, "touchstart", BX.proxy(function(event){
569					this.onMoveLeftSlider(event)
570				}, this));
571
572				BX.bind(this.rightSlider, "touchstart", BX.proxy(function(event){
573					this.onMoveRightSlider(event)
574				}, this));
575
576				BX.bind(this.colorAvailableActive, "touchstart", BX.proxy(function(event){
577					this.onChangeLeftSlider(event);
578				}, this));
579
580				BX.bind(this.colorUnavailableActive, "touchstart", BX.proxy(function(event){
581					this.onChangeLeftSlider(event);
582				}, this));
583
584				BX.bind(this.colorAvailableInactive, "touchstart", BX.proxy(function(event){
585					this.onChangeLeftSlider(event);
586				}, this));
587			}
588			else
589			{
590				BX.bind(this.leftSlider, "mousedown", BX.proxy(function(event){
591					this.onMoveLeftSlider(event)
592				}, this));
593
594				BX.bind(this.rightSlider, "mousedown", BX.proxy(function(event){
595					this.onMoveRightSlider(event)
596				}, this));
597
598				BX.bind(this.colorAvailableActive, "mousedown", BX.proxy(function(event){
599					this.onChangeLeftSlider(event);
600				}, this));
601
602				BX.bind(this.colorUnavailableActive, "mousedown", BX.proxy(function(event){
603					this.onChangeLeftSlider(event);
604				}, this));
605
606				BX.bind(this.colorAvailableInactive, "mousedown", BX.proxy(function(event){
607					this.onChangeLeftSlider(event);
608				}, this));
609			}
610
611			BX.bind(this.minInput, "keyup", BX.proxy(function(event){
612				this.onInputChange();
613			}, this));
614
615			BX.bind(this.maxInput, "keyup", BX.proxy(function(event){
616				this.onInputChange();
617			}, this));
618		}
619	};
620
621	SmartFilter.prototype.init = function()
622	{
623		var priceDiff;
624
625		if (this.curMinPrice > this.minPrice)
626		{
627			priceDiff = this.curMinPrice - this.minPrice;
628			this.leftPercent = (priceDiff*100)/this.priceDiff;
629
630			this.leftSlider.style.left = this.leftPercent + "%";
631			this.colorUnavailableActive.style.left = this.leftPercent + "%";
632		}
633
634		this.setMinFilteredValue(this.fltMinPrice);
635
636		if (this.curMaxPrice < this.maxPrice)
637		{
638			priceDiff = this.maxPrice - this.curMaxPrice;
639			this.rightPercent = (priceDiff*100)/this.priceDiff;
640
641			this.rightSlider.style.right = this.rightPercent + "%";
642			this.colorUnavailableActive.style.right = this.rightPercent + "%";
643		}
644
645		this.setMaxFilteredValue(this.fltMaxPrice);
646	};
647
648	SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice)
649	{
650		this.fltMinPrice = parseFloat(fltMinPrice);
651		if (this.fltMinPrice >= this.minPrice)
652		{
653			var priceDiff = this.fltMinPrice - this.minPrice;
654			this.fltMinPercent = (priceDiff*100)/this.priceDiff;
655
656			if (this.leftPercent > this.fltMinPercent)
657				this.colorAvailableActive.style.left = this.leftPercent + "%";
658			else
659				this.colorAvailableActive.style.left = this.fltMinPercent + "%";
660
661			this.colorAvailableInactive.style.left = this.fltMinPercent + "%";
662		}
663		else
664		{
665			this.colorAvailableActive.style.left = "0%";
666			this.colorAvailableInactive.style.left = "0%";
667		}
668	};
669
670	SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice)
671	{
672		this.fltMaxPrice = parseFloat(fltMaxPrice);
673		if (this.fltMaxPrice <= this.maxPrice)
674		{
675			var priceDiff = this.maxPrice - this.fltMaxPrice;
676			this.fltMaxPercent = (priceDiff*100)/this.priceDiff;
677
678			if (this.rightPercent > this.fltMaxPercent)
679				this.colorAvailableActive.style.right = this.rightPercent + "%";
680			else
681				this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
682
683			this.colorAvailableInactive.style.right = this.fltMaxPercent + "%";
684		}
685		else
686		{
687			this.colorAvailableActive.style.right = "0%";
688			this.colorAvailableInactive.style.right = "0%";
689		}
690	};
691
692	SmartFilter.prototype.getXCoord = function(elem)
693	{
694		var box = elem.getBoundingClientRect();
695		var body = document.body;
696		var docElem = document.documentElement;
697
698		var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
699		var clientLeft = docElem.clientLeft || body.clientLeft || 0;
700		var left = box.left + scrollLeft - clientLeft;
701
702		return Math.round(left);
703	};
704
705	SmartFilter.prototype.getPageX = function(e)
706	{
707		e = e || window.event;
708		var pageX = null;
709
710		if (this.isTouch && e.targetTouches[0] != null)
711		{
712			pageX = e.targetTouches[0].pageX;
713		}
714		else if (e.pageX != null)
715		{
716			pageX = e.pageX;
717		}
718		else if (e.clientX != null)
719		{
720			var html = document.documentElement;
721			var body = document.body;
722
723			pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0);
724			pageX -= html.clientLeft || 0;
725		}
726
727		return pageX;
728	};
729
730	SmartFilter.prototype.recountMinPrice = function()
731	{
732		var newMinPrice = (this.priceDiff*this.leftPercent)/100;
733		newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision);
734
735		if (newMinPrice != this.minPrice)
736			this.minInput.value = newMinPrice;
737		else
738			this.minInput.value = "";
739		smartFilter.keyup(this.minInput);
740	};
741
742	SmartFilter.prototype.recountMaxPrice = function()
743	{
744		var newMaxPrice = (this.priceDiff*this.rightPercent)/100;
745		newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision);
746
747		if (newMaxPrice != this.maxPrice)
748			this.maxInput.value = newMaxPrice;
749		else
750			this.maxInput.value = "";
751		smartFilter.keyup(this.maxInput);
752	};
753
754	SmartFilter.prototype.onInputChange = function ()
755	{
756		var priceDiff;
757		if (this.minInput.value)
758		{
759			var leftInputValue = this.minInput.value;
760			if (leftInputValue < this.minPrice)
761				leftInputValue = this.minPrice;
762
763			if (leftInputValue > this.maxPrice)
764				leftInputValue = this.maxPrice;
765
766			priceDiff = leftInputValue - this.minPrice;
767			this.leftPercent = (priceDiff*100)/this.priceDiff;
768
769			this.makeLeftSliderMove(false);
770		}
771
772		if (this.maxInput.value)
773		{
774			var rightInputValue = this.maxInput.value;
775			if (rightInputValue < this.minPrice)
776				rightInputValue = this.minPrice;
777
778			if (rightInputValue > this.maxPrice)
779				rightInputValue = this.maxPrice;
780
781			priceDiff = this.maxPrice - rightInputValue;
782			this.rightPercent = (priceDiff*100)/this.priceDiff;
783
784			this.makeRightSliderMove(false);
785		}
786	};
787
788	SmartFilter.prototype.makeLeftSliderMove = function(recountPrice)
789	{
790		recountPrice = (recountPrice !== false);
791
792		this.leftSlider.style.left = this.leftPercent + "%";
793		this.colorUnavailableActive.style.left = this.leftPercent + "%";
794
795		var areBothSlidersMoving = false;
796		if (this.leftPercent + this.rightPercent >= 100)
797		{
798			areBothSlidersMoving = true;
799			this.rightPercent = 100 - this.leftPercent;
800			this.rightSlider.style.right = this.rightPercent + "%";
801			this.colorUnavailableActive.style.right = this.rightPercent + "%";
802		}
803
804		if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100-this.fltMaxPercent))
805		{
806			this.colorAvailableActive.style.left = this.leftPercent + "%";
807			if (areBothSlidersMoving)
808			{
809				this.colorAvailableActive.style.right = 100 - this.leftPercent + "%";
810			}
811		}
812		else if(this.leftPercent <= this.fltMinPercent)
813		{
814			this.colorAvailableActive.style.left = this.fltMinPercent + "%";
815			if (areBothSlidersMoving)
816			{
817				this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%";
818			}
819		}
820		else if(this.leftPercent >= this.fltMaxPercent)
821		{
822			this.colorAvailableActive.style.left = 100-this.fltMaxPercent + "%";
823			if (areBothSlidersMoving)
824			{
825				this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
826			}
827		}
828
829		if (recountPrice)
830		{
831			this.recountMinPrice();
832			if (areBothSlidersMoving)
833				this.recountMaxPrice();
834		}
835	};
836
837	SmartFilter.prototype.countNewLeft = function(event)
838	{
839		var pageX = this.getPageX(event);
840
841		var trackerXCoord = this.getXCoord(this.trackerWrap);
842		var rightEdge = this.trackerWrap.offsetWidth;
843
844		var newLeft = pageX - trackerXCoord;
845
846		if (newLeft < 0)
847			newLeft = 0;
848		else if (newLeft > rightEdge)
849			newLeft = rightEdge;
850
851		return newLeft;
852	};
853
854	SmartFilter.prototype.onMoveLeftSlider = function(e)
855	{
856		if (!this.isTouch)
857		{
858			this.leftSlider.ondragstart = function() {
859				return false;
860			};
861		}
862
863		if (!this.isTouch)
864		{
865			document.onmousemove = BX.proxy(function(event) {
866				this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
867				this.makeLeftSliderMove();
868			}, this);
869
870			document.onmouseup = function() {
871				document.onmousemove = document.onmouseup = null;
872			};
873		}
874		else
875		{
876			var onMoveFunction = BX.proxy(function(event) {
877				this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
878				this.makeLeftSliderMove();
879			}, this);
880
881			var onEndFunction = BX.proxy(function(event) {
882				window.removeEventListener('touchmove', onMoveFunction, false);
883				window.removeEventListener('touchend', onEndFunction, false);
884				onMoveFunction = onEndFunction = null;
885			}, this);
886
887			window.addEventListener('touchmove', onMoveFunction, false);
888			window.addEventListener('touchend', onEndFunction, false);
889
890			/*document.ontouchmove = BX.proxy(function(event) {
891				this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
892				this.makeLeftSliderMove();
893			}, this);
894
895			document.ontouchend = function() {
896				document.ontouchmove = document.touchend = null;
897			};*/
898		}
899
900		return false;
901	};
902
903	SmartFilter.prototype.makeRightSliderMove = function(recountPrice)
904	{
905		recountPrice = (recountPrice !== false);
906
907		this.rightSlider.style.right = this.rightPercent + "%";
908		this.colorUnavailableActive.style.right = this.rightPercent + "%";
909
910		var areBothSlidersMoving = false;
911		if (this.leftPercent + this.rightPercent >= 100)
912		{
913			areBothSlidersMoving = true;
914			this.leftPercent = 100 - this.rightPercent;
915			this.leftSlider.style.left = this.leftPercent + "%";
916			this.colorUnavailableActive.style.left = this.leftPercent + "%";
917		}
918
919		if ((100-this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent)
920		{
921			this.colorAvailableActive.style.right = this.rightPercent + "%";
922			if (areBothSlidersMoving)
923			{
924				this.colorAvailableActive.style.left = 100 - this.rightPercent + "%";
925			}
926		}
927		else if(this.rightPercent <= this.fltMaxPercent)
928		{
929			this.colorAvailableActive.style.right = this.fltMaxPercent + "%";
930			if (areBothSlidersMoving)
931			{
932				this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%";
933			}
934		}
935		else if((100-this.rightPercent) <= this.fltMinPercent)
936		{
937			this.colorAvailableActive.style.right = 100-this.fltMinPercent + "%";
938			if (areBothSlidersMoving)
939			{
940				this.colorAvailableActive.style.left = this.fltMinPercent + "%";
941			}
942		}
943
944		if (recountPrice)
945		{
946			this.recountMaxPrice();
947			if (areBothSlidersMoving)
948				this.recountMinPrice();
949		}
950	};
951
952	SmartFilter.prototype.onMoveRightSlider = function(e)
953	{
954		if (!this.isTouch)
955		{
956			this.rightSlider.ondragstart = function() {
957				return false;
958			};
959		}
960
961		if (!this.isTouch)
962		{
963			document.onmousemove = BX.proxy(function(event) {
964				this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth));
965				this.makeRightSliderMove();
966			}, this);
967
968			document.onmouseup = function() {
969				document.onmousemove = document.onmouseup = null;
970			};
971		}
972		else
973		{
974			var onMoveFunction = BX.proxy(function(event) {
975				this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth));
976				this.makeRightSliderMove();
977			}, this);
978
979			var onEndFunction = BX.proxy(function(event) {
980				window.removeEventListener('touchmove', onMoveFunction, false);
981				window.removeEventListener('touchend', onEndFunction, false);
982				onMoveFunction = onEndFunction = null;
983			}, this);
984
985			window.addEventListener('touchmove', onMoveFunction, false);
986			window.addEventListener('touchend', onEndFunction, false);
987
988			/*document.ontouchmove = BX.proxy(function(event) {
989				this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth));
990				this.makeRightSliderMove();
991			}, this);
992
993			document.ontouchend = function() {
994				document.ontouchmove = document.ontouchend = null;
995			};*/
996		}
997
998		return false;
999	};
1000
1001	SmartFilter.prototype.onChangeLeftSlider = function(e)
1002	{
1003		if (!this.isTouch)
1004		{
1005			this.leftSlider.ondragstart = function() {
1006				//return false;
1007			};
1008		}
1009		if (!this.isTouch)
1010		{
1011			// document.onmousedown = BX.proxy(function(event) {
1012				var percent=((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
1013				if($(event.target).is(".bx_ui_slider_handle") || !$(event.target).is("[class^=bx_ui_slider]"))
1014					return;
1015				if(percent<50){
1016					this.leftPercent = percent+1;
1017					this.makeLeftSliderMove();
1018				}else{
1019					this.rightPercent = 100-percent;
1020					this.makeRightSliderMove();
1021				}
1022			// }, this);
1023
1024			document.onmouseup = function() {
1025				document.onmousemove = document.onmouseup = null;
1026			};
1027		}
1028		else
1029		{
1030			var percent=((this.countNewLeft(e)*100)/this.trackerWrap.offsetWidth);
1031			if($(e.target).is(".bx_ui_slider_handle"))
1032				return;
1033			if(percent<50){
1034				this.leftPercent = percent;
1035				this.makeLeftSliderMove();
1036			}else{
1037				this.rightPercent = 100-percent;
1038				this.makeRightSliderMove();
1039			}
1040
1041			/*document.ontouchend = BX.proxy(function(event) {
1042				var percent=((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth);
1043				if($(event.target).is(".bx_ui_slider_handle"))
1044					return;
1045				if(percent<50){
1046					this.leftPercent = percent;
1047					this.makeLeftSliderMove();
1048				}else{
1049					this.rightPercent = 100-percent;
1050					this.makeRightSliderMove();
1051				}
1052			}, this);
1053
1054			document.ontouchend = function() {
1055				document.ontouchmove = document.touchend = null;
1056			};*/
1057		}
1058
1059		return false;
1060	};
1061
1062	return SmartFilter;
1063})();

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.