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