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