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