1// fix double add event handler (composite + google PSI module) 2if(!window.JCSmartFilterBinds){ 3 $(document).ready(function(){ 4 var checkClosed = function(item){ 5 $.cookie.json = true; 6 var arClosed = $.cookie("MAX_FILTER_CLOSED"); 7 if (arClosed && typeof arClosed != "undefined"){ 8 if (typeof item != "undefined"){ 9 var propID = item.parents(".bx_filter_parameters_box").data("property_id"); 10 var delIndex = $.inArray(propID, arClosed); 11 if (delIndex >= 0) { arClosed.splice(delIndex,1);} else {arClosed.push(propID);} 12 } 13 }else{ 14 var arClosed = []; 15 if (typeof item != "undefined"){ 16 item = $(item); 17 var propID = item.parents(".bx_filter_parameters_box").data("property_id"); 18 if (!item.parents(".bx_filter_parameters_box").is(".active")) { if (!$.inArray(propID, arClosed) >= 0) { arClosed.push(propID); } } 19 else { if ($.inArray(propID, arClosed) >= 0) { arClosed.splice(delIndex,1); } } 20 } 21 } 22 $.cookie("MAX_FILTER_CLOSED", arClosed, { 23 path: '/', 24 domain: '', 25 expires: 360 26 }); 27 return true; 28 } 29 $(document).on("click", ".bx_filter_parameters_box_title", function(e){ 30 if(!$(e.target).hasClass('tooltip')){ 31 var active=2; 32 if ($(this).closest(".bx_filter_parameters_box").hasClass("active")) 33 { 34 // $(this).next(".bx_filter_block").slideUp(100); 35 $(this).next(".bx_filter_block").stop().velocity('slideUp', 100); 36 } 37 else 38 { 39 // $(this).next(".bx_filter_block").slideDown(200); 40 $(this).next(".bx_filter_block").stop().velocity('slideDown', 200); 41 } 42 43 $(this).closest(".bx_filter_parameters_box").toggleClass("active"); 44 45 if($(this).closest(".bx_filter_parameters_box").hasClass("active")) 46 active=3; 47 48 $.cookie.json = true; 49 $.cookie("MAX_filter_prop_"+$(this).closest(".bx_filter_parameters_box").data('prop_code'), active,{ 50 path: '/', 51 domain: '', 52 expires: 360 53 }); 54 } 55 }); 56 $('.bx_filter_parameters_box').each(function(){ 57 if($.cookie("MAX_filter_prop_"+$(this).data('prop_code'))==2){ 58 $(this).removeClass('active'); 59 $(this).find('.bx_filter_block').hide(); 60 }else if($.cookie("MAX_filter_prop_"+$(this).data('prop_code'))==3){ 61 $(this).addClass('active'); 62 $(this).find('.bx_filter_block').show(); 63 } 64 }); 65 $(document).click(function(e) { 66 if(!$(e.target).hasClass('tooltip')){ 67 $('.bx_filter .hint.active').removeClass("active").find(".tooltip").slideUp(200); 68 } 69 }); 70 window.JCSmartFilterBinds = true; 71 InitScrollBar(); 72 }) 73} 74 function JCSmartFilter(ajaxURL, viewMode, params) 75 { 76 this.ajaxURL = ajaxURL; 77 this.form = null; 78 this.timer = null; 79 this.cacheKey = ''; 80 this.cache = []; 81 this.viewMode = viewMode; 82 this.normal_url=false; 83 this.reset=false; 84 /*if (params && params.SEF_SET_FILTER_URL) 85 {*/ 86 this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL); 87 this.sef = true; 88 /*} 89 if (params && params.SEF_DEL_FILTER_URL) 90 {*/ 91 this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL); 92 //} 93 if(!params.SEF_DEL_FILTER_URL){ 94 this.normal_url=true; 95 } 96 } 97 98 JCSmartFilter.prototype.keyup = function(input) 99 { 100 if(!!this.timer) 101 { 102 clearTimeout(this.timer); 103 } 104 if(!$(input).hasClass('disabled')){ 105 this.timer = setTimeout(BX.delegate(function(){ 106 this.reload(input); 107 }, this), 500); 108 } 109 }; 110 111 JCSmartFilter.prototype.click = function(checkbox) 112 { 113 if(!!this.timer) 114 { 115 clearTimeout(this.timer); 116 } 117 118 this.timer = setTimeout(BX.delegate(function(){ 119 this.reload(checkbox); 120 }, this), 500); 121 }; 122 123 JCSmartFilter.prototype.reload = function(input) 124 { 125 if (this.cacheKey !== '') 126 { 127 //Postprone backend query 128 if(!!this.timer) 129 { 130 clearTimeout(this.timer); 131 } 132 this.timer = setTimeout(BX.delegate(function(){ 133 this.reload(input); 134 }, this), 1000); 135 return; 136 } 137 this.cacheKey = '|'; 138 139 this.position = BX.pos(input, true); 140 this.form = BX.findParent(input, {'tag':'form'}); 141 142 if (this.form) 143 { 144 if($('.middle > .container .ajax_load').length) 145 $('.middle > .container .ajax_load').addClass('loading-state'); 146 147 var values = []; 148 values[0] = {name: 'ajax', value: 'y'}; 149 this.gatherInputsValues(values, BX.findChildren(this.form, {'tag': new RegExp('^(input|select)$', 'i')}, true)); 150 151 $('.bx_filter_parameters_box').removeClass('set'); 152 153 for (var i = 0; i < values.length; i++){ 154 this.cacheKey += values[i].name + ':' + values[i].value + '|'; 155 $('input[name='+values[i].name+']').closest('.bx_filter_parameters_box').addClass('set'); 156 } 157 158 for (var i = 0; i < values.length; i++) 159 this.cacheKey += values[i].name + ':' + values[i].value + '|'; 160 161 if (this.cache[this.cacheKey]) 162 { 163 this.curFilterinput = input; 164 this.postHandler(this.cache[this.cacheKey], true); 165 } 166 else 167 {
168 if (this.sef) 169 { 170 var set_filter = BX('set_filter'), 171 reset_filter = BX('del_filter'); 172 173 if(set_filter) 174 set_filter.disabled = true; 175 if(reset_filter) 176 reset_filter.disabled = true; 177 } 178 179 this.curFilterinput = input; 180 BX.ajax.loadJSON( 181 this.ajaxURL, 182 this.values2post(values), 183 BX.delegate(this.postHandler, this) 184 ); 185 } 186 } 187 }; 188 189 JCSmartFilter.prototype.updateItem = function (PID, arItem, reset) 190 { 191 if (arItem.PROPERTY_TYPE === 'N' || arItem.PRICE) 192 { 193 var trackBar = window['trackBar' + PID]; 194 if (!trackBar && arItem.ENCODED_ID) 195 trackBar = window['trackBar' + arItem.ENCODED_ID]; 196 197 if (trackBar && arItem.VALUES) 198 { 199 if (arItem.VALUES.MIN) 200 { 201 if(arItem.VALUES.MIN.HTML_VALUE && window.FilterHelper !== undefined) { 202 var helperData = { 203 NAME: arItem.VALUES.MIN.CONTROL_ID, 204 VALUE: BX.message('FROM')+' '+arItem.VALUES.MIN.HTML_VALUE, 205 TITLE: arItem.NAME, 206 CODE: arItem.VALUES.MIN.CONTROL_ID.replace('_MIN', ''), 207 TYPE: 'price', 208 }; 209 FilterHelper.add(helperData); 210 } 211 if (arItem.VALUES.MIN.FILTERED_VALUE) 212 trackBar.setMinFilteredValue(arItem.VALUES.MIN.FILTERED_VALUE); 213 else 214 trackBar.setMinFilteredValue(arItem.VALUES.MIN.VALUE); 215 } 216 217 if (arItem.VALUES.MAX) 218 { 219 if(arItem.VALUES.MAX.HTML_VALUE && window.FilterHelper !== undefined) { 220 var helperData = { 221 NAME: arItem.VALUES.MAX.CONTROL_ID, 222 VALUE: BX.message('BEFORE')+' '+arItem.VALUES.MAX.HTML_VALUE, 223 TITLE: arItem.NAME, 224 CODE: arItem.VALUES.MAX.CONTROL_ID.replace('_MAX', ''), 225 TYPE: 'price', 226 }; 227 FilterHelper.add(helperData); 228 } 229 if (arItem.VALUES.MAX.FILTERED_VALUE) 230 trackBar.setMaxFilteredValue(arItem.VALUES.MAX.FILTERED_VALUE); 231 else 232 trackBar.setMaxFilteredValue(arItem.VALUES.MAX.VALUE); 233 } 234 if(reset=="Y"){ 235 trackBar.leftPercent=trackBar.rightPercent=0; 236 $("#"+arItem.VALUES.MIN.CONTROL_ID).val(''); 237 $("#"+arItem.VALUES.MAX.CONTROL_ID).val(''); 238 $("#left_slider_"+arItem.ENCODED_ID).css({'left':"0%"}); 239 $("#colorUnavailableActive_"+arItem.ENCODED_ID).css({'left':"0%", 'right' : "0%"}); 240 $("#colorAvailableInactive_"+arItem.ENCODED_ID).css({'left':"0%", 'right' : "0%"}); 241 $("#colorAvailableActive_"+arItem.ENCODED_ID).css({'left':"0%", 'right' : "0%"}); 242 $("#right_slider_"+arItem.ENCODED_ID).css({'right':"0%"}); 243 } 244 } 245 } 246 else if (arItem.VALUES) 247 { 248 for (var i in arItem.VALUES) 249 { 250 if (arItem.VALUES.hasOwnProperty(i)) 251 { 252 var value = arItem.VALUES[i]; 253 var control = BX(value.CONTROL_ID); 254 if (!!control) 255 { 256 var label = document.querySelector('[data-role="label_'+value.CONTROL_ID+'"]'); 257 input = document.querySelector('[id="'+value.CONTROL_ID+'"]'); 258 259 if(value.CHECKED && window.FilterHelper !== undefined) { 260 var helperData = { 261 NAME: value.CONTROL_ID, 262 VALUE: value.VALUE, 263 TITLE: arItem.NAME, 264 INPUT: input, 265 CODE: arItem.CODE.toLowerCase(), 266 TYPE: $(input).attr('type'), 267 }; 268 FilterHelper.add(helperData); 269 } 270 if (value.DISABLED) 271 { 272 if (label){ 273 BX.addClass(label, 'disabled'); 274 if(input){ 275 input.setAttribute('disabled','disabled'); 276 BX.addClass(input, 'disabled'); 277 } 278 }else{ 279 BX.addClass(control.parentNode, 'disabled'); 280 } 281 282 283 } 284 else 285 { 286 if (label){ 287 BX.removeClass(label, 'disabled'); 288 if(input){ 289 input.removeAttribute('disabled'); 290 BX.removeClass(input, 'disabled'); 291 } 292 // if(reset=="Y"){ 293 if($(control)){ 294 $(control).prop('disabled',false); 295 $(control).removeClass('disabled'); 296 } 297 $(label).find('span').removeClass('disabled'); 298 // } 299 }else 300 BX.removeClass(control.parentNode, 'disabled'); 301 } 302 303 if(reset=="Y"){ 304 if($(control).attr("type")=="checkbox" || $(control).attr("type")=="radio"){ 305 if($(control).attr("checked")){
306 $(control).prop('checked',false); 307 // input.removeAttribute('checked'); 308 } 309 } 310 } 311 312 if (value.hasOwnProperty('ELEMENT_COUNT')) 313 { 314 label = document.querySelector('[data-role="count_'+value.CONTROL_ID+'"]'); 315 if (label) 316 label.innerHTML = value.ELEMENT_COUNT; 317 } 318 } 319 } 320 } 321 } 322 }; 323 324 JCSmartFilter.prototype.postHandlerAjax = function (result, fromCache) 325 { 326 $('#content').html(result); 327 } 328 329 JCSmartFilter.prototype.setUrlSortDisplay = function (url) 330 { 331 var arReplace_url='', 332 strReplace_url=''; 333 334 $('.sort_btn').each(function(){ 335 arReplace_url=$(this).attr('href').split("?"); 336 arReplace_url[0]=url; 337 strReplace_url=arReplace_url.join('?'); 338 339 $(this).attr('href', strReplace_url); 340 }) 341 } 342 343 JCSmartFilter.prototype.filterCatalog = function (url, set_disabled, reset, count) 344 { 345 if( window.History.enabled || window.history.pushState != null ){ 346 window.History.pushState( null, document.title, decodeURIComponent(url) ); 347 }else{ 348 location.href = url; 349 } 350 351 // this.setUrlSortDisplay(url); 352 353 $.ajax({ 354 url:url, 355 type: "GET", 356 data: {'ajax_get':'Y', 'ajax_get_filter':'Y'}, 357 success: function(html){ 358 /*$('.middle > .container').html(html); 359 360 if($(html).find('.filter_title').hasClass('active-filter')) 361 { 362 $('.filter_title').addClass('active-filter'); 363 $('.bx_filter_search_reset').removeClass('hidden'); 364 } 365 else 366 { 367 $('.filter_title').removeClass('active-filter'); 368 if(reset) 369 $('.bx_filter_search_reset').addClass('hidden'); 370 } 371 372 if(reset) 373 { 374 $('.bx_filter_button_box .bx_filter_search_reset').addClass('hidden'); 375 376 377 if(reset && $('#mobilefilter .bx_filter').length) 378 { 379 mobileFilterNum(count); 380 } 381 382 smartFilter.reset = false; 383 }*/ 384 385 if(reset && (!$('#wrapInlineFilter').length || !$('#wrapInlineFilter').is(':empty'))) 386 { 387 // $('#right_block_ajax').html($(html).find('#right_block_ajax').html()); 388 $('.js-load-wrapper').html($(html).find('.js-load-wrapper').html()); 389 $('.left_block').html($(html).find('.left_block').html()); 390 $('.top-content-block').html($(html).find('.top-content-block').html()); 391 392 if ('checkFilterLandgings' in window && typeof checkFilterLandgings == 'function') { 393 checkFilterLandgings() 394 } 395 396 InitStickySideBar(); 397 InitScrollBar($('.left_block .smartfilter .srollbar-custom')); 398 } 399 else 400 { 401 var itemsHtml = $.trim($(html).find('.inner_wrapper').html()); 402 $('.middle > .container .inner_wrapper').html(itemsHtml); 403 404 //ajax top-block 405 $('.top-content-block').html($(html).find('.top-content-block').html()) 406 407 //ajax sort-block 408 $('.sort_header').html($(html).find('.sort_header').html()) 409 410 if($(html).find('.filter_title').hasClass('active-filter')) 411 { 412 $('.filter_title').addClass('active-filter'); 413 $('.bx_filter_search_reset ').removeClass('hidden'); 414 } 415 else 416 { 417 $('.filter_title').removeClass('active-filter'); 418 $('.bx_filter_search_reset ').addClass('hidden'); 419 } 420 421 if(reset && $('#mobilefilter .bx_filter').length) 422 { 423 $("#mobilefilter").html(''); 424 $(html).find(".bx_filter").appendTo($("#mobilefilter")); 425 $("#mobilefilter .bx_filter_parameters").addClass('scrollbar'); 426 $("#mobilefilter .bx_filter_parameters .bx_filter_parameters_box_title").addClass('colored_theme_hover_bg-block'); 427 $('#mobilefilter .bx_filter_button_box .filter-bnt-wrapper').removeClass('hidden'); 428 InitCustomScrollBar(); 429 430 smartFilter.bindUrlToButton('set_filter', smartFilter.SEF_SET_FILTER_URL); 431 smartFilter.bindUrlToButton('del_filter', smartFilter.SEF_DEL_FILTER_URL); 432 433 mobileFilterNum(count); 434 435 if(window.sortFilterPopup !== undefined && typeof(window.sortFilterPopup.destroy) == 'function' ) { 436 window.sortFilterPopup.destroy(); 437 } 438 } 439 440 if ('checkFilterLandgings' in window && typeof checkFilterLandgings == 'function') { 441 checkFilterLandgings() 442 } 443 } 444 445 CheckTopMenuFullCatalogSubmenu(); 446 447 $('.fast_view_frame').remove(); 448 449 // setStatusButton(); 450 BX.onCustomEvent('onAjaxSuccessFilter'); 451 452 if(set_disabled=="Y"){ 453 var set_filter = BX('set_filter'), 454 reset_filter = BX('del_filter'); 455 456 if(set_filter) 457 set_filter.disabled = false;
458 if(reset_filter) 459 reset_filter.disabled = false; 460 } 461 462 var eventdata = {action:'jsLoadBlock'}; 463 BX.onCustomEvent('onCompleteAction', [eventdata, this]); 464 465 if($('.middle > .container .ajax_load').length) 466 $('.middle > .container .ajax_load').removeClass('loading-state'); 467 468 // $('.countdown').countdown('destroy'); 469 // initCountdown(); 470 } 471 }) 472 } 473 474 JCSmartFilter.prototype.postHandler = function (result, fromCache) 475 { 476 if(window.FilterHelper !== undefined){ 477 FilterHelper.reload(); 478 } 479 var hrefFILTER, url, curProp; 480 var modef = BX('modef'); 481 var modef_mobile = BX('modef_mobile'); 482 var modef_num = BX('modef_num'); 483 var modef_num_mobile = BX('modef_num_mobile'); 484 var reset="N"; 485 486 if ('RESET_FORM' in result){ 487 document.getElementsByClassName("smartfilter")[0].reset(); 488 reset="Y"; 489 } 490 491 if (!!result && !!result.ITEMS) 492 { 493 for(var PID in result.ITEMS) 494 { 495 if (result.ITEMS.hasOwnProperty(PID)) 496 { 497 this.updateItem(PID, result.ITEMS[PID], reset); 498 } 499 } 500 if(reset=="Y"){ 501 if($(".bx_filter_select_block").length){ 502 $(".bx_filter_select_block").each(function(){ 503 var id=$(this).closest('.bx_filter_parameters_box').attr('property_id'),
504 all_text=$(this).find('.input_wr_all input:first-child').data('title'); 505 $(this).find('.bx_filter_select_text').text(all_text); 506 $(this).find('.bx_filter_select_popup li label').removeClass('selected'); 507 }) 508 } 509 } 510 if (!!modef && !!modef_num) 511 { 512 modef_num.innerHTML = result.ELEMENT_COUNT; 513 modef_num_mobile.innerHTML = result.ELEMENT_COUNT; 514 if(typeof mobileFilterNum === 'function'){ 515 mobileFilterNum(result.ELEMENT_COUNT); 516 } 517 hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true); 518 hrefFILTER_mobile = BX.findChildren(modef_mobile, {tag: 'A'}, true); 519 520 if (result.FILTER_URL && hrefFILTER) 521 { 522 hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/')); 523 hrefFILTER_mobile[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL.replace('/filter/clear/apply/', '/')); 524 } 525 526 if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID) 527 { 528 BX.unbindAll(hrefFILTER[0]); 529 BX.unbindAll(hrefFILTER_mobile[0]); 530 BX.bind(hrefFILTER[0], 'click', function(e) 531 { 532 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 533 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 534 return BX.PreventDefault(e); 535 }); 536 } 537 538 if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID) 539 { 540 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 541 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 542 } 543 else 544 { 545 /*ajax update filter catalog items start*/ 546 547 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 548 // BX.ajax.insertToNode(url+'?ajax_get=Y', "right_block_ajax"); 549 550 this.filterCatalog(url, "N", this.reset, result.ELEMENT_COUNT); 551 552 /*ajax update filter catalog items end*/ 553 554 /*if (modef.style.display === 'none') 555 { 556 modef.style.display = 'inline-block'; 557 modef_mobile.style.display = 'inline-block'; 558 } 559 if (this.viewMode == "vertical") 560 { 561 curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class':'bx_filter_parameters_box'}), {'class':'bx_filter_container_modef'}, true, false); 562 curProp.appendChild(modef); 563 }*/ 564 565 if (result.SEF_SET_FILTER_URL) 566 { 567 this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL); 568 }else{ 569 this.bindUrlToButton('set_filter', url); 570 } 571 } 572 } 573 if(window.FilterHelper !== undefined){ 574 FilterHelper.show(); 575 } 576 } 577 578 if (this.sef) 579 { 580 var set_filter = BX('set_filter'), 581 reset_filter = BX('del_filter'); 582 583 if(set_filter) 584 set_filter.disabled = false; 585 if(reset_filter) 586 reset_filter.disabled = false; 587 } 588 589 if (!fromCache && this.cacheKey !== '') 590 { 591 this.cache[this.cacheKey] = result; 592 } 593 this.cacheKey = ''; 594 }; 595 596 JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url) 597 { 598 var button = BX(buttonId); 599 if (button) 600 { 601 var proxy = function(j, func) 602 { 603 return function() 604 { 605 return func(j); 606 } 607 }; 608 609 if (button.type == 'submit') 610 button.type = 'button'; 611 612 $(button).data("href", url); 613 BX.unbindAll(button); 614 615 BX.bind(button, 'click', BX.proxy(function(){ 616 var url_filter=$(button).data('href'), 617 id=$(button).attr('id'); 618 619 if(id=="del_filter"){ 620 var values = [], 621 url_form =this.normal_url ? $('form.smartfilter').attr('action') : this.ajaxURL; 622 values[0] = {name: 'ajax', value: 'y'}; 623 // document.getElementById("smartfilter").reset(); 624 if(!this.normal_url){ 625 // this.gatherInputsValues(values, BX.findChildren(document.getElementById("smartfilter"), {'tag': new RegExp('^([type=hidden])$', 'i')}, true)); 626 this.gatherInputsValues(values, BX.findChildren(document.getElementById("smartfilter"), {'attribute': 'hidden'}, true)); 627 } 628 values[1] = {name: 'reset_form', value: 'y'}; 629 if (this.sef) 630 { 631 var set_filter = BX('set_filter'), 632 reset_filter = BX('del_filter'); 633 634 if(set_filter) 635 set_filter.disabled = true; 636 if(reset_filter) 637 reset_filter.disabled = true; 638 } 639 640 this.reset = true; 641 642 BX.ajax.loadJSON( 643 url_form, 644 this.values2post(values), 645 BX.delegate(this.postHandler, this) 646 ); 647 }else{ 648 if(url_filter){ 649 if (this.sef) 650 { 651 var set_filter = BX('set_filter'), 652 reset_filter = BX('del_filter'); 653 654 if(set_filter) 655 set_filter.disabled = true; 656 if(reset_filter) 657 reset_filter.disabled = true; 658 } 659 660 this.filterCatalog(url_filter, "Y"); 661 } 662 } 663 }, this)); 664 } 665 }; 666 667 JCSmartFilter.prototype.gatherInputsValues = function (values, elements) 668 { 669 if(elements) 670 { 671 for(var i = 0; i < elements.length; i++) 672 { 673 var el = elements[i]; 674 if (el.disabled || !el.type) 675 continue; 676 677 switch(el.type.toLowerCase()) 678 { 679 case 'text': 680 case 'textarea': 681 case 'password': 682 case 'hidden': 683 case 'select-one': 684 if(el.value.length) 685 values[values.length] = {name : el.name, value : el.value}; 686 break; 687 case 'radio': 688 case 'checkbox': 689 if(el.checked) 690 values[values.length] = {name : el.name, value : el.value}; 691 break; 692 case 'select-multiple': 693 for (var j = 0; j < el.options.length; j++) 694 { 695 if (el.options[j].selected) 696 values[values.length] = {name : el.name, value : el.options[j].value}; 697 } 698 break; 699 default: 700 break; 701 } 702 } 703 } 704 }; 705 706 JCSmartFilter.prototype.values2post = function (values) 707 { 708 var post = []; 709 var current = post; 710 var i = 0; 711 712 while(i < values.length) 713 { 714 var p = values[i].name.indexOf('['); 715 if(p == -1) 716 { 717 current[values[i].name] = values[i].value; 718 current = post; 719 i++; 720 } 721 else 722 {
723 var name = values[i].name.substring(0, p); 724 var rest = values[i].name.substring(p+1); 725 if(!current[name]) 726 current[name] = []; 727 728 var pp = rest.indexOf(']'); 729 if(pp == -1) 730 { 731 //Error - not balanced brackets 732 current = post; 733 i++; 734 } 735 else if(pp == 0) 736 { 737 //No index specified - so take the next integer 738 current = current[name]; 739 values[i].name = '' + current.length; 740 } 741 else 742 { 743 //Now index name becomes and name and we go deeper into the array 744 current = current[name]; 745 values[i].name = rest.substring(0, pp) + rest.substring(pp+1); 746 } 747 } 748 } 749 return post; 750 }; 751 752 JCSmartFilter.prototype.hideFilterProps = function(element) 753 { 754 var obj = element.parentNode, 755 filterBlock = obj.querySelector("[data-role='bx_filter_block']"), 756 propAngle = obj.querySelector("[data-role='prop_angle']"); 757 758 if(BX.hasClass(obj, "bx-active")) 759 { 760 new BX.easing({ 761 duration : 300, 762 start : { opacity: 1, height: filterBlock.offsetHeight }, 763 finish : { opacity: 0, height:0 }, 764 transition : BX.easing.transitions.quart, 765 step : function(state){ 766 filterBlock.style.opacity = state.opacity; 767 filterBlock.style.height = state.height + "px"; 768 }, 769 complete : function() { 770 filterBlock.setAttribute("style", ""); 771 BX.removeClass(obj, "bx-active"); 772 } 773 }).animate(); 774 775 BX.addClass(propAngle, "fa-angle-down"); 776 BX.removeClass(propAngle, "fa-angle-up"); 777 } 778 else 779 { 780 filterBlock.style.display = "block"; 781 filterBlock.style.opacity = 0; 782 filterBlock.style.height = "auto"; 783 784 var obj_children_height = filterBlock.offsetHeight; 785 filterBlock.style.height = 0; 786 787 new BX.easing({ 788 duration : 300, 789 start : { opacity: 0, height: 0 }, 790 finish : { opacity: 1, height: obj_children_height }, 791 transition : BX.easing.transitions.quart, 792 step : function(state){ 793 filterBlock.style.opacity = state.opacity; 794 filterBlock.style.height = state.height + "px"; 795 }, 796 complete : function() { 797 } 798 }).animate(); 799 800 BX.addClass(obj, "bx-active"); 801 BX.removeClass(propAngle, "fa-angle-down"); 802 BX.addClass(propAngle, "fa-angle-up"); 803 } 804 }; 805 806 JCSmartFilter.prototype.showDropDownPopup = function(element, popupId) 807 { 808 var contentNode = element.querySelector('[data-role="dropdownContent"]'), 809 offset=$(element).offset(); 810 var el = BX.PopupWindowManager.create("smartFilterDropDown"+popupId, element, { 811 autoHide: true, 812 offsetLeft: 0, 813 offsetTop: 0, 814 overlay : false, 815 draggable: {restrict:true}, 816 closeByEsc: true, 817 content: contentNode 818 }); 819 820 if(popupId == 'ASPRO_FILTER_SORT') { 821 window.sortFilterPopup = el; 822 } 823 824 el.show(); 825 826 $("#smartFilterDropDown"+popupId).insertAfter($(element).closest('.bx_filter_parameters_box_container')); 827 828 $("#smartFilterDropDown"+popupId).addClass('srollbar-custom').css({'top':'auto', 'left':'auto'/*, 'width':$(element).css('width')*/}); 829 InitScrollBar(); 830 }; 831 832 JCSmartFilter.prototype.selectDropDownItem = function(element, controlId) 833 { 834 if(!BX.hasClass(element,'disabled')){ 835 this.keyup(BX(controlId)); 836 837 var wrapContainer = BX.findParent(BX(controlId), {className:"bx_filter_select_container"}, false); 838 839 var currentOption = wrapContainer.querySelector('[data-role="currentOption"]'); 840 841 currentOption.innerHTML = element.innerHTML; 842 $(element).closest('.bx_filter_select_popup').find('label').removeClass('selected'); 843 BX.addClass(element, "selected"); 844 845 if(BX.PopupWindowManager.getCurrentPopup()) 846 BX.PopupWindowManager.getCurrentPopup().close(); 847 } 848 }; 849 850 BX.namespace("BX.Iblock.SmartFilter"); 851 BX.Iblock.SmartFilter = (function() 852 { 853 var SmartFilter = function(arParams) 854 { 855 if (typeof arParams === 'object') 856 { 857 this.leftSlider = BX(arParams.leftSlider); 858 this.rightSlider = BX(arParams.rightSlider); 859 this.tracker = BX(arParams.tracker); 860 this.trackerWrap = BX(arParams.trackerWrap); 861 862 this.minInput = BX(arParams.minInputId); 863 this.maxInput = BX(arParams.maxInputId); 864 865 this.minPrice = parseFloat(arParams.minPrice); 866 this.maxPrice = parseFloat(arParams.maxPrice); 867 868 this.curMinPrice = parseFloat(arParams.curMinPrice); 869 this.curMaxPrice = parseFloat(arParams.curMaxPrice); 870
871 this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice); 872 this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice); 873 874 this.precision = arParams.precision || 0; 875 876 this.priceDiff = this.maxPrice - this.minPrice; 877 878 this.leftPercent = arParams.leftPercent ? parseFloat(arParams.leftPercent) : 0; 879 this.rightPercent = arParams.rightPercent ? parseFloat(arParams.rightPercent) : 0; 880 881 this.fltMinPercent = 0; 882 this.fltMaxPercent = 0; 883 884 this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray 885 this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue 886 this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue 887 888 this.isTouch = false; 889 890 this.init(); 891 892 if ('ontouchstart' in document.documentElement || 'ontouchstart' in window) 893 { 894 this.isTouch = true; 895 896 BX.bind(this.leftSlider, "touchstart", BX.proxy(function(event){ 897 this.onMoveLeftSlider(event) 898 }, this)); 899 900 BX.bind(this.rightSlider, "touchstart", BX.proxy(function(event){ 901 this.onMoveRightSlider(event) 902 }, this)); 903 904 BX.bind(this.colorAvailableActive, "touchstart", BX.proxy(function(event){ 905 this.onChangeLeftSlider(event); 906 }, this)); 907 908 BX.bind(this.colorUnavailableActive, "touchstart", BX.proxy(function(event){ 909 this.onChangeLeftSlider(event); 910 }, this)); 911 912 BX.bind(this.colorAvailableInactive, "touchstart", BX.proxy(function(event){ 913 this.onChangeLeftSlider(event); 914 }, this)); 915 } 916 else 917 { 918 BX.bind(this.leftSlider, "mousedown", BX.proxy(function(event){ 919 this.onMoveLeftSlider(event) 920 }, this)); 921 922 BX.bind(this.rightSlider, "mousedown", BX.proxy(function(event){ 923 this.onMoveRightSlider(event) 924 }, this)); 925 926 BX.bind(this.colorAvailableActive, "mousedown", BX.proxy(function(event){ 927 this.onChangeLeftSlider(event); 928 }, this)); 929 930 BX.bind(this.colorUnavailableActive, "mousedown", BX.proxy(function(event){ 931 this.onChangeLeftSlider(event); 932 }, this)); 933 934 BX.bind(this.colorAvailableInactive, "mousedown", BX.proxy(function(event){ 935 this.onChangeLeftSlider(event); 936 }, this)); 937 } 938 939 BX.bind(this.minInput, "keyup", BX.proxy(function(event){ 940 this.onInputChange(); 941 }, this)); 942 943 BX.bind(this.maxInput, "keyup", BX.proxy(function(event){ 944 this.onInputChange(); 945 }, this)); 946 } 947 }; 948 949 SmartFilter.prototype.init = function() 950 { 951 var priceDiff; 952 953 if (this.curMinPrice > this.minPrice) 954 { 955 priceDiff = this.curMinPrice - this.minPrice; 956 this.leftPercent = (priceDiff*100)/this.priceDiff; 957 958 this.leftSlider.style.left = this.leftPercent + "%"; 959 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 960 } 961 962 this.setMinFilteredValue(this.fltMinPrice); 963 964 if (this.curMaxPrice < this.maxPrice) 965 { 966 priceDiff = this.maxPrice - this.curMaxPrice; 967 this.rightPercent = (priceDiff*100)/this.priceDiff; 968 969 this.rightSlider.style.right = this.rightPercent + "%"; 970 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 971 } 972 973 this.setMaxFilteredValue(this.fltMaxPrice); 974 if(typeof(asproFilterHelper) == 'function') { 975 window.FilterHelper = new asproFilterHelper(this); 976 FilterHelper.show(); 977 } 978 }; 979 980 SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice) 981 { 982 if (this.colorAvailableInactive) { 983 this.fltMinPrice = parseFloat(fltMinPrice); 984 if (this.fltMinPrice >= this.minPrice) 985 { 986 var priceDiff = this.fltMinPrice - this.minPrice; 987 this.fltMinPercent = (priceDiff*100)/this.priceDiff; 988 989 if (this.leftPercent > this.fltMinPercent) 990 this.colorAvailableActive.style.left = this.leftPercent + "%"; 991 else 992 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 993 994 this.colorAvailableInactive.style.left = this.fltMinPercent + "%"; 995 } 996 else 997 { 998 this.colorAvailableActive.style.left = "0%"; 999 this.colorAvailableInactive.style.left = "0%"; 1000 } 1001 } 1002 }; 1003 1004 SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice) 1005 { 1006 if (this.colorAvailableInactive) { 1007 this.fltMaxPrice = parseFloat(fltMaxPrice); 1008 if (this.fltMaxPrice <= this.maxPrice) 1009 { 1010 var priceDiff = this.maxPrice - this.fltMaxPrice; 1011 this.fltMaxPercent = (priceDiff*100)/this.priceDiff; 1012 1013 if (this.rightPercent > this.fltMaxPercent) 1014 this.colorAvailableActive.style.right = this.rightPercent + "%"; 1015 else 1016 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 1017 1018 this.colorAvailableInactive.style.right = this.fltMaxPercent + "%"; 1019 } 1020 else 1021 { 1022 this.colorAvailableActive.style.right = "0%"; 1023 this.colorAvailableInactive.style.right = "0%"; 1024 } 1025 } 1026 }; 1027 1028 SmartFilter.prototype.getXCoord = function(elem) 1029 { 1030 var box = elem.getBoundingClientRect(); 1031 var body = document.body; 1032 var docElem = document.documentElement; 1033 1034 var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft; 1035 var clientLeft = docElem.clientLeft || body.clientLeft || 0; 1036 var left = box.left + scrollLeft - clientLeft; 1037 1038 return Math.round(left); 1039 }; 1040 1041 SmartFilter.prototype.getPageX = function(e) 1042 { 1043 e = e || window.event; 1044 var pageX = null; 1045 1046 if (this.isTouch && e.targetTouches[0] != null) 1047 { 1048 pageX = e.targetTouches[0].pageX; 1049 } 1050 else if (e.pageX != null) 1051 { 1052 pageX = e.pageX; 1053 } 1054 else if (e.clientX != null) 1055 { 1056 var html = document.documentElement; 1057 var body = document.body; 1058 1059 pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0); 1060 pageX -= html.clientLeft || 0; 1061 } 1062 1063 return pageX; 1064 }; 1065 1066 SmartFilter.prototype.recountMinPrice = function() 1067 { 1068 var newMinPrice = (this.priceDiff*this.leftPercent)/100; 1069 newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision); 1070 1071 if (newMinPrice != this.minPrice) 1072 this.minInput.value = newMinPrice; 1073 else 1074 this.minInput.value = ""; 1075 smartFilter.keyup(this.minInput); 1076 }; 1077 1078 SmartFilter.prototype.recountMaxPrice = function() 1079 { 1080 var newMaxPrice = (this.priceDiff*this.rightPercent)/100; 1081 newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision); 1082 1083 if (newMaxPrice != this.maxPrice) 1084 this.maxInput.value = newMaxPrice; 1085 else 1086 this.maxInput.value = ""; 1087 smartFilter.keyup(this.maxInput); 1088 }; 1089 1090 SmartFilter.prototype.onInputChange = function () 1091 { 1092 var priceDiff; 1093 if (this.minInput.value) 1094 { 1095 var leftInputValue = this.minInput.value; 1096 if (leftInputValue < this.minPrice) 1097 leftInputValue = this.minPrice; 1098 1099 if (leftInputValue > this.maxPrice) 1100 leftInputValue = this.maxPrice; 1101 1102 priceDiff = leftInputValue - this.minPrice; 1103 this.leftPercent = (priceDiff*100)/this.priceDiff; 1104 1105 this.makeLeftSliderMove(false); 1106 } 1107 1108 if (this.maxInput.value) 1109 { 1110 var rightInputValue = this.maxInput.value; 1111 if (rightInputValue < this.minPrice) 1112 rightInputValue = this.minPrice; 1113 1114 if (rightInputValue > this.maxPrice) 1115 rightInputValue = this.maxPrice; 1116 1117 priceDiff = this.maxPrice - rightInputValue; 1118 this.rightPercent = (priceDiff*100)/this.priceDiff; 1119 1120 this.makeRightSliderMove(false); 1121 } 1122 }; 1123 1124 SmartFilter.prototype.makeLeftSliderMove = function(recountPrice) 1125 { 1126 recountPrice = (recountPrice !== false); 1127 1128 this.leftSlider.style.left = this.leftPercent + "%"; 1129 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 1130 1131 var areBothSlidersMoving = false;
1132 if (this.leftPercent + this.rightPercent >= 100) 1133 { 1134 areBothSlidersMoving = true; 1135 this.rightPercent = 100 - this.leftPercent; 1136 this.rightSlider.style.right = this.rightPercent + "%"; 1137 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 1138 } 1139 1140 if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100-this.fltMaxPercent)) 1141 { 1142 this.colorAvailableActive.style.left = this.leftPercent + "%"; 1143 if (areBothSlidersMoving) 1144 { 1145 this.colorAvailableActive.style.right = 100 - this.leftPercent + "%"; 1146 } 1147 } 1148 else if(this.leftPercent <= this.fltMinPercent) 1149 { 1150 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 1151 if (areBothSlidersMoving) 1152 { 1153 this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%"; 1154 } 1155 } 1156 else if(this.leftPercent >= this.fltMaxPercent) 1157 { 1158 this.colorAvailableActive.style.left = 100-this.fltMaxPercent + "%"; 1159 if (areBothSlidersMoving) 1160 { 1161 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 1162 } 1163 } 1164 1165 if (recountPrice) 1166 { 1167 this.recountMinPrice(); 1168 if (areBothSlidersMoving) 1169 this.recountMaxPrice(); 1170 } 1171 }; 1172 1173 SmartFilter.prototype.countNewLeft = function(event) 1174 { 1175 var pageX = this.getPageX(event); 1176 1177 var trackerXCoord = this.getXCoord(this.trackerWrap); 1178 var rightEdge = this.trackerWrap.offsetWidth; 1179 1180 var newLeft = pageX - trackerXCoord; 1181 1182 if (newLeft < 0) 1183 newLeft = 0; 1184 else if (newLeft > rightEdge) 1185 newLeft = rightEdge; 1186 1187 return newLeft; 1188 }; 1189 1190 SmartFilter.prototype.onMoveLeftSlider = function(e) 1191 { 1192 if (!this.isTouch) 1193 { 1194 this.leftSlider.ondragstart = function() { 1195 return false; 1196 }; 1197 } 1198 1199 $('.bx_filter .bx_filter_parameters_box_container input').prop('disabled', false); 1200 1201 if (!this.isTouch) 1202 { 1203 document.onmousemove = BX.proxy(function(event) { 1204 this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth); 1205 this.makeLeftSliderMove(); 1206 }, this); 1207 1208 document.onmouseup = function() { 1209 document.onmousemove = document.onmouseup = null; 1210 }; 1211 } 1212 else 1213 { 1214 var onMoveFunction = BX.proxy(function(event) { 1215 this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth); 1216 this.makeLeftSliderMove(); 1217 }, this); 1218 1219 var onEndFunction = BX.proxy(function(event) { 1220 window.removeEventListener('touchmove', onMoveFunction, false); 1221 window.removeEventListener('touchend', onEndFunction, false); 1222 onMoveFunction = onEndFunction = null; 1223 }, this); 1224 1225 window.addEventListener('touchmove', onMoveFunction, false); 1226 window.addEventListener('touchend', onEndFunction, false); 1227 1228 /*document.ontouchmove = BX.proxy(function(event) { 1229 this.leftPercent = ((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth); 1230 this.makeLeftSliderMove(); 1231 }, this); 1232 1233 document.ontouchend = function() { 1234 document.ontouchmove = document.touchend = null; 1235 };*/ 1236 } 1237 1238 return false; 1239 }; 1240 1241 SmartFilter.prototype.makeRightSliderMove = function(recountPrice) 1242 { 1243 recountPrice = (recountPrice !== false); 1244 1245 this.rightSlider.style.right = this.rightPercent + "%"; 1246 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 1247 1248 var areBothSlidersMoving = false; 1249 if (this.leftPercent + this.rightPercent >= 100) 1250 { 1251 areBothSlidersMoving = true; 1252 this.leftPercent = 100 - this.rightPercent; 1253 this.leftSlider.style.left = this.leftPercent + "%"; 1254 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 1255 } 1256 1257 if ((100-this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent) 1258 { 1259 this.colorAvailableActive.style.right = this.rightPercent + "%"; 1260 if (areBothSlidersMoving) 1261 { 1262 this.colorAvailableActive.style.left = 100 - this.rightPercent + "%"; 1263 } 1264 } 1265 else if(this.rightPercent <= this.fltMaxPercent) 1266 { 1267 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 1268 if (areBothSlidersMoving) 1269 { 1270 this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%"; 1271 } 1272 } 1273 else if((100-this.rightPercent) <= this.fltMinPercent) 1274 { 1275 this.colorAvailableActive.style.right = 100-this.fltMinPercent + "%"; 1276 if (areBothSlidersMoving) 1277 { 1278 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 1279 } 1280 } 1281 1282 if (recountPrice) 1283 { 1284 this.recountMaxPrice(); 1285 if (areBothSlidersMoving) 1286 this.recountMinPrice(); 1287 } 1288 }; 1289 1290 SmartFilter.prototype.onMoveRightSlider = function(e) 1291 { 1292 if (!this.isTouch) 1293 { 1294 this.rightSlider.ondragstart = function() { 1295 return false;
1296 }; 1297 } 1298 1299 $('.bx_filter .bx_filter_parameters_box_container input').prop('disabled', false); 1300 1301 if (!this.isTouch) 1302 { 1303 document.onmousemove = BX.proxy(function(event) { 1304 this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth)); 1305 this.makeRightSliderMove(); 1306 }, this); 1307 1308 document.onmouseup = function() { 1309 document.onmousemove = document.onmouseup = null; 1310 }; 1311 } 1312 else 1313 { 1314 document.ontouchmove = BX.proxy(function(event) { 1315 this.rightPercent = 100-(((this.countNewLeft(event))*100)/(this.trackerWrap.offsetWidth)); 1316 this.makeRightSliderMove(); 1317 }, this); 1318 1319 document.ontouchend = function() { 1320 document.ontouchmove = document.ontouchend = null; 1321 }; 1322 } 1323 1324 return false; 1325 }; 1326 1327 SmartFilter.prototype.onChangeLeftSlider = function(e) 1328 { 1329 if (!this.isTouch) 1330 { 1331 this.leftSlider.ondragstart = function() { 1332 //return false; 1333 }; 1334 } 1335 1336 if (!this.isTouch) 1337 { 1338 // document.onmousedown = BX.proxy(function(event) { 1339 var percent=((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth); 1340 if($(event.target).is(".bx_ui_slider_handle") || !$(event.target).is("[class^=bx_ui_slider]")) 1341 return; 1342 if(percent<50){ 1343 this.leftPercent = percent+1; 1344 this.makeLeftSliderMove(); 1345 }else{ 1346 this.rightPercent = 100-percent; 1347 this.makeRightSliderMove(); 1348 } 1349 // }, this); 1350 1351 document.onmouseup = function() { 1352 document.onmousemove = document.onmouseup = null; 1353 }; 1354 } 1355 else 1356 { 1357 var percent=((this.countNewLeft(e)*100)/this.trackerWrap.offsetWidth); 1358 if($(e.target).is(".bx_ui_slider_handle")) 1359 return; 1360 if(percent<50){ 1361 this.leftPercent = percent; 1362 this.makeLeftSliderMove(); 1363 }else{ 1364 this.rightPercent = 100-percent; 1365 this.makeRightSliderMove(); 1366 } 1367 1368 /*document.ontouchend = BX.proxy(function(event) { 1369 var percent=((this.countNewLeft(event)*100)/this.trackerWrap.offsetWidth); 1370 if($(event.target).is(".bx_ui_slider_handle")) 1371 return; 1372 if(percent<50){ 1373 this.leftPercent = percent; 1374 this.makeLeftSliderMove(); 1375 }else{ 1376 this.rightPercent = 100-percent; 1377 this.makeRightSliderMove(); 1378 } 1379 }, this); 1380 1381 document.ontouchend = function() { 1382 document.ontouchmove = document.touchend = null; 1383 };*/ 1384 } 1385 1386 return false; 1387 }; 1388 1389 return SmartFilter; 1390 })();
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.