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