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