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