1function JCSmartFilter(ajaxURL, viewMode, params, words) { 2 this.params = params; 3 this.ajaxURL = ajaxURL; 4 this.form = null; 5 this.timer = null; 6 this.cacheKey = ''; 7 this.cache = []; 8 this.popups = []; 9 this.viewMode = viewMode; 10 this.words = words; 11 if (params && params.SEF_SET_FILTER_URL) { 12 this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL); 13 this.sef = true; 14 } 15 if (params && params.SEF_DEL_FILTER_URL) { 16 17 this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL); 18 } 19} 20 21JCSmartFilter.prototype.keyup = function (input) { 22 23 if (!!this.timer) { 24 clearTimeout(this.timer); 25 } 26 27 this.timer = setTimeout(BX.delegate(function () { 28 this.reload(input); 29 }, this), 500); 30 31}; 32 33JCSmartFilter.prototype.click = function (checkbox) { 34 35 if (!!this.timer) { 36 clearTimeout(this.timer); 37 } 38 39 this.timer = setTimeout(BX.delegate(function () { 40 this.reload(checkbox); 41 42 }, this), 500); 43}; 44 45JCSmartFilter.prototype.reload = function (input) { 46 47 $('.preloader').addClass('preloader--show'); 48 if (this.cacheKey !== '') { 49 //Postprone backend query 50 if (!!this.timer) { 51 clearTimeout(this.timer); 52 } 53 this.timer = setTimeout(BX.delegate(function () { 54 this.reload(input); 55 }, this), 1000); 56 return; 57 } 58 this.cacheKey = '|'; 59 60 this.position = BX.pos(input, true); 61 this.form = BX.findParent(input, {'tag': 'form'}); 62 63 if (this.form) { 64 var values = []; 65 66 values[0] = {name: 'ajax', value: 'y'}; 67 this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true)); 68 for (var i = 0; i < values.length; i++) 69 this.cacheKey += values[i].name + ':' + values[i].value + '|'; 70 71 if (this.cache[this.cacheKey]) { 72 this.curFilterinput = input; 73 74 75 this.postHandler(this.cache[this.cacheKey], true); 76 } else { 77 78 if (this.sef) { 79 var set_filter = BX('set_filter'); 80 set_filter.disabled = true; 81 } 82 83 this.curFilterinput = input; 84 85 86 BX.ajax.loadJSON( 87 this.ajaxURL, 88 this.values2post(values), 89 BX.delegate(this.postHandler, this) 90 ); 91 } 92 } 93}; 94 95JCSmartFilter.prototype.updateItem = function (PID, arItem) { 96 97 if (arItem.PROPERTY_TYPE === 'A') { 98 let rangeSlider = $('#' + arItem.CONTROL_ID); 99 let rangeSliderData = rangeSlider.data('ionRangeSlider'); 100 101 //console.log(rangeSlider); 102 103 if (rangeSlider) { 104 let rangeMin = arItem.VALUES.MIN.HTML_VALUE ? arItem.VALUES.MIN.HTML_VALUE : arItem.VALUES.MIN.VALUE; 105 let rangeMax = arItem.VALUES.MAX.HTML_VALUE ? arItem.VALUES.MAX.HTML_VALUE : arItem.VALUES.MAX.VALUE; 106 let arUpdate = { 107 'from': rangeMin, 108 'to': rangeMax, 109 }; 110 111 rangeSlider.data('from-available', arItem.VALUES.MIN.FILTERED_VALUE); 112 rangeSlider.data('to-available', arItem.VALUES.MAX.FILTERED_VALUE); 113 rangeSliderData.update(arUpdate); 114 115 /* let rangeSliderMinInput = $('#' + arItem.VALUES.MIN.CONTROL_ID); 116 let rangeSliderMaxInput = $('#' + arItem.VALUES.MAX.CONTROL_ID); 117 118 if (rangeSliderMinInput) { 119 let rangeSliderMinInputValue = (rangeSliderMinInput.val().replace(/\s+/g, '')); 120 rangeSliderMinInput.val((rangeSliderMinInputValue > rangeMin) ? rangeSliderMinInputValue : rangeMin); 121 } 122 if (rangeSliderMaxInput) { 123 let rangeSliderMaxInputValue = (rangeSliderMaxInput.val().replace(/\s+/g, '')); 124 rangeSliderMaxInput.val((rangeSliderMaxInputValue > rangeMax) ? rangeSliderMaxInputValue : rangeMax); 125 } */ 126 } 127 } else if (arItem.VALUES) { 128 for (var i in arItem.VALUES) { 129 if (arItem.VALUES.hasOwnProperty(i)) { 130 var value = arItem.VALUES[i]; 131 var control = BX(value.CONTROL_ID); 132 133 if (!!control) { 134 var label = document.querySelector('[data-role="label_' + value.CONTROL_ID + '"]'); 135 136 if (value.DISABLED) { 137 if (label) { 138 BX.addClass(label, 'disabled'); 139 } else { 140 if (control.tagName === 'OPTION') { 141 BX.adjust(control, {props: {disabled: true}}); //disable Ð´Ð»Ñ ÑлеменÑов ÑелекÑа 142 } else { 143 BX.addClass(control.parentNode, 'disabled'); 144 } 145 146 } 147 // BX.adjust(control, {props: {disabled: true}}); 148 } else { 149 150 if (label) { 151 BX.removeClass(label, 'disabled'); 152 } else { 153 if (control.tagName === 'OPTION') { 154 BX.adjust(control, {props: {disabled: false}}); //Ñнимаем disable Ñ ÑлеменÑов ÑелекÑа 155 } else { 156 BX.removeClass(control.parentNode, 'disabled'); 157 } 158 } 159 // BX.adjust(control, {props: {disabled: false}}); 160 } 161 162 if (value.hasOwnProperty('ELEMENT_COUNT')) { 163 label = document.querySelector('[data-role="count_' + value.CONTROL_ID + '"]'); 164 if (label) 165 label.innerHTML = value.ELEMENT_COUNT; 166 } 167 } 168 } 169 } 170 } 171}; 172 173JCSmartFilter.prototype.postHandler = function (result, fromCache) { 174 var hrefFILTER, url, curProp; 175 var modef = BX('modef'); 176 var modef_num = BX('modef_num'); 177 var modef_button = BX('modef_button'); 178 if (!!result && !!result.ITEMS) { 179 180 for (var popupId in this.popups) { 181 if (this.popups.hasOwnProperty(popupId)) { 182 this.popups[popupId].destroy(); 183 } 184 } 185 this.popups = []; 186 187 for (var PID in result.ITEMS) { 188 if (result.ITEMS.hasOwnProperty(PID)) { 189 this.updateItem(PID, result.ITEMS[PID]); 190 } 191 } 192 193 if (!!modef && !!modef_num) { 194 let count = result.ELEMENT_COUNT + ' ' + wordForm(result.ELEMENT_COUNT, this.words); 195 modef_num.innerHTML = count; 196 setCountPlacesMobile(count); 197 198 199 hrefFILTER = modef; 200 201 // УÑÑановка ÑÑÑлки Ñ Ð¿Ð°ÑамеÑÑами из ÑилÑÑÑа на ÐºÐ½Ð¾Ð¿ÐºÑ "показаÑÑ" 202 if (result.FILTER_URL && modef_button) { 203 // modef_button.href = '/kvartiry' + BX.util.htmlspecialcharsback(result.FILTER_URL); 204 modef_button.href = BX.util.htmlspecialcharsback(result.FILTER_URL); 205 } 206 207 // УÑÑановка ÑÑÑлки Ñ ÑилÑÑÑом 208 history.pushState(null, '', BX.util.htmlspecialcharsback(result.FILTER_URL)); 209 210 // Ðиндинг на ÐºÐ½Ð¾Ð¿ÐºÑ "показаÑÑ" пÑи вклÑÑенном Ñежиме AJAX, но без мгновенного Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ 211 // каÑалога пÑи иÑполÑзовании Ñмного ÑилÑÑÑа 212 if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID) { 213 BX.unbindAll(hrefFILTER[0]); 214 BX.bind(hrefFILTER[0], 'click', function (e) { 215 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 216 // Ðбновление ÑилÑÑÑа или комплекÑного компоненÑа каÑалога 217 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 218 // Ðбновление ÑпиÑка ÑлеменÑов пÑи ÑазделÑном иÑполÑзовании компоненÑов 219 if (this.params.COMPONENT_CATALOG_CONTAINER_ID) { 220 let componentCatalogContainerID = this.params.COMPONENT_CATALOG_CONTAINER_ID; 221 $.get( 222 BX.util.htmlspecialcharsback(result.FILTER_URL), 223 function (data) { 224 $('#' + componentCatalogContainerID).html($(data).find('#' + componentCatalogContainerID).html()); 225 /* let preloader = $('[role="preloader"]'); 226 preloader.css({'opacity':'0', 'z-index':'-1'});*/ 227 } 228 ); 229 } 230 return BX.PreventDefault(e); 231 }); 232 } 233 234 // Ðгновенное обновление каÑалога пÑи изменении паÑамеÑÑов 235 // Ñмного ÑилÑÑÑа 236 if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID) { 237 238 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 239 // Ðбновление ÑилÑÑÑа или комплекÑного компоненÑа каÑалога 240 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 241 } else { 242 if (modef.style.opacity === '0') { 243 modef.style.opacity = '0'; 244 } 245 246 if (this.viewMode == "VERTICAL") { 247 curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class': 'bx-filter-parameters-box'}), {'class': 'bx-filter-container-modef'}, true, false); 248 curProp.appendChild(modef); 249 } 250 251 if (result.SEF_SET_FILTER_URL) { 252 this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL); 253 } 254 } 255 256 // Ðбновление ÑпиÑка ÑлеменÑов пÑи ÑазделÑном иÑполÑзовании компоненÑов 257 if (result.INSTANT_RELOAD && this.params.COMPONENT_CATALOG_CONTAINER_ID) { 258 let componentCatalogContainerID = this.params.COMPONENT_CATALOG_CONTAINER_ID; 259 $.get( 260 BX.util.htmlspecialcharsback(result.FILTER_URL), 261 function (data) { 262 $('#' + componentCatalogContainerID).html($(data).find('#' + componentCatalogContainerID).html()); 263 $('.preloader').removeClass('preloader--show'); 264 } 265 ); 266 } 267 } 268 } 269 270 if (this.sef) { 271 var set_filter = BX('set_filter'); 272 set_filter.disabled = false;
273 } 274 275 if (!fromCache && this.cacheKey !== '') { 276 this.cache[this.cacheKey] = result; 277 } 278 this.cacheKey = ''; 279 280 281}; 282$(window).keydown(function(event){ 283 if(event.keyCode == 13) { 284 event.preventDefault(); 285 smartFilter.keyup(event.target); 286 } 287}); 288JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url) { 289 290 var button = BX(buttonId); 291 if (button) { 292 var proxy = function (j, func) { 293 return function () { 294 return func(j); 295 } 296 }; 297 298 if (button.type == 'submit') 299 button.type = 'button'; 300 301 BX.bind(button, 'click', proxy(url, function (url) { 302 303 window.location.href = url; 304 return false; 305 })); 306 } 307}; 308 309JCSmartFilter.prototype.gatherInputsValues = function (values, elements) { 310 if (elements) { 311 for (var i = 0; i < elements.length; i++) { 312 var el = elements[i]; 313 if (el.disabled || !el.type || !el.name) 314 continue; 315 316 switch (el.type.toLowerCase()) { 317 case 'number': 318 319 break; 320 case 'text': 321 case 'textarea': 322 case 'password': 323 case 'hidden': 324 case 'select-one': 325 if (el.value.length) { 326 values[values.length] = {name: el.name, value: el.value.replace(/\s+/g, '')}; 327 328 //console.log([el.value, el.value.replace(/\s+/g, '')]); 329 } 330 break; 331 case 'radio': 332 case 'checkbox': 333 if (el.checked) { 334 values[values.length] = {name: el.name, value: el.value}; 335 } 336 break; 337 case 'select-multiple': 338 339 for (var j = 0; j < el.options.length; j++) { 340 if (el.options[j].selected) { 341 values[values.length] = {name: el.options[j].id, value: el.options[j].value}; 342 } 343 } 344 break; 345 default: 346 break; 347 } 348 } 349 } 350}; 351 352JCSmartFilter.prototype.values2post = function (values) { 353 var post = []; 354 var current = post; 355 var i = 0; 356 357 while (i < values.length) { 358 var p = values[i].name.indexOf('['); 359 if (p == -1) { 360 current[values[i].name] = values[i].value; 361 current = post; 362 i++; 363 } else { 364 var name = values[i].name.substring(0, p); 365 var rest = values[i].name.substring(p + 1); 366 if (!current[name]) 367 current[name] = []; 368 369 var pp = rest.indexOf(']'); 370 if (pp == -1) { 371 //Error - not balanced brackets 372 current = post; 373 i++; 374 } else if (pp == 0) { 375 //No index specified - so take the next integer 376 current = current[name]; 377 values[i].name = '' + current.length; 378 } else { 379 //Now index name becomes and name and we go deeper into the array 380 current = current[name]; 381 values[i].name = rest.substring(0, pp) + rest.substring(pp + 1); 382 } 383 } 384 } 385 return post; 386}; 387 388JCSmartFilter.prototype.hideFilterProps = function (element) { 389 var obj = element.parentNode, 390 filterBlock = obj.querySelector("[data-role='bx_filter_block']"), 391 propAngle = obj.querySelector("[data-role='prop_angle']"); 392 393 if (BX.hasClass(obj, "bx-active")) { 394 new BX.easing({ 395 duration: 300, 396 start: {opacity: 1, height: filterBlock.offsetHeight}, 397 finish: {opacity: 0, height: 0}, 398 transition: BX.easing.transitions.quart, 399 step: function (state) { 400 filterBlock.style.opacity = state.opacity; 401 filterBlock.style.height = state.height + "px"; 402 }, 403 complete: function () { 404 filterBlock.setAttribute("style", ""); 405 BX.removeClass(obj, "bx-active"); 406 } 407 }).animate(); 408 409 BX.addClass(propAngle, "fa-angle-down"); 410 BX.removeClass(propAngle, "fa-angle-up"); 411 } else { 412 filterBlock.style.display = "block"; 413 filterBlock.style.opacity = 0; 414 filterBlock.style.height = "auto"; 415 416 var obj_children_height = filterBlock.offsetHeight; 417 filterBlock.style.height = 0; 418 419 new BX.easing({ 420 duration: 300, 421 start: {opacity: 0, height: 0}, 422 finish: {opacity: 1, height: obj_children_height}, 423 transition: BX.easing.transitions.quart, 424 step: function (state) { 425 filterBlock.style.opacity = state.opacity; 426 filterBlock.style.height = state.height + "px"; 427 }, 428 complete: function () { 429 } 430 }).animate(); 431 432 BX.addClass(obj, "bx-active"); 433 BX.removeClass(propAngle, "fa-angle-down"); 434 BX.addClass(propAngle, "fa-angle-up"); 435 } 436}; 437 438JCSmartFilter.prototype.showDropDownPopup = function (element, popupId) { 439 var contentNode = element.querySelector('[data-role="dropdownContent"]'); 440 this.popups["smartFilterDropDown" + popupId] = BX.PopupWindowManager.create("smartFilterDropDown" + popupId, element, { 441 autoHide: true, 442 offsetLeft: 0, 443 offsetTop: 3,
444 overlay: false, 445 draggable: {restrict: true}, 446 closeByEsc: true, 447 content: BX.clone(contentNode) 448 }); 449 this.popups["smartFilterDropDown" + popupId].show(); 450}; 451 452JCSmartFilter.prototype.selectDropDownItem = function (element, controlId) { 453 this.keyup(BX(controlId)); 454 455 var wrapContainer = BX.findParent(BX(controlId), {className: "bx-filter-select-container"}, false); 456 457 var currentOption = wrapContainer.querySelector('[data-role="currentOption"]'); 458 currentOption.innerHTML = element.innerHTML; 459 BX.PopupWindowManager.getCurrentPopup().close(); 460}; 461 462BX.namespace("BX.Iblock.SmartFilter"); 463BX.Iblock.SmartFilter = (function () { 464 /** @param {{ 465 leftSlider: string, 466 rightSlider: string, 467 tracker: string, 468 trackerWrap: string, 469 minInputId: string, 470 maxInputId: string, 471 minPrice: float|int|string, 472 maxPrice: float|int|string, 473 curMinPrice: float|int|string, 474 curMaxPrice: float|int|string, 475 fltMinPrice: float|int|string|null, 476 fltMaxPrice: float|int|string|null, 477 precision: int|null, 478 colorUnavailableActive: string, 479 colorAvailableActive: string, 480 colorAvailableInactive: string 481 }} arParams 482 */ 483 var SmartFilter = function (arParams) { 484 if (typeof arParams === 'object') { 485 this.leftSlider = BX(arParams.leftSlider); 486 this.rightSlider = BX(arParams.rightSlider); 487 this.tracker = BX(arParams.tracker); 488 this.trackerWrap = BX(arParams.trackerWrap); 489 490 this.minInput = BX(arParams.minInputId); 491 this.maxInput = BX(arParams.maxInputId); 492 493 this.minPrice = parseFloat(arParams.minPrice); 494 this.maxPrice = parseFloat(arParams.maxPrice); 495 496 this.curMinPrice = parseFloat(arParams.curMinPrice); 497 this.curMaxPrice = parseFloat(arParams.curMaxPrice); 498 499 this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice); 500 this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice); 501 502 this.precision = arParams.precision || 0; 503 504 this.priceDiff = this.maxPrice - this.minPrice; 505 506 this.leftPercent = 0; 507 this.rightPercent = 0; 508 509 this.fltMinPercent = 0; 510 this.fltMaxPercent = 0; 511 512 this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray 513 this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue 514 this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue 515 516 this.isTouch = false; 517 518 this.init(); 519 520 if ('ontouchstart' in document.documentElement) { 521 this.isTouch = true; 522 523 BX.bind(this.leftSlider, "touchstart", BX.proxy(function (event) { 524 this.onMoveLeftSlider(event) 525 }, this)); 526 527 BX.bind(this.rightSlider, "touchstart", BX.proxy(function (event) { 528 this.onMoveRightSlider(event) 529 }, this)); 530 } else { 531 BX.bind(this.leftSlider, "mousedown", BX.proxy(function (event) { 532 this.onMoveLeftSlider(event) 533 }, this)); 534 535 BX.bind(this.rightSlider, "mousedown", BX.proxy(function (event) { 536 this.onMoveRightSlider(event) 537 }, this)); 538 } 539 540 BX.bind(this.minInput, "keyup", BX.proxy(function (event) { 541 this.onInputChange(); 542 }, this)); 543 544 BX.bind(this.maxInput, "keyup", BX.proxy(function (event) { 545 this.onInputChange(); 546 }, this)); 547 } 548 }; 549 550 SmartFilter.prototype.init = function () { 551 var priceDiff; 552 553 if (this.curMinPrice > this.minPrice) { 554 priceDiff = this.curMinPrice - this.minPrice; 555 this.leftPercent = (priceDiff * 100) / this.priceDiff; 556 557 this.leftSlider.style.left = this.leftPercent + "%"; 558 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 559 } 560 561 this.setMinFilteredValue(this.fltMinPrice); 562 563 if (this.curMaxPrice < this.maxPrice) { 564 priceDiff = this.maxPrice - this.curMaxPrice; 565 this.rightPercent = (priceDiff * 100) / this.priceDiff; 566 567 this.rightSlider.style.right = this.rightPercent + "%"; 568 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 569 } 570 571 this.setMaxFilteredValue(this.fltMaxPrice); 572 }; 573 574 SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice) { 575 this.fltMinPrice = parseFloat(fltMinPrice); 576 if (this.fltMinPrice >= this.minPrice) { 577 var priceDiff = this.fltMinPrice - this.minPrice; 578 this.fltMinPercent = (priceDiff * 100) / this.priceDiff; 579 580 if (this.leftPercent > this.fltMinPercent) 581 this.colorAvailableActive.style.left = this.leftPercent + "%"; 582 else 583 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 584 585 this.colorAvailableInactive.style.left = this.fltMinPercent + "%"; 586 } else { 587 this.colorAvailableActive.style.left = "0%"; 588 this.colorAvailableInactive.style.left = "0%"; 589 } 590 }; 591 592 SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice) { 593 this.fltMaxPrice = parseFloat(fltMaxPrice); 594 if (this.fltMaxPrice <= this.maxPrice) { 595 var priceDiff = this.maxPrice - this.fltMaxPrice; 596 this.fltMaxPercent = (priceDiff * 100) / this.priceDiff; 597 598 if (this.rightPercent > this.fltMaxPercent) 599 this.colorAvailableActive.style.right = this.rightPercent + "%"; 600 else 601 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 602 603 this.colorAvailableInactive.style.right = this.fltMaxPercent + "%"; 604 } else { 605 this.colorAvailableActive.style.right = "0%"; 606 this.colorAvailableInactive.style.right = "0%"; 607 } 608 }; 609 610 SmartFilter.prototype.getXCoord = function (elem) { 611 var box = elem.getBoundingClientRect(); 612 var body = document.body; 613 var docElem = document.documentElement; 614 615 var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft; 616 var clientLeft = docElem.clientLeft || body.clientLeft || 0; 617 var left = box.left + scrollLeft - clientLeft; 618 619 return Math.round(left); 620 }; 621 622 SmartFilter.prototype.getPageX = function (e) { 623 e = e || window.event; 624 var pageX = null; 625 626 if (this.isTouch && event.targetTouches[0] != null) { 627 pageX = e.targetTouches[0].pageX; 628 } else if (e.pageX != null) { 629 pageX = e.pageX; 630 } else if (e.clientX != null) { 631 var html = document.documentElement; 632 var body = document.body; 633 634 pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0); 635 pageX -= html.clientLeft || 0; 636 } 637 638 return pageX; 639 }; 640 641 SmartFilter.prototype.recountMinPrice = function () { 642 var newMinPrice = (this.priceDiff * this.leftPercent) / 100; 643 newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision); 644 645 if (newMinPrice != this.minPrice) 646 this.minInput.value = newMinPrice; 647 else 648 this.minInput.value = ""; 649 /** @global JCSmartFilter smartFilter */ 650 smartFilter.keyup(this.minInput); 651 }; 652 653 SmartFilter.prototype.recountMaxPrice = function () { 654 var newMaxPrice = (this.priceDiff * this.rightPercent) / 100; 655 newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision); 656 657 if (newMaxPrice != this.maxPrice) 658 this.maxInput.value = newMaxPrice; 659 else 660 this.maxInput.value = ""; 661 /** @global JCSmartFilter smartFilter */ 662 smartFilter.keyup(this.maxInput); 663 }; 664 665 SmartFilter.prototype.onInputChange = function () { 666 var priceDiff; 667 if (this.minInput.value) { 668 var leftInputValue = this.minInput.value; 669 if (leftInputValue < this.minPrice) 670 leftInputValue = this.minPrice; 671 672 if (leftInputValue > this.maxPrice) 673 leftInputValue = this.maxPrice; 674 675 priceDiff = leftInputValue - this.minPrice; 676 this.leftPercent = (priceDiff * 100) / this.priceDiff; 677 678 this.makeLeftSliderMove(false); 679 } 680 681 if (this.maxInput.value) { 682 var rightInputValue = this.maxInput.value; 683 if (rightInputValue < this.minPrice) 684 rightInputValue = this.minPrice; 685 686 if (rightInputValue > this.maxPrice) 687 rightInputValue = this.maxPrice; 688 689 priceDiff = this.maxPrice - rightInputValue; 690 this.rightPercent = (priceDiff * 100) / this.priceDiff; 691 692 this.makeRightSliderMove(false); 693 } 694 }; 695 696 SmartFilter.prototype.makeLeftSliderMove = function (recountPrice) { 697 recountPrice = (recountPrice !== false); 698 699 this.leftSlider.style.left = this.leftPercent + "%"; 700 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 701 702 var areBothSlidersMoving = false;
703 if (this.leftPercent + this.rightPercent >= 100) { 704 areBothSlidersMoving = true; 705 this.rightPercent = 100 - this.leftPercent; 706 this.rightSlider.style.right = this.rightPercent + "%"; 707 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 708 } 709 710 if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100 - this.fltMaxPercent)) { 711 this.colorAvailableActive.style.left = this.leftPercent + "%"; 712 if (areBothSlidersMoving) { 713 this.colorAvailableActive.style.right = 100 - this.leftPercent + "%"; 714 } 715 } else if (this.leftPercent <= this.fltMinPercent) { 716 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 717 if (areBothSlidersMoving) { 718 this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%"; 719 } 720 } else if (this.leftPercent >= this.fltMaxPercent) { 721 this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%"; 722 if (areBothSlidersMoving) { 723 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 724 } 725 } 726 727 if (recountPrice) { 728 this.recountMinPrice(); 729 if (areBothSlidersMoving) 730 this.recountMaxPrice(); 731 } 732 }; 733 734 SmartFilter.prototype.countNewLeft = function (event) { 735 var pageX = this.getPageX(event); 736 737 var trackerXCoord = this.getXCoord(this.trackerWrap); 738 var rightEdge = this.trackerWrap.offsetWidth; 739 740 var newLeft = pageX - trackerXCoord; 741 742 if (newLeft < 0) 743 newLeft = 0; 744 else if (newLeft > rightEdge) 745 newLeft = rightEdge; 746 747 return newLeft; 748 }; 749 750 SmartFilter.prototype.onMoveLeftSlider = function (e) { 751 if (!this.isTouch) { 752 this.leftSlider.ondragstart = function () { 753 return false; 754 }; 755 } 756 757 if (!this.isTouch) { 758 document.onmousemove = BX.proxy(function (event) { 759 this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth); 760 this.makeLeftSliderMove(); 761 }, this); 762 763 document.onmouseup = function () { 764 document.onmousemove = document.onmouseup = null; 765 }; 766 } else { 767 document.ontouchmove = BX.proxy(function (event) { 768 this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth); 769 this.makeLeftSliderMove(); 770 }, this); 771 772 document.ontouchend = function () { 773 document.ontouchmove = document.touchend = null; 774 }; 775 } 776 777 return false; 778 }; 779 780 SmartFilter.prototype.makeRightSliderMove = function (recountPrice) { 781 recountPrice = (recountPrice !== false); 782 783 this.rightSlider.style.right = this.rightPercent + "%"; 784 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 785 786 var areBothSlidersMoving = false; 787 if (this.leftPercent + this.rightPercent >= 100) { 788 areBothSlidersMoving = true; 789 this.leftPercent = 100 - this.rightPercent; 790 this.leftSlider.style.left = this.leftPercent + "%"; 791 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 792 } 793 794 if ((100 - this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent) { 795 this.colorAvailableActive.style.right = this.rightPercent + "%"; 796 if (areBothSlidersMoving) { 797 this.colorAvailableActive.style.left = 100 - this.rightPercent + "%"; 798 } 799 } else if (this.rightPercent <= this.fltMaxPercent) { 800 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 801 if (areBothSlidersMoving) { 802 this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%"; 803 } 804 } else if ((100 - this.rightPercent) <= this.fltMinPercent) { 805 this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%"; 806 if (areBothSlidersMoving) { 807 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 808 } 809 } 810 811 if (recountPrice) { 812 this.recountMaxPrice(); 813 if (areBothSlidersMoving) 814 this.recountMinPrice(); 815 } 816 }; 817 818 SmartFilter.prototype.onMoveRightSlider = function (e) { 819 if (!this.isTouch) { 820 this.rightSlider.ondragstart = function () { 821 return false;
822 }; 823 } 824 825 if (!this.isTouch) { 826 document.onmousemove = BX.proxy(function (event) { 827 this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth)); 828 this.makeRightSliderMove(); 829 }, this); 830 831 document.onmouseup = function () { 832 document.onmousemove = document.onmouseup = null; 833 }; 834 } else { 835 document.ontouchmove = BX.proxy(function (event) { 836 this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth)); 837 this.makeRightSliderMove(); 838 }, this); 839 840 document.ontouchend = function () { 841 document.ontouchmove = document.ontouchend = null; 842 }; 843 } 844 845 return false; 846 }; 847 848 return SmartFilter; 849})();
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.