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