1 2; /* Start:"a:4:{s:4:"full";s:109:"/local/templates/visagehall_new/components/bitrix/catalog.smart.filter/.default_new/script.js?178937032652341";s:6:"source";s:93:"/local/templates/visagehall_new/components/bitrix/catalog.smart.filter/.default_new/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3function isMobileCatalog() { 4 return window.matchMedia('(max-width: 767px)').matches; 5} 6 7function isSmartFilterOpen() { 8 const smartfilter = document.querySelector('.smartfilter'); 9 return !!(smartfilter && smartfilter.classList.contains('active')); 10} 11 12function hideCatalogTopLineOnMobile() { 13 if (!isMobileCatalog()) return; 14 15 const catalogTopLine = document.querySelector('.catalog__top-line') || document.querySelector('[data-catalog-top-line]'); 16 if (catalogTopLine) { 17 catalogTopLine.style.zIndex = '0'; 18 } 19} 20 21function reinitSelects() { 22 if (window.SelectCustom) { 23 const selectParents = document.body.querySelectorAll('[data-select-parent]'); 24 25 selectParents.forEach((parent) => { 26 // if select2 instance is NOT already initialized 27 if (!parent.hasAttribute('data-select2-id')) { 28 new window.SelectCustom().init(parent); 29 } 30 }); 31 } 32} 33 34function bindSideEvents(abortController) { 35 const signal = abortController.signal; 36 37 try { 38 document.querySelector('.catalog__filter-btn')?.addEventListener('click', function sortCheckedItems() { 39 try { 40 const filterItems = document.querySelectorAll('.filter-default-popup__item'); 41 const checkedItems = []; 42 43 // СобиÑаем вÑе оÑмеÑеннÑе пÑнкÑÑ 44 filterItems.forEach(function (item) { 45 if (item.querySelector('input[type="checkbox"]').checked) { 46 checkedItems.push(item); 47 } 48 }); 49 50 // ÐеÑемеÑаем оÑмеÑеннÑе пÑнкÑÑ Ð² наÑало ÑпиÑка 51 checkedItems.forEach(function (item) { 52 item.parentNode.insertBefore(item, item.parentNode.firstChild); 53 }); 54 } catch (err) { 55 console.trace(err); 56 } 57 }, { signal }); 58 59 /***************************************** 60 * РаÑкÑÑÑие/ÑкÑÑÑие dropdowns в ÑилÑÑÑе * 61 *****************************************/ 62 63 document.querySelectorAll('.js-filter-call-btn').forEach((btn) => { 64 btn.addEventListener('click', function toggleFilter(e) { 65 try { 66 const filterBox = e.currentTarget.closest('.js-filter-close'); 67 filterBox?.classList.toggle('_active'); 68 } catch (err) { 69 console.trace(err); 70 } 71 }, { signal }); 72 }); 73 74 document.querySelector('.close-filter')?.addEventListener('click', function closeFilter() { 75 const hasTouchElement = document.querySelector('.has-touch'); 76 const catalogTopLine = document.querySelector('.catalog__top-line'); 77 const smartFilter = document.querySelector('.smartfilter'); 78 79 // УÑÑановиÑÑ overflow в 'auto' пÑи закÑÑÑии ÑилÑÑÑа 80 if (hasTouchElement) { 81 hasTouchElement.style.overflow = 'auto'; 82 } 83 84 if (catalogTopLine) { 85 catalogTopLine.style.zIndex = '491'; 86 } 87 88 // УдалÑем клаÑÑ 'active', еÑли он пÑиÑÑÑÑÑвÑÐµÑ 89 smartFilter?.classList.remove('active'); 90 }, { signal }); 91 92 /************************************ 93 * ÐоиÑк по бÑендам / ÑÐ¸Ð¿Ñ Ð¿ÑодÑкÑа * 94 ************************************/ 95 96 const dataName = { 97 filterSearch: 'data-filter-search', 98 filterList: 'data-filter-list', 99 }; 100 101 const filterSearchInputs = Array.from(document.querySelectorAll(`[${dataName.filterSearch}]`)); 102 const filterLists = Array.from(document.querySelectorAll(`[${dataName.filterList}]`)); 103 104 const handleSearch = window.debounce?.(searchForBrands, 500) ?? searchForBrands; 105
106 filterSearchInputs.forEach((searchInput) => { 107 const name = searchInput.getAttribute(dataName.filterSearch); 108 109 if (!name) { 110 return; 111 } 112 113 const filterList = filterLists.find((list) => list.getAttribute(dataName.filterList) === name); 114 115 if (!filterList) { 116 return; 117 } 118 119 searchInput.addEventListener('input', (e) => handleSearch(e, filterList), { signal }); 120 }); 121 122 /** 123 * ÐоиÑк по ÑпиÑкам в ÑилÑÑÑе 124 * @param e {Event} 125 * @param list {HTMLElement} 126 */ 127 function searchForBrands(e, list) { 128 const value = e.target.value.trim().toLowerCase(); 129 130 for (const node of list.children) { 131 const nodeText = node.textContent.trim().toLowerCase(); 132 133 node.classList?.toggle('hidden', !nodeText.includes(value)); 134 } 135 } 136 } catch (e) { 137 console.trace(e); 138 } 139} 140 141function JCSmartFilter(ajaxURL, viewMode, params) { 142 this.ajaxURL = ajaxURL; 143 this.form = null; 144 this.timer = null; 145 this.cacheKey = ''; 146 this.requestInt = 0; 147 this.autoClosePopupTimeout = 0; 148 this.cache = []; 149 this.popups = []; 150 this.viewMode = viewMode; 151 if (params && params.SEF_SET_FILTER_URL) { 152 this.bindUrlToButton('set_filter', params.SEF_SET_FILTER_URL); 153 this.sef = true; 154 } 155 if (params && params.SEF_DEL_FILTER_URL) { 156 this.bindUrlToButton('del_filter', params.SEF_DEL_FILTER_URL); 157 } 158 159 setTimeout(() => { 160 var tagList = BX("smartFilter_tag-list"); 161 162 this.tagListUpdate(tagList); 163 }, 1000); 164} 165 166 167JCSmartFilter.prototype.keyup = function (input) { 168 if (!!this.timer) { 169 clearTimeout(this.timer); 170 } 171 172 this.requestInt++; 173 clearTimeout(this.autoClosePopupTimeout); 174 175 this.timer = setTimeout(BX.delegate(function () { 176 this.reload(input); 177 }, this), 500); 178}; 179 180JCSmartFilter.prototype.click = function (checkbox) { 181 if (!!this.timer) { 182 clearTimeout(this.timer); 183 } 184 185 let tag = document.querySelector('[data-role="tag_' + checkbox.name + '"]'); 186 if (tag) { 187 tag.remove(); 188 } 189 190 this.requestInt++; 191 clearTimeout(this.autoClosePopupTimeout); 192 193 this.timer = setTimeout(BX.delegate(function () { 194 this.reload(checkbox); 195 }, this), 500); 196}; 197 198JCSmartFilter.prototype.reload = function (input) { 199 this.cacheKey = '|'; 200 201 this.position = BX.pos(input, true); 202 this.form = BX.findParent(input, { 'tag': 'form' }); 203 if (this.form) { 204 var values = []; 205 values[0] = { name: 'ajax', value: 'y' }; 206 this.gatherInputsValues(values, BX.findChildren(this.form, { 'tag': new RegExp('^(input|select)$', 'i') }, true)); 207 208 for (var i = 0; i < values.length; i++) 209 this.cacheKey += values[i].name + ':' + values[i].value + '|'; 210 211 $('#items-container').addClass('is-loading'); 212 213 if (this.cache[this.cacheKey]) { 214 this.curFilterinput = input; 215 this.postHandler(this.cache[this.cacheKey]); 216 } else { 217 if (this.sef) { 218 var set_filter = BX('set_filter'); 219 set_filter.disabled = true; 220 } 221 222 this.curFilterinput = input; 223 BX.ajax.loadJSON( 224 this.ajaxURL, 225 this.values2post(values), 226 this.postHandler.bind(this, this.requestInt), 227 ); 228 } 229 } 230}; 231 232JCSmartFilter.prototype.tagListUpdate = function (tagList) { 233 var tagListWrapper = tagList.closest('.tag-list-wrapper'); 234 235 if (!tagListWrapper) return; 236 237 var tagListHidden = tagListWrapper.querySelector('.tag-list__hidden'); 238 var tagListHiddenList = tagListWrapper.querySelector('.tag-list__hidden-list'); 239 var tagListToggle = tagListWrapper.querySelector('.tag-list__toggle:not(.ready)'); 240 var tagListClose = tagListWrapper.querySelector('.tag-list__close:not(.ready)'); 241 var filterResetBtns = document.querySelectorAll('[data-filter-reset]'); 242 var filterToggleBtns = document.querySelectorAll('[data-toggle-filters]'); 243 244 function checkTagListWidth() { 245 if (!tagListHidden) return false;
246 247 let hiddenTagsCount = tagListHiddenList.children.length; 248 249 //ÐÑли блок Ñ ÑÑгами болÑÑе 340px, Ñо поÑледний ÑÑг пÑÑÑем и пÑовеÑÑем еÑÑ Ñаз 250 if (tagList.offsetWidth > 340) { 251 tagListHiddenList.appendChild(tagList.lastChild); 252 checkTagListWidth(); 253 254 //ÐÑли блок Ñ ÑÑгами менÑÑе 240px, но еÑÑÑ ÑкÑÑÑÑе ÑÑги, Ñо пеÑемеÑаем один ÑÑг в видимÑй блок 255 } else if (tagList.offsetWidth < 240 && hiddenTagsCount) { 256 tagList.appendChild(tagListHiddenList.lastChild); 257 } 258 259 hiddenTagsCount = tagListHiddenList.children.length; 260 if (!hiddenTagsCount) tagListHidden.classList.remove('active'); 261 tagListWrapper.querySelector('.tag-list__toggle').classList.toggle('visually-hidden', !hiddenTagsCount); 262 tagListWrapper.querySelector('.tag-list__toggle').textContent = `+${hiddenTagsCount}`; 263 264 updateFilterButtons(); 265 } 266 267 function updateFilterButtons() { 268 const tagsCount = tagListWrapper.querySelectorAll('.tag-list__item').length; 269 270 filterResetBtns.forEach(btn => { 271 btn.classList.toggle('visually-hidden', !tagsCount); 272 }); 273 274 filterToggleBtns.forEach(btn => { 275 btn.classList.toggle('highlighted', tagsCount); 276 277 const el = document.querySelector(".text_catalog_category"); 278 if (el && btn.classList.contains('highlighted')) { 279 // el.style.display = "none" ; 280 } 281 }); 282 } 283 284 function toggleHiddenTagList() { 285 tagListHidden.classList.toggle('active'); 286 } 287 288 if (tagListToggle) { 289 tagListToggle.classList.add('ready'); 290 tagListToggle.addEventListener('click', toggleHiddenTagList); 291 tagListClose.addEventListener('click', toggleHiddenTagList); 292 } 293 294 checkTagListWidth(); 295 tagListWrapper.classList.remove('loading'); 296}; 297 298JCSmartFilter.prototype.updateItem = function (PID, arItem) { 299 var tagList = BX("smartFilter_tag-list"); 300 301 if (arItem.PROPERTY_TYPE === 'N' || arItem.PRICE) { 302 var trackBar = window['trackBar' + PID]; 303 if (!trackBar && arItem.ENCODED_ID) 304 trackBar = window['trackBar' + arItem.ENCODED_ID]; 305 306 if (trackBar && arItem.VALUES) { 307 if (arItem.VALUES.MIN) { 308 if (arItem.VALUES.MIN.FILTERED_VALUE) 309 trackBar.setMinFilteredValue(arItem.VALUES.MIN.FILTERED_VALUE); 310 else 311 trackBar.setMinFilteredValue(arItem.VALUES.MIN.VALUE); 312 } 313 314 if (arItem.VALUES.MAX) { 315 if (arItem.VALUES.MAX.FILTERED_VALUE) 316 trackBar.setMaxFilteredValue(arItem.VALUES.MAX.FILTERED_VALUE); 317 else 318 trackBar.setMaxFilteredValue(arItem.VALUES.MAX.VALUE); 319 } 320 } else { 321 const rangeSlider = $(`#${arItem.ENCODED_ID}`).data("ionRangeSlider"); 322 323 rangeSlider.update({ 324 from: arItem.VALUES.MIN.HTML_VALUE, 325 to: arItem.VALUES.MAX.HTML_VALUE, 326 min: arItem.VALUES.MIN.VALUE, 327 max: arItem.VALUES.MAX.VALUE, 328 }); 329 330 $(`#${arItem.VALUES.MIN.CONTROL_ID}`).val(arItem.VALUES.MIN.HTML_VALUE); 331 $(`#${arItem.VALUES.MAX.CONTROL_ID}`).val(arItem.VALUES.MAX.HTML_VALUE); 332 } 333 var tag = document.querySelector('[data-role="tag_' + arItem.CODE + '"]'); 334 // ÑÑÐ°Ð³Ð¼ÐµÐ½Ñ ÐºÐ¾Ð´Ð° закоменÑеннÑй вÑÐ´Ð°ÐµÑ Ð² ÑилÑÑÑе ÑÐµÐ½Ñ Ñак же и название ÑвойÑÑва по ÑÑÐ¾Ð¼Ñ Ð´Ð¾Ð±Ð°Ð²Ð¸Ð» новое 335 // var value = (arItem.PRICE ? "" : arItem.NAME) + [arItem.VALUES.MIN.HTML_VALUE, arItem.VALUES.MAX.HTML_VALUE].filter(function(v) {return ~~v > 0;}).join(' â½ â ').concat(' â½'); 336 var value = [arItem.VALUES.MIN.HTML_VALUE, arItem.VALUES.MAX.HTML_VALUE].filter(function (v) { 337 return ~~v > 0; 338 }).join(' â½ â ').concat(' â½'); 339 340 if ((arItem.VALUES.MIN.HTML_VALUE || arItem.VALUES.MAX.HTML_VALUE) && tagList && !tag) { 341 tag = BX.create('div', { 342 attrs: { 343 className: "tag-list__item", 344 "data-role": "tag_" + arItem.CODE, 345 }, 346 children: [ 347 BX.create('p', { 348 attrs: { 349 classname: "tag-list__value", 350 }, 351 html: value, 352 }), 353 BX.create('div', { 354 attrs: { 355 className: "cross-btn", 356 }, 357 events: { 358 click: BX.delegate(function () { 359 $('#' + arItem.VALUES.MIN.CONTROL_ID).val(''); 360 $('#' + arItem.VALUES.MAX.CONTROL_ID).val(''); 361 tag.remove(); 362 smartFilter.reload(document.getElementById(arItem.VALUES.MIN.CONTROL_ID)); 363 364 //ÐодÑÑавлÑем даннÑе Ñ Ð¼Ð¸Ð½Ð¸Ð¼Ð°Ð»Ñной/макÑималÑной Ñеной поÑле пеÑезагÑÑзки ÑилÑÑÑа 365 $('#' + arItem.VALUES.MIN.CONTROL_ID).val(arItem.VALUES.MIN.FILTERED_VALUE); 366 $('#' + arItem.VALUES.MAX.CONTROL_ID).val(arItem.VALUES.MAX.FILTERED_VALUE); 367 }, this), 368 }, 369 }), 370 ], 371 }); 372 BX.append(tag, tagList); 373 374 this.tagListUpdate(tagList); 375 } else if (tag) { 376 tag.querySelector('.tag-list__value').innerHTML = value; 377 } 378 379 } else if (arItem.VALUES) { 380 var filter = BX('filter_' + arItem.ID); 381 if (filter) { 382 var enabledValuesCount = Object.values(arItem.VALUES).filter(function (v) { 383 return !v.DISABLED; 384 }).length; 385 386 if (arItem.ID == 293 || enabledValuesCount <= 1) { 387 // BX.addClass(filter, '_hide'); 388 } else { 389 BX.removeClass(filter, '_hide'); 390 } 391 } 392 393 394 for (var i in arItem.VALUES) { 395 if (arItem.VALUES.hasOwnProperty(i)) { 396 var value = arItem.VALUES[i]; 397 var control = BX(value.CONTROL_ID); 398 399 if (!!control) { 400 // control.disabled = value.DISABLED; 401 // control.checked = value.CHECKED && !value.DISABLED; 402 control.checked = value.CHECKED; 403 404 var label = document.querySelector('[data-role="label_' + value.CONTROL_ID + '"]'); 405 if (value.DISABLED) { 406 if (label) { 407 var item = BX.findParent(label, { className: "filter-default-popup__item" }); 408 } else { 409 var item = BX.findParent(control, { className: "filter-default-popup__item" }); 410 } 411 if (item) { 412 BX.addClass(item, 'disabled'); 413 } 414 } else { 415 if (label) { 416 var item = BX.findParent(label, { className: "filter-default-popup__item" }); 417 } else { 418 var item = BX.findParent(control, { className: "filter-default-popup__item" }); 419 } 420 if (item) { 421 BX.removeClass(item, 'disabled'); 422 } 423 } 424 425 var tag = document.querySelector('[data-role="tag_' + value.CONTROL_ID + '"]'); 426 if (value.CHECKED && !value.DISABLED) { 427 if (!tag) { 428 var tag = BX.create('div', { 429 attrs: { 430 className: "tag-list__item", 431 "data-role": "tag_" + value.CONTROL_ID, 432 }, 433 children: [ 434 BX.create('p', { 435 attrs: { 436 classname: "tag-list__value", 437 }, 438 html: value.VALUE, 439 }), 440 BX.create('label', { 441 attrs: { 442 for: value.CONTROL_ID, 443 }, 444 children: [ 445 BX.create('div', { 446 attrs: { 447 className: "cross-btn", 448 }, 449 }), 450 ], 451 }), 452 ], 453 }); 454 455 BX.append(tag, tagList); 456 } 457 } else if (tag) { 458 tag.remove(); 459 } 460 461 this.tagListUpdate(tagList); 462 463 if (value.hasOwnProperty('ELEMENT_COUNT')) { 464 label = document.querySelector('[data-role="count_' + value.CONTROL_ID + '"]'); 465 if (label) 466 label.innerHTML = ' '; 467 } 468 } 469 } 470 } 471 var applied = document.querySelector('[data-role="applied_' + arItem.CODE + '"]'); 472 if (applied) 473 applied.innerHTML = ' ' + (Object.values(arItem.VALUES).reduce(function (r, v) { 474 return r + (!!v.CHECKED && !v.DISABLED); 475 }, 0) || ''); 476 } 477}; 478 479JCSmartFilter.prototype.decodeHtmlChars = function (data) { 480 if (!this.HTMLtmp) { 481 this.HTMLtmp = document.createElement('span'); 482 } 483 this.HTMLtmp.innerHTML = data; 484 return this.HTMLtmp.innerText; 485}; 486 487JCSmartFilter.prototype.postHandler = function (result) { 488 var hrefFILTER, url, curProp, checkKey; 489 var modef = BX('modef'); 490 var modef_num = BX('modef_num'); 491 var toggleFiltersBtn = document.querySelector('.btn[data-toggle-filters]'); 492 493 //document.querySelector('.prod-description__descriptions').style.display = 'none'; 494 let elem = document.querySelector('.prod-description__descriptions'); 495 if (elem) { 496 elem.style.display = 'none'; 497 } 498 499 if (arguments.length > 1) { 500 checkKey = arguments[0]; 501 result = arguments[1]; 502 } else { 503 result = arguments[0]; 504 } 505 506 if (!!checkKey && this.requestInt !== checkKey) { 507 return; 508 } 509 510 if (!!result && !!result.ITEMS) { 511 512 for (var popupId in this.popups) { 513 if (this.popups.hasOwnProperty(popupId)) { 514 this.popups[popupId].destroy(); 515 } 516 } 517 this.popups = []; 518 519 for (var PID in result.ITEMS) { 520 if (result.ITEMS.hasOwnProperty(PID)) { 521 this.updateItem(PID, result.ITEMS[PID]); 522 } 523 } 524 525 if (!!modef && !!modef_num) { 526 modef_num.innerHTML = result.ELEMENT_COUNT; 527 hrefFILTER = BX.findChildren(modef, { tag: 'A' }, true); 528 529 if (result.FILTER_URL && hrefFILTER) { 530 hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL); 531 } 532 533 if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID) { 534 BX.unbindAll(hrefFILTER[0]); 535 BX.bind(hrefFILTER[0], 'click', function (e) { 536 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 537 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 538 return BX.PreventDefault(e); 539 }); 540 } 541 542 if (result.FILTER_AJAX_URL) { 543 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 544 $.ajax(url, { dataType: "json" }).done(function (d) { 545 if ($('#items-container').length > 0 && !!d.items) { 546 $('#items-container').html(d.items).removeClass('is-loading'); 547 $('#pagination-container').html(d.pagination); 548 $('#sections-container').html(d.sections); 549 $('#search-count-container').html(d.total); 550 window.history.replaceState(null, null, url); 551 } else { 552 //window.location.href = url; 553 } 554 555 if (isSmartFilterOpen()) { 556 hideCatalogTopLineOnMobile(); 557 } 558 }); 559 } 560 561 if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID) { 562 url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL); 563 BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID); 564 } else { 565 if (isSmartFilterOpen()) { 566 modef.style.display = 'none'; 567 } else if (modef.style.display === 'none') { 568 modef.style.display = 'inline-block'; 569 } 570 571 if (this.viewMode == "VERTICAL" && false) { 572 curProp = BX.findChild(BX.findParent(this.curFilterinput, { 'class': 'bx-filter-parameters-box' }), { 'class': 'bx-filter-container-modef' }, true, false); 573 curProp.appendChild(modef); 574 } 575 576 if (result.SEF_SET_FILTER_URL) { 577 this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL); 578 } 579 } 580 } 581 582 // if (result.ELEMENT_COUNT !== undefined) { 583 // const breadcrumbCount = document.querySelector('.nx-breadcrumbs .item_count'); 584 // if (breadcrumbCount) { 585 // breadcrumbCount.innerHTML = `(${result.ELEMENT_COUNT})`; 586 // } 587 // } 588 589 if (toggleFiltersBtn) { 590 let btnText = `ÐоказаÑÑ ${result.ELEMENT_COUNT} `, 591 value = result.ELEMENT_COUNT % 10, 592 word = ''; 593 594 const newWord = function (value) { 595 if (value > 10 && value < 20) return 'ÑоваÑов'; 596 if (value > 1 && value < 5) return 'ÑоваÑа'; 597 if (value == 1) return 'ÑоваÑ'; 598 return 'ÑоваÑов'; 599 }; 600 601 word = newWord(value); 602 603 btnText = btnText.concat(word); 604 605 toggleFiltersBtn.textContent = btnText; 606 } 607 } 608 609 if (this.sef) { 610 var set_filter = BX('set_filter'); 611 set_filter.disabled = false;
612 } 613 614 if (this.cacheKey !== '' && !this.cache[this.cacheKey]) { 615 this.cache[this.cacheKey] = result; 616 } 617 this.cacheKey = ''; 618 619 if (isSmartFilterOpen()) { 620 hideCatalogTopLineOnMobile(); 621 } 622 623 //ÐакÑÑÑие попапов поÑле пÑÐ¸Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÑилÑÑÑа 624 /*this.autoClosePopupTimeout = setTimeout(function () { 625 [...document.querySelectorAll('.extended-filter__item._active')].forEach(function (v) { 626 BX.removeClass(v, '_active'); 627 }) 628 }, 1000);*/ 629}; 630 631JCSmartFilter.prototype.bindUrlToButton = function (buttonId, url) { 632 var button = BX(buttonId); 633 if (button) { 634 var proxy = function (j, func) { 635 return function () { 636 return func(j); 637 }; 638 }; 639 640 if (button.type == 'submit') 641 button.type = 'button'; 642 643 BX.bind(button, 'click', proxy(url, function (url) { 644 window.location.href = url; 645 return false; 646 })); 647 } 648}; 649 650JCSmartFilter.prototype.gatherInputsValues = function (values, elements) { 651 if (!elements) return; 652 653 for (var i = 0; i < elements.length; i++) { 654 var el = elements[i]; 655 656 if (el.disabled || !el.type) 657 continue; 658 659 switch (el.type.toLowerCase()) { 660 case 'text': 661 case 'textarea': 662 case 'password': 663 case 'hidden': 664 case 'select-one': 665 if (el.value.length) 666 values[values.length] = { name: el.name, value: el.value }; 667 break; 668 case 'radio': 669 case 'checkbox': 670 if (el.checked) 671 values[values.length] = { name: el.name, value: el.value }; 672 break; 673 case 'select-multiple': 674 for (var j = 0; j < el.options.length; j++) { 675 if (el.options[j].selected) 676 values[values.length] = { name: el.name, value: el.options[j].value }; 677 } 678 break; 679 default: 680 break; 681 } 682 } 683}; 684 685JCSmartFilter.prototype.values2post = function (values) { 686 var post = []; 687 var current = post; 688 var i = 0; 689 690 while (i < values.length) { 691 var p = values[i].name.indexOf('['); 692 if (p == -1) { 693 current[values[i].name] = values[i].value; 694 current = post; 695 i++; 696 } else { 697 var name = values[i].name.substring(0, p); 698 var rest = values[i].name.substring(p + 1); 699 if (!current[name]) 700 current[name] = []; 701 702 var pp = rest.indexOf(']'); 703 if (pp == -1) { 704 //Error - not balanced brackets 705 current = post; 706 i++; 707 } else if (pp == 0) { 708 //No index specified - so take the next integer 709 current = current[name]; 710 values[i].name = '' + current.length; 711 } else { 712 //Now index name becomes and name and we go deeper into the array 713 current = current[name]; 714 values[i].name = rest.substring(0, pp) + rest.substring(pp + 1); 715 } 716 } 717 } 718 return post; 719}; 720 721JCSmartFilter.prototype.hideFilterProps = function (element) { 722 var obj = element.parentNode, 723 filterBlock = obj.querySelector("[data-role='bx_filter_block']"), 724 propAngle = obj.querySelector("[data-role='prop_angle']"); 725 726 if (BX.hasClass(obj, "bx-active")) { 727 new BX.easing({ 728 duration: 300, 729 start: { opacity: 1, height: filterBlock.offsetHeight }, 730 finish: { opacity: 0, height: 0 }, 731 transition: BX.easing.transitions.quart, 732 step: function (state) { 733 filterBlock.style.opacity = state.opacity; 734 filterBlock.style.height = state.height + "px"; 735 }, 736 complete: function () { 737 filterBlock.setAttribute("style", ""); 738 BX.removeClass(obj, "bx-active"); 739 }, 740 }).animate(); 741 742 BX.addClass(propAngle, "fa-angle-down"); 743 BX.removeClass(propAngle, "fa-angle-up"); 744 } else { 745 filterBlock.style.display = "block"; 746 filterBlock.style.opacity = 0; 747 filterBlock.style.height = "auto"; 748 749 var obj_children_height = filterBlock.offsetHeight; 750 filterBlock.style.height = 0; 751 752 new BX.easing({ 753 duration: 300, 754 start: { opacity: 0, height: 0 }, 755 finish: { opacity: 1, height: obj_children_height }, 756 transition: BX.easing.transitions.quart, 757 step: function (state) { 758 filterBlock.style.opacity = state.opacity; 759 filterBlock.style.height = state.height + "px"; 760 }, 761 complete: function () { 762 }, 763 }).animate(); 764 765 BX.addClass(obj, "bx-active"); 766 BX.removeClass(propAngle, "fa-angle-down"); 767 BX.addClass(propAngle, "fa-angle-up"); 768 } 769}; 770 771JCSmartFilter.prototype.showDropDownPopup = function (element, popupId) { 772 var contentNode = element.querySelector('[data-role="dropdownContent"]'); 773 this.popups["smartFilterDropDown" + popupId] = BX.PopupWindowManager.create("smartFilterDropDown" + popupId, element, { 774 autoHide: true, 775 offsetLeft: 0, 776 offsetTop: 3,
777 overlay: false, 778 draggable: { restrict: true }, 779 closeByEsc: true, 780 content: BX.clone(contentNode), 781 }); 782 this.popups["smartFilterDropDown" + popupId].show(); 783}; 784 785JCSmartFilter.prototype.selectDropDownItem = function (element, controlId) { 786 this.keyup(BX(controlId)); 787 788 var wrapContainer = BX.findParent(BX(controlId), { className: "bx-filter-select-container" }, false); 789 790 var currentOption = wrapContainer.querySelector('[data-role="currentOption"]'); 791 currentOption.innerHTML = element.innerHTML; 792 BX.PopupWindowManager.getCurrentPopup().close(); 793}; 794 795BX.namespace("BX.Iblock.SmartFilter"); 796BX.Iblock.SmartFilter = (function () { 797 /** @param {{ 798 leftSlider: string, 799 rightSlider: string, 800 tracker: string, 801 trackerWrap: string, 802 minInputId: string, 803 maxInputId: string, 804 minPrice: float|int|string, 805 maxPrice: float|int|string, 806 curMinPrice: float|int|string, 807 curMaxPrice: float|int|string, 808 fltMinPrice: float|int|string|null, 809 fltMaxPrice: float|int|string|null, 810 precision: int|null, 811 colorUnavailableActive: string, 812 colorAvailableActive: string, 813 colorAvailableInactive: string 814 }} arParams 815 */ 816 var SmartFilter = function (arParams) { 817 if (typeof arParams === 'object') { 818 this.leftSlider = BX(arParams.leftSlider); 819 this.rightSlider = BX(arParams.rightSlider); 820 this.tracker = BX(arParams.tracker); 821 this.trackerWrap = BX(arParams.trackerWrap); 822 823 this.minInput = BX(arParams.minInputId); 824 this.maxInput = BX(arParams.maxInputId); 825 826 this.minPrice = parseFloat(arParams.minPrice); 827 this.maxPrice = parseFloat(arParams.maxPrice); 828 829 this.curMinPrice = parseFloat(arParams.curMinPrice); 830 this.curMaxPrice = parseFloat(arParams.curMaxPrice); 831 832 this.fltMinPrice = arParams.fltMinPrice ? parseFloat(arParams.fltMinPrice) : parseFloat(arParams.curMinPrice); 833 this.fltMaxPrice = arParams.fltMaxPrice ? parseFloat(arParams.fltMaxPrice) : parseFloat(arParams.curMaxPrice); 834 835 this.precision = arParams.precision || 0; 836 837 this.priceDiff = this.maxPrice - this.minPrice; 838 839 this.leftPercent = 0; 840 this.rightPercent = 0; 841 842 this.fltMinPercent = 0; 843 this.fltMaxPercent = 0; 844 845 this.colorUnavailableActive = BX(arParams.colorUnavailableActive);//gray 846 this.colorAvailableActive = BX(arParams.colorAvailableActive);//blue 847 this.colorAvailableInactive = BX(arParams.colorAvailableInactive);//light blue 848 849 this.isTouch = false; 850 851 this.init(); 852 853 if ('ontouchstart' in document.documentElement) { 854 this.isTouch = true; 855 856 BX.bind(this.leftSlider, "touchstart", BX.proxy(function (event) { 857 this.onMoveLeftSlider(event); 858 }, this)); 859 860 BX.bind(this.rightSlider, "touchstart", BX.proxy(function (event) { 861 this.onMoveRightSlider(event); 862 }, this)); 863 } else { 864 BX.bind(this.leftSlider, "mousedown", BX.proxy(function (event) { 865 this.onMoveLeftSlider(event); 866 }, this)); 867 868 BX.bind(this.rightSlider, "mousedown", BX.proxy(function (event) { 869 this.onMoveRightSlider(event); 870 }, this)); 871 } 872 873 BX.bind(this.minInput, "keyup", BX.proxy(function (event) { 874 this.onInputChange(); 875 }, this)); 876 877 BX.bind(this.maxInput, "keyup", BX.proxy(function (event) { 878 this.onInputChange(); 879 }, this)); 880 } 881 }; 882 883 SmartFilter.prototype.init = function () { 884 var priceDiff; 885 if (this.curMinPrice > this.minPrice) { 886 priceDiff = this.curMinPrice - this.minPrice; 887 this.leftPercent = (priceDiff * 100) / this.priceDiff; 888 889 this.leftSlider.style.left = this.leftPercent + "%"; 890 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 891 } 892 893 this.setMinFilteredValue(this.fltMinPrice); 894 895 if (this.curMaxPrice < this.maxPrice) { 896 priceDiff = this.maxPrice - this.curMaxPrice; 897 this.rightPercent = (priceDiff * 100) / this.priceDiff; 898 899 this.rightSlider.style.right = this.rightPercent + "%"; 900 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 901 } 902 903 this.setMaxFilteredValue(this.fltMaxPrice); 904 }; 905 906 SmartFilter.prototype.setMinFilteredValue = function (fltMinPrice) { 907 this.fltMinPrice = parseFloat(fltMinPrice); 908 if (this.fltMinPrice >= this.minPrice) { 909 var priceDiff = this.fltMinPrice - this.minPrice; 910 this.fltMinPercent = (priceDiff * 100) / this.priceDiff; 911 912 if (this.leftPercent > this.fltMinPercent) 913 this.colorAvailableActive.style.left = this.leftPercent + "%"; 914 else 915 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 916 917 this.colorAvailableInactive.style.left = this.fltMinPercent + "%"; 918 } else { 919 this.colorAvailableActive.style.left = "0%"; 920 this.colorAvailableInactive.style.left = "0%"; 921 } 922 }; 923 924 SmartFilter.prototype.setMaxFilteredValue = function (fltMaxPrice) { 925 this.fltMaxPrice = parseFloat(fltMaxPrice); 926 if (this.fltMaxPrice <= this.maxPrice) { 927 var priceDiff = this.maxPrice - this.fltMaxPrice; 928 this.fltMaxPercent = (priceDiff * 100) / this.priceDiff; 929 930 if (this.rightPercent > this.fltMaxPercent) 931 this.colorAvailableActive.style.right = this.rightPercent + "%"; 932 else 933 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 934 935 this.colorAvailableInactive.style.right = this.fltMaxPercent + "%"; 936 } else { 937 this.colorAvailableActive.style.right = "0%"; 938 this.colorAvailableInactive.style.right = "0%"; 939 } 940 }; 941 942 SmartFilter.prototype.getXCoord = function (elem) { 943 var box = elem.getBoundingClientRect(); 944 var body = document.body; 945 var docElem = document.documentElement; 946 947 var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft; 948 var clientLeft = docElem.clientLeft || body.clientLeft || 0; 949 var left = box.left + scrollLeft - clientLeft; 950 951 return Math.round(left); 952 }; 953 954 SmartFilter.prototype.getPageX = function (e) { 955 e = e || window.event; 956 var pageX = null; 957 958 if (this.isTouch && event.targetTouches[0] != null) { 959 pageX = e.targetTouches[0].pageX; 960 } else if (e.pageX != null) { 961 pageX = e.pageX; 962 } else if (e.clientX != null) { 963 var html = document.documentElement; 964 var body = document.body; 965 966 pageX = e.clientX + (html.scrollLeft || body && body.scrollLeft || 0); 967 pageX -= html.clientLeft || 0; 968 } 969 970 return pageX; 971 }; 972 973 SmartFilter.prototype.recountMinPrice = function () { 974 var newMinPrice = (this.priceDiff * this.leftPercent) / 100; 975 newMinPrice = (this.minPrice + newMinPrice).toFixed(this.precision); 976 977 if (newMinPrice != this.minPrice) 978 this.minInput.value = newMinPrice; 979 else 980 this.minInput.value = ""; 981 /** @global JCSmartFilter smartFilter */ 982 smartFilter.keyup(this.minInput); 983 }; 984 985 SmartFilter.prototype.recountMaxPrice = function () { 986 var newMaxPrice = (this.priceDiff * this.rightPercent) / 100; 987 newMaxPrice = (this.maxPrice - newMaxPrice).toFixed(this.precision); 988 989 if (newMaxPrice != this.maxPrice) 990 this.maxInput.value = newMaxPrice; 991 else 992 this.maxInput.value = ""; 993 /** @global JCSmartFilter smartFilter */ 994 smartFilter.keyup(this.maxInput); 995 }; 996 997 SmartFilter.prototype.onInputChange = function () { 998 var priceDiff; 999 if (this.minInput.value) { 1000 var leftInputValue = this.minInput.value; 1001 if (leftInputValue < this.minPrice) 1002 leftInputValue = this.minPrice; 1003 1004 if (leftInputValue > this.maxPrice) 1005 leftInputValue = this.maxPrice; 1006 1007 priceDiff = leftInputValue - this.minPrice; 1008 this.leftPercent = (priceDiff * 100) / this.priceDiff; 1009 1010 this.makeLeftSliderMove(false); 1011 } 1012 1013 if (this.maxInput.value) { 1014 var rightInputValue = this.maxInput.value; 1015 if (rightInputValue < this.minPrice) 1016 rightInputValue = this.minPrice; 1017 1018 if (rightInputValue > this.maxPrice) 1019 rightInputValue = this.maxPrice; 1020 1021 priceDiff = this.maxPrice - rightInputValue; 1022 this.rightPercent = (priceDiff * 100) / this.priceDiff; 1023 1024 this.makeRightSliderMove(false); 1025 } 1026 }; 1027 1028 SmartFilter.prototype.makeLeftSliderMove = function (recountPrice) { 1029 recountPrice = (recountPrice !== false); 1030 1031 this.leftSlider.style.left = this.leftPercent + "%"; 1032 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 1033 1034 var areBothSlidersMoving = false;
1035 if (this.leftPercent + this.rightPercent >= 100) { 1036 areBothSlidersMoving = true; 1037 this.rightPercent = 100 - this.leftPercent; 1038 this.rightSlider.style.right = this.rightPercent + "%"; 1039 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 1040 } 1041 1042 if (this.leftPercent >= this.fltMinPercent && this.leftPercent <= (100 - this.fltMaxPercent)) { 1043 this.colorAvailableActive.style.left = this.leftPercent + "%"; 1044 if (areBothSlidersMoving) { 1045 this.colorAvailableActive.style.right = 100 - this.leftPercent + "%"; 1046 } 1047 } else if (this.leftPercent <= this.fltMinPercent) { 1048 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 1049 if (areBothSlidersMoving) { 1050 this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%"; 1051 } 1052 } else if (this.leftPercent >= this.fltMaxPercent) { 1053 this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%"; 1054 if (areBothSlidersMoving) { 1055 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 1056 } 1057 } 1058 1059 if (recountPrice) { 1060 this.recountMinPrice(); 1061 if (areBothSlidersMoving) 1062 this.recountMaxPrice(); 1063 } 1064 }; 1065 1066 SmartFilter.prototype.countNewLeft = function (event) { 1067 var pageX = this.getPageX(event); 1068 1069 var trackerXCoord = this.getXCoord(this.trackerWrap); 1070 var rightEdge = this.trackerWrap.offsetWidth; 1071 1072 var newLeft = pageX - trackerXCoord; 1073 1074 if (newLeft < 0) 1075 newLeft = 0; 1076 else if (newLeft > rightEdge) 1077 newLeft = rightEdge; 1078 1079 return newLeft; 1080 }; 1081 1082 SmartFilter.prototype.onMoveLeftSlider = function (e) { 1083 if (!this.isTouch) { 1084 this.leftSlider.ondragstart = function () { 1085 return false; 1086 }; 1087 } 1088 1089 if (!this.isTouch) { 1090 document.onmousemove = BX.proxy(function (event) { 1091 this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth); 1092 this.makeLeftSliderMove(); 1093 }, this); 1094 1095 document.onmouseup = function () { 1096 document.onmousemove = document.onmouseup = null; 1097 }; 1098 } else { 1099 document.ontouchmove = BX.proxy(function (event) { 1100 this.leftPercent = ((this.countNewLeft(event) * 100) / this.trackerWrap.offsetWidth); 1101 this.makeLeftSliderMove(); 1102 }, this); 1103 1104 document.ontouchend = function () { 1105 document.ontouchmove = document.touchend = null; 1106 }; 1107 } 1108 1109 return false; 1110 }; 1111 1112 SmartFilter.prototype.makeRightSliderMove = function (recountPrice) { 1113 recountPrice = (recountPrice !== false); 1114 1115 this.rightSlider.style.right = this.rightPercent + "%"; 1116 this.colorUnavailableActive.style.right = this.rightPercent + "%"; 1117 1118 var areBothSlidersMoving = false; 1119 if (this.leftPercent + this.rightPercent >= 100) { 1120 areBothSlidersMoving = true; 1121 this.leftPercent = 100 - this.rightPercent; 1122 this.leftSlider.style.left = this.leftPercent + "%"; 1123 this.colorUnavailableActive.style.left = this.leftPercent + "%"; 1124 } 1125 1126 if ((100 - this.rightPercent) >= this.fltMinPercent && this.rightPercent >= this.fltMaxPercent) { 1127 this.colorAvailableActive.style.right = this.rightPercent + "%"; 1128 if (areBothSlidersMoving) { 1129 this.colorAvailableActive.style.left = 100 - this.rightPercent + "%"; 1130 } 1131 } else if (this.rightPercent <= this.fltMaxPercent) { 1132 this.colorAvailableActive.style.right = this.fltMaxPercent + "%"; 1133 if (areBothSlidersMoving) { 1134 this.colorAvailableActive.style.left = 100 - this.fltMaxPercent + "%"; 1135 } 1136 } else if ((100 - this.rightPercent) <= this.fltMinPercent) { 1137 this.colorAvailableActive.style.right = 100 - this.fltMinPercent + "%"; 1138 if (areBothSlidersMoving) { 1139 this.colorAvailableActive.style.left = this.fltMinPercent + "%"; 1140 } 1141 } 1142 1143 if (recountPrice) { 1144 this.recountMaxPrice(); 1145 if (areBothSlidersMoving) 1146 this.recountMinPrice(); 1147 } 1148 }; 1149 1150 SmartFilter.prototype.onMoveRightSlider = function (e) { 1151 if (!this.isTouch) { 1152 this.rightSlider.ondragstart = function () { 1153 return false;
1154 }; 1155 } 1156 1157 if (!this.isTouch) { 1158 document.onmousemove = BX.proxy(function (event) { 1159 this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth)); 1160 this.makeRightSliderMove(); 1161 }, this); 1162 1163 document.onmouseup = function () { 1164 document.onmousemove = document.onmouseup = null; 1165 }; 1166 } else { 1167 document.ontouchmove = BX.proxy(function (event) { 1168 this.rightPercent = 100 - (((this.countNewLeft(event)) * 100) / (this.trackerWrap.offsetWidth)); 1169 this.makeRightSliderMove(); 1170 }, this); 1171 1172 document.ontouchend = function () { 1173 document.ontouchmove = document.ontouchend = null; 1174 }; 1175 } 1176 1177 return false; 1178 }; 1179 1180 return SmartFilter; 1181})(); 1182 1183try { 1184 class CatalogFixedLine { 1185 constructor(element, options, abortController) { 1186 this.id = { 1187 delFilter: 'del_filter' 1188 } 1189 1190 this.options = { 1191 offset: 315, 1192 offsetForWhiteHeader: 215 1193 } 1194 1195 this.className = { 1196 fixed: 'fixed', 1197 active: 'active', 1198 tagItem: 'tag-list__item', 1199 1200 } 1201 1202 this.dataName = { 1203 header: 'header', 1204 filterLine: 'catalog-filter-line', 1205 suggestions: 'mobile-suggest', 1206 toggleFiltersButton: 'toggle-filters', 1207 filters: 'filters', 1208 sidebar: 'catalog-sidebar', 1209 catalogTopLine: 'catalog-top-line', 1210 filterReset: 'filter-reset', 1211 filterApply: 'filter-apply', 1212 toggleSidebarButton: 'toggle-sidebar', 1213 valueLimit: 'value-limit', 1214 max: 'max', 1215 min: 'min' 1216 } 1217 1218 this.catalogTopLine = document.querySelector(`[data-${this.dataName.catalogTopLine}]`); 1219 if (!this.catalogTopLine) return false; 1220 1221 this.signal = abortController.signal; 1222 1223 this.header = document.querySelector(`[data-${this.dataName.header}]`); 1224 this.filterLine = this.catalogTopLine.querySelector(`[data-${this.dataName.filterLine}]`); 1225 this.suggestions = document.querySelector(`[data-${this.dataName.suggestions}]`); 1226 this.toggleFiltersBtns = this.catalogTopLine.querySelectorAll(`[data-${this.dataName.toggleFiltersButton}]`); 1227 this.filters = this.catalogTopLine.querySelector(`[data-${this.dataName.filters}]`); 1228 this.filterReset = this.catalogTopLine.querySelectorAll(`[data-${this.dataName.filterReset}]`); 1229 this.filterApply = this.catalogTopLine.querySelector(`[data-${this.dataName.filterApply}]`); 1230 this.sidebar = document.querySelector(`[data-${this.dataName.sidebar}]`); 1231 this.toggleSidebarBtn = this.catalogTopLine.querySelector(`[data-${this.dataName.toggleSidebarButton}]`); 1232 this.lastScrollY = window.scrollY; 1233 this.isBrandPage = !!document.querySelector('.brandZone'); 1234 1235 if (this.isBrandPage) this.options.offset = 490; 1236 1237 $.extend(true, this, this, options) 1238 1239 this.init() 1240 } 1241 1242 //Method for run all class methods 1243 init() { 1244 if (window.location.href.indexOf('filter') >= 0){ 1245 let elem = document.querySelector('.prod-description__descriptions'); 1246 if (elem) { 1247 elem.style.display = 'none'; 1248 } 1249 1250 } 1251 this.bindEvents() 1252 } 1253 1254 //Method for all events 1255 bindEvents() { 1256 this.toggleFiltersBtns.forEach(btn => { 1257 btn.addEventListener('click', this.toggleFilters.bind(this), { signal: this.signal }); 1258 1259 }) 1260 this.filterReset.forEach(resetBtn => { 1261 resetBtn.addEventListener('click', this.resetFilter.bind(this), { signal: this.signal }); 1262 }) 1263 this.toggleSidebarBtn && this.toggleSidebarBtn.addEventListener('click', this.toggleSidebar.bind(this), { signal: this.signal }); 1264 this.filterLine && window.addEventListener('scroll', this.fixLine.bind(this), { signal: this.signal }); 1265 1266 window.scrollTo(window.scrollX, window.scrollY + 1); 1267 } 1268 1269 resetFilter(e) { 1270 e.preventDefault(); 1271 const delFilter = document.querySelector(`#${this.id.delFilter}`); 1272 delFilter.click(); 1273 } 1274 1275 toggleFilters(e) { 1276 e.preventDefault(); 1277 const isBrandPage = window.location.href.indexOf('/catalog/brands/') >= 0; 1278 1279 if (this.filters==null){ 1280 this.filters = document.querySelector(`[data-${this.dataName.filters}]`); 1281 } 1282 1283 this.filters.classList.toggle(`${this.className.active}`); 1284 if (this.filters.classList.contains(`${this.className.active}`)) { 1285 if (window.innerWidth < 768) { 1286 this.setTopLineZIndex(0); 1287 } else if (window.location.href.indexOf('/brands/') < 0) { 1288 this.filters.classList.toggle(`${this.className.active}`); 1289 this.setTopLineZIndex(492); 1290 } else { 1291 this.setTopLineZIndex(0); 1292 } 1293 document.body.classList.add('catalog-filter-open'); 1294 if (window.innerWidth < 768) this.header.classList.remove('header--white'); 1295 } else { 1296 if (window.location.href.indexOf('/brands/')<0){ 1297 this.filters.classList.toggle(`${this.className.active}`); 1298 1299 if(window.innerWidth < 763){ 1300 this.setTopLineZIndex(-1); 1301 } else { 1302 this.setTopLineZIndex(10); 1303 } 1304 1305 } else { 1306 this.setTopLineZIndex(493); 1307 } 1308 document.body.classList.remove('catalog-filter-open'); 1309 1310 //ÐÑли на ÑÑÑаниÑе бÑенда, Ñо не возвÑаÑаем Ñ ÐµÐ´ÐµÑÑ Ð±ÐµÐ»Ñй ÑÐ²ÐµÑ 1311 if (!isBrandPage && window.scrollY < this.options.offsetForWhiteHeader) this.header.classList.add('header--white'); 1312 } 1313 } 1314 1315 toggleSidebar(e) { 1316 e.currentTarget.classList.toggle(`${this.className.active}`); 1317 this.sidebar && this.sidebar.classList.toggle(`${this.className.active}`); 1318 } 1319 1320 setTopLineZIndex(index) { 1321 this.catalogTopLine.style.zIndex = `${index}`; 1322 } 1323 1324 fixLine() { 1325 if (isMobileCatalog() && isSmartFilterOpen()) { 1326 this.setTopLineZIndex(0); 1327 return; 1328 } 1329 1330 const newScrollY = window.scrollY; 1331 const hasMobileSuggestions = !!this.suggestions?.children.length || screen.width < 763; 1332 1333 if (hasMobileSuggestions && newScrollY - this.lastScrollY < 0) { 1334 this.setTopLineZIndex(2); 1335 } 1336 1337 if (!hasMobileSuggestions && newScrollY - this.lastScrollY > 0 && newScrollY > this.options.offset) { 1338 this.filterLine.classList.add(this.className.fixed) 1339 this.setTopLineZIndex(494); 1340 this.sidebar && this.sidebar.classList.add('sticky'); 1341 } 1342 1343 if (hasMobileSuggestions || newScrollY < this.options.offset) { 1344 this.filterLine.classList.remove(this.className.fixed) 1345 this.sidebar && this.sidebar.classList.remove('sticky'); 1346 } 1347 1348 this.lastScrollY = newScrollY; 1349 } 1350 } 1351
1352 let closeButton = document.querySelector('.smartfilter__close'); 1353 1354 // ÐобавлÑем обÑабоÑÑик ÑобÑÑÐ¸Ñ ÐºÐ»Ð¸ÐºÐ° 1355 closeButton.addEventListener('click', function() { 1356 let hasTouchElement = document.querySelector('.has-touch'); 1357 let catalogTopLine = document.querySelector('.catalog__top-line'); 1358 // УÑÑановиÑÑ overflow в 'auto' пÑи закÑÑÑии ÑилÑÑÑа 1359 if (hasTouchElement) { 1360 hasTouchElement.style.overflow = 'auto'; 1361 } 1362 if (catalogTopLine) { 1363 catalogTopLine.style.zIndex = '496'; 1364 document.body.classList.remove('catalog-filter-open'); 1365 } 1366 // ÐолÑÑаем ÑлеменÑ, коÑоÑÑй Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ ÐºÐ»Ð°ÑÑ 'active' 1367 let smartfilter = document.querySelector('.smartfilter'); 1368 1369 // ÐÑовеÑÑем, еÑÑÑ Ð»Ð¸ клаÑÑ 'active' 1370 if (smartfilter.classList.contains('active')) { 1371 // УдалÑем клаÑÑ 'active', еÑли он пÑиÑÑÑÑÑвÑÐµÑ 1372 smartfilter.classList.remove('active'); 1373 } 1374 }) 1375 1376 /************************************ 1377 * ÐниÑиализаÑÐ¸Ñ ÐºÐ°ÑÑомнÑÑ ÑкÑипÑов * 1378 ************************************/ 1379 1380 let abortController = new AbortController(); 1381 new CatalogFixedLine(undefined, undefined, abortController); 1382 bindSideEvents(abortController); 1383 1384 BX.addCustomEvent("onFrameDataReceived", function () { 1385 abortController.abort(); 1386 1387 abortController = new AbortController(); 1388 new CatalogFixedLine(undefined, undefined, abortController); 1389 bindSideEvents(abortController); 1390 reinitSelects(); 1391 }); 1392} catch (err) { 1393 console.trace(err); 1394} 1395/* End */ 1396; 1397; /* Start:"a:4:{s:4:"full";s:104:"/local/templates/visagehall_new/components/bitrix/catalog.section/.default_new/script.js?177383998022773";s:6:"source";s:88:"/local/templates/visagehall_new/components/bitrix/catalog.section/.default_new/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 1398(function (window) { 1399 if (!!window.JCCatalogProductSubscribe) 1400 { 1401 return; 1402 } 1403 1404 var subscribeButton = function(params) 1405 { 1406 subscribeButton.superclass.constructor.apply(this, arguments); 1407 this.nameNode = BX.create('div', { 1408 props : { id : this.id }, 1409 style: typeof(params.style) === 'object' ? params.style : {}, 1410 text: params.text 1411 }); 1412 this.buttonNode = BX.create('div', { 1413 attrs: { className: params.className }, 1414 dataset: params.dataAttrs, 1415 children: [this.nameNode], 1416 events : this.contextEvents 1417 }); 1418 if (BX.browser.IsIE()) 1419 { 1420 this.buttonNode.setAttribute("hideFocus", "hidefocus"); 1421 } 1422 }; 1423 BX.extend(subscribeButton, BX.PopupWindowButton); 1424 1425 window.JCCatalogProductSubscribe = function(params) 1426 { 1427 this.buttonId = params.buttonId; 1428 this.buttonClass = params.buttonClass; 1429 this.jsObject = params.jsObject; 1430 this.ajaxUrl = '/local/templates/visagehall_new/components/bitrix/catalog.product.subscribe/visagehall/ajax.php'; 1431 this.alreadySubscribed = params.alreadySubscribed; 1432 this.listIdAlreadySubscribed = params.listIdAlreadySubscribed; 1433 this.urlListSubscriptions = params.urlListSubscriptions; 1434 this.listOldItemId = {}; 1435 this.landingId = params.landingId; 1436 this.prodObjId = params.prodObjId; 1437 1438 this.elemButtonSubscribe = null; 1439 this.elemPopupWin = null; 1440 this.defaultButtonClass = 'bx-catalog-subscribe-button'; 1441 1442 this._elemButtonSubscribeClickHandler = BX.delegate(this.subscribe, this); 1443 this._elemButtonUnSubscribeClickHandler = BX.delegate(this.unSubscribe, this); 1444 this._elemHiddenClickHandler = BX.delegate(this.checkSubscribe, this); 1445 1446 BX.ready(BX.delegate(this.init,this)); 1447 }; 1448 1449 window.JCCatalogProductSubscribe.prototype.init = function() 1450 { 1451 if (!!this.buttonId) 1452 { 1453 this.elemButtonSubscribe = BX(this.buttonId); 1454 this.elemHiddenSubscribe = BX(this.buttonId+'_hidden'); 1455 } 1456 1457 if (!!this.elemButtonSubscribe) 1458 { 1459 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler); 1460 } 1461 1462 if (!!this.elemHiddenSubscribe) 1463 { 1464 BX.bind(this.elemHiddenSubscribe, 'click', this._elemHiddenClickHandler); 1465 } 1466 1467 this.setButton(this.alreadySubscribed); 1468 this.setIdAlreadySubscribed(this.listIdAlreadySubscribed); 1469 }; 1470 1471 window.JCCatalogProductSubscribe.prototype.checkSubscribe = function() 1472 { 1473 if(!this.elemHiddenSubscribe || !this.elemButtonSubscribe) return; 1474 1475 if(this.listOldItemId.hasOwnProperty(this.elemButtonSubscribe.dataset.item)) 1476 { 1477 this.setButton(true); 1478 } 1479 else 1480 { 1481 BX.ajax({ 1482 method: 'POST', 1483 dataType: 'json', 1484 url: this.ajaxUrl, 1485 data: { 1486 sessid: BX.bitrix_sessid(), 1487 checkSubscribe: 'Y', 1488 itemId: this.elemButtonSubscribe.dataset.item 1489 }, 1490 onsuccess: BX.delegate(function (result) { 1491 if(result.subscribe) 1492 { 1493 this.setButton(true); 1494 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true; 1495 } 1496 else 1497 { 1498 this.setButton(false); 1499 } 1500 }, this) 1501 }); 1502 } 1503 }; 1504 1505 window.JCCatalogProductSubscribe.prototype.unSubscribe = function() { 1506 this.elemButtonSubscribe = BX.proxy_context; 1507 if(!this.elemButtonSubscribe) return false;
1508 1509 BX.ajax.post( 1510 '/local/ajax/subscribeProduct.php', 1511 { 1512 product_id: this.elemButtonSubscribe.dataset.item, 1513 action: "delete", 1514 }, 1515 (d) => { 1516 d = JSON.parse(d); 1517 if (d.success) { 1518 this.elemButtonSubscribe.className = this.buttonClass + ' ' + this.defaultButtonClass; 1519 this.elemButtonSubscribe.innerHTML = '<span class="btn-style__wrapper"><span class="btn-style__label">' + BX.message('CPST_SUBSCRIBE_BUTTON_NAME') + '</span>'; 1520 BX.unbind(this.elemButtonSubscribe, 'click', this._elemButtonUnSubscribeClickHandler); 1521 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler); 1522 } 1523 } 1524 ); 1525 } 1526 1527 window.JCCatalogProductSubscribe.prototype.subscribe = function() 1528 { 1529 this.elemButtonSubscribe = BX.proxy_context; 1530 if(!this.elemButtonSubscribe) return false; 1531 1532 BX.ajax({ 1533 method: 'POST', 1534 dataType: 'json', 1535 url: this.ajaxUrl, 1536 data: { 1537 sessid: BX.bitrix_sessid(), 1538 subscribe: 'Y', 1539 itemId: this.elemButtonSubscribe.dataset.item, 1540 siteId: BX.message('SITE_ID'), 1541 landingId: this.landingId 1542 }, 1543 onsuccess: BX.delegate(function (result) { 1544 if(result.success) 1545 { 1546 this.createSuccessPopup(result); 1547 this.setButton(true); 1548 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true; 1549 this.prodObjId && window[this.prodObjId].setIdAlreadySubscribed(this.listOldItemId); 1550 } 1551 else if(result.contactFormSubmit) 1552 { 1553 this.initPopupWindow(); 1554 this.elemPopupWin.setTitleBar(BX.message('CPST_SUBSCRIBE_POPUP_TITLE')); 1555 var form = this.createContentForPopup(result); 1556 this.elemPopupWin.setContent(form); 1557 if(this.elemButtonSubscribe && this.elemButtonSubscribe.dataset && this.elemButtonSubscribe.dataset.authorized === 'false'){ 1558 form.appendChild(BX.create('div', { 1559 props: { 1560 className: 'checkbox', 1561 }, 1562 children: [ 1563 BX.create('input', { 1564 props: { 1565 id: `agree_${this.buttonId}`, 1566 className: 'nx-actions__agree-checkbox visually-hidden', 1567 type: 'checkbox', 1568 name: 'agree-product-subscribe', 1569 checked: false 1570 }, 1571 dataset: { 1572 'agreeInput': '' 1573 } 1574 }), 1575 1576 BX.create('label', { 1577 props: { 1578 className: 'nx-actions__agree-label', 1579 }, 1580 attrs: { 1581 'for': `agree_${this.buttonId}`, 1582 }, 1583 html: BX.message('CPST_SUBSCRIBE_LABLE_AGREE'), 1584 events: { 1585 click: function () { 1586 const popup = this.closest('.popup-window'), 1587 agreeInput = popup.querySelector('[data-agree-input]'), 1588 agreeBtn = popup.querySelector('[data-agree-btn]'); 1589 1590 setTimeout(() => { 1591 if(input.value && input.value.trim() !== ''){ 1592 agreeBtn.classList.toggle('disabled', !agreeInput.checked) 1593 } else { 1594 agreeBtn.classList.add('disabled') 1595 } 1596 }, 0) 1597 1598 } 1599 } 1600 }) 1601 ] 1602 1603 })) 1604 } 1605 1606 1607 var popup = form.closest('.popup-window'); 1608 var prodPreview = popup.querySelector('.popup-window-product-preview'); 1609 1610 prodPreview && prodPreview.remove(); 1611 1612 prodPreview = document.createElement('DIV'); 1613 prodPreview.classList.add('popup-window-product-preview'); 1614 1615 var prodPreviewInner = document.createElement('div'); 1616 prodPreviewInner.classList.add('inner'); 1617 1618 var prodPreviewImg = document.createElement('img'); 1619 prodPreviewImg.src = result.itemImage; 1620 1621 prodPreviewInner.appendChild(prodPreviewImg); 1622 prodPreview.appendChild(prodPreviewInner) 1623 1624 popup.insertAdjacentElement('afterbegin', prodPreview); 1625 let input = document.getElementById("userContact"); 1626 1627 this.elemPopupWin.setButtons([ 1628 new subscribeButton({ 1629 text: 'ÐодпиÑаÑÑÑÑ', 1630 className : (function(){ 1631 // var isAuthorized = (this.elemButtonSubscribe && this.elemButtonSubscribe.dataset && this.elemButtonSubscribe.dataset.authorized === 'true'); 1632 return 'btn btn--d-block btn-primary agree-btn disabled'; 1633 }).call(this), 1634 dataAttrs: { 1635 'agreeBtn': '' 1636 }, 1637 events: { 1638 click : BX.delegate(function() { 1639 if(!this.validateContactField(result.contactTypeData)) 1640 { 1641 return false;
1642 } 1643 BX.ajax.submitAjax(form, { 1644 method : 'POST', 1645 url: this.ajaxUrl, 1646 processData : true, 1647 onsuccess: BX.delegate(function (resultForm) { 1648 resultForm = BX.parseJSON(resultForm, {}); 1649 if(resultForm.success) 1650 { 1651 this.createSuccessPopup(resultForm); 1652 this.setButton(true); 1653 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true; 1654 this.prodObjId && window[this.prodObjId].setIdAlreadySubscribed(this.listOldItemId); 1655 } 1656 else if(resultForm.error) 1657 { 1658 if(resultForm.hasOwnProperty('setButton')) 1659 { 1660 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true; 1661 this.setButton(true); 1662 } 1663 var errorMessage = resultForm.message; 1664 if(resultForm.hasOwnProperty('typeName')) 1665 { 1666 errorMessage = resultForm.message.replace('USER_CONTACT', 1667 resultForm.typeName); 1668 } 1669 BX('bx-catalog-subscribe-form-notify').style.color = '#ff2190'; 1670 BX('bx-catalog-subscribe-form-notify').style.textTransform = 'uppercase'; 1671 BX('bx-catalog-subscribe-form-notify').style.fontSize = '10px'; 1672 BX('bx-catalog-subscribe-form-notify').innerHTML = errorMessage; 1673 } 1674 }, this) 1675 }); 1676 }, this) 1677 } 1678 }), 1679 ]); 1680 this.elemPopupWin.show(); 1681 var emailInput = BX('userContact'); 1682 if (emailInput) { 1683 var self = this; 1684 var handler = function(){ self.validateEmailAndUpdateButton(); }; 1685 BX.bind(emailInput, 'input', handler); 1686 BX.bind(emailInput, 'change', handler); 1687 self.validateEmailAndUpdateButton(); 1688 } 1689 } 1690 else if(result.error) 1691 { 1692 if(result.hasOwnProperty('setButton')) 1693 { 1694 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true; 1695 this.setButton(true); 1696 } 1697 this.showWindowWithAnswer({status: 'error', message: result.message}); 1698 } 1699 }, this) 1700 }); 1701 }; 1702 1703 window.JCCatalogProductSubscribe.prototype.validateEmailAndUpdateButton = function() 1704 { 1705 var emailInput = BX('userContact'); 1706 var popup = emailInput ? emailInput.closest('.popup-window') : null; 1707 var agreeBtn = popup ? popup.querySelector('.agree-btn') : null; 1708 1709 if (!emailInput || !popup || !agreeBtn) return; 1710 1711 var email = emailInput.value.trim(); 1712 var isEmailValid = email.length > 0 && email.includes('@'); 1713 1714 // For unauthorized users, also check checkbox 1715 if (this.elemButtonSubscribe && this.elemButtonSubscribe.dataset && this.elemButtonSubscribe.dataset.authorized === 'false') { 1716 var agreeInput = popup.querySelector('[data-agree-input]'); 1717 var isAgreed = agreeInput ? agreeInput.checked : false; 1718 agreeBtn.classList.toggle('disabled', !isEmailValid || !isAgreed); 1719 } else { 1720 // For authorized users, only check email 1721 agreeBtn.classList.toggle('disabled', !isEmailValid); 1722 } 1723 }; 1724 1725 window.JCCatalogProductSubscribe.prototype.validateContactField = function(contactTypeData) 1726 { 1727 var inputFields = BX.findChildren(BX('bx-catalog-subscribe-form'), 1728 {'tag': 'input', 'attribute': {id: 'userContact'}}, true); 1729 if(!inputFields.length || typeof contactTypeData !== 'object') 1730 { 1731 BX('bx-catalog-subscribe-form-notify').style.color = '#ff2190'; 1732 BX('bx-catalog-subscribe-form-notify').style.textTransform = 'uppercase'; 1733 BX('bx-catalog-subscribe-form-notify').style.fontSize = '10px'; 1734 BX('bx-catalog-subscribe-form-notify').innerHTML = BX.message('CPST_SUBSCRIBE_VALIDATE_UNKNOW_ERROR'); 1735 return false; 1736 } 1737 1738 var contactTypeId, contactValue, useContact, errors = [], useContactErrors = []; 1739 for(var k = 0; k < inputFields.length; k++) 1740 { 1741 contactTypeId = inputFields[k].getAttribute('data-id'); 1742 contactValue = inputFields[k].value; 1743 useContact = BX('bx-contact-use-'+contactTypeId); 1744 if(useContact && useContact.value == 'N') 1745 { 1746 useContactErrors.push(true); 1747 continue; 1748 } 1749 if(!contactValue.length) 1750 { 1751 errors.push(BX.message('CPST_SUBSCRIBE_VALIDATE_ERROR_EMPTY_FIELD').replace( 1752 '#FIELD#', contactTypeData[contactTypeId].contactLable)); 1753 } 1754 } 1755 1756 if(inputFields.length == useContactErrors.length) 1757 { 1758 BX('bx-catalog-subscribe-form-notify').style.color = '#ff2190'; 1759 BX('bx-catalog-subscribe-form-notify').style.textTransform = 'uppercase'; 1760 BX('bx-catalog-subscribe-form-notify').style.fontSize = '10px'; 1761 BX('bx-catalog-subscribe-form-notify').innerHTML = BX.message('CPST_SUBSCRIBE_VALIDATE_ERROR'); 1762 return false;
1763 } 1764 1765 if(errors.length) 1766 { 1767 BX('bx-catalog-subscribe-form-notify').style.color = '#ff2190'; 1768 BX('bx-catalog-subscribe-form-notify').style.textTransform = 'uppercase'; 1769 BX('bx-catalog-subscribe-form-notify').style.fontSize = '10px'; 1770 1771 for(var i = 0; i < errors.length; i++) 1772 { 1773 BX('bx-catalog-subscribe-form-notify').innerHTML = errors[i]; 1774 } 1775 return false; 1776 } 1777 1778 return true; 1779 }; 1780 1781 window.JCCatalogProductSubscribe.prototype.reloadCaptcha = function() 1782 { 1783 BX.ajax.get(this.ajaxUrl+'?reloadCaptcha=Y', '', function(captchaCode) { 1784 BX('captcha_sid').value = captchaCode; 1785 BX('captcha_img').src = '/bitrix/tools/captcha.php?captcha_sid='+captchaCode+''; 1786 }); 1787 }; 1788 1789 window.JCCatalogProductSubscribe.prototype.createContentForPopup = function(responseData) 1790 { 1791 if(!responseData.hasOwnProperty('contactTypeData')) 1792 { 1793 return null; 1794 } 1795 1796 var contactTypeData = responseData.contactTypeData, contactCount = Object.keys(contactTypeData).length, 1797 styleInputForm = '', manyContact = 'N', content = document.createDocumentFragment(); 1798 1799 for(var k in contactTypeData) 1800 { 1801 /** ÐодпиÑка ÑÑÑого по Email */ 1802 if (contactTypeData[k].contactId === 1) { 1803 content.appendChild(BX.create('div', { 1804 props: { 1805 id: 'bx-catalog-subscribe-form-container-' + k, 1806 className: 'bx-catalog-subscribe-form-container', 1807 style: styleInputForm 1808 }, 1809 children: [ 1810 BX.create('div', { 1811 props: { 1812 className: 'bx-catalog-subscribe-form-container-label' 1813 }, 1814 text: BX.message('CPST_SUBSCRIBE_LABLE_CONTACT_INPUT').replace( 1815 '#CONTACT#', contactTypeData[k].contactLable) 1816 }), 1817 BX.create('label', { 1818 props: { 1819 className: `nx-dynamic-label ${responseData.contactTypeData[k].email ? 'focused' : ' '}` 1820 }, 1821 attrs: { 1822 'data-dynamic-label': 'true' 1823 }, 1824 children: [ 1825 BX.create('input', { 1826 props: { 1827 id: 'userContact', 1828 className: 'nx-dynamic-label__input nx-form-element', 1829 type: 'text', 1830 name: 'contact[' + k + '][user]', 1831 value: responseData.contactTypeData[k].email, 1832 }, 1833 attrs: { 1834 'data-id': k, 1835 'data-dynamic-inp': 'true' 1836 } 1837 }), 1838 BX.create('span', { 1839 props: { 1840 className: 'nx-dynamic-label__text' 1841 }, 1842 text: contactTypeData[k].contactLable 1843 }) 1844 ] 1845 }) 1846 ] 1847 })); 1848 } 1849 } 1850 1851 content.appendChild(BX.create('p', { 1852 props: {id: 'bx-catalog-subscribe-form-notify', className: 'bx-catalog-subscribe-form-notify'} 1853 })); 1854 1855 if(responseData.hasOwnProperty('captchaCode')) 1856 { 1857 content.appendChild(BX.create('div', { 1858 props: { 1859 className: 'bx-catalog-subscribe-form-container' 1860 }, 1861 children: [ 1862 BX.create('span', {props: {className: 'bx-catalog-subscribe-form-star-required'}, text: '*'}), 1863 BX.message('CPST_ENTER_WORD_PICTURE'), 1864 BX.create('div', { 1865 props: {className: 'bx-captcha'}, 1866 children: [ 1867 BX.create('input', { 1868 props: { 1869 type: 'hidden', 1870 id: 'captcha_sid', 1871 name: 'captcha_sid', 1872 value: responseData.captchaCode 1873 } 1874 }), 1875 BX.create('img', { 1876 props: { 1877 id: 'captcha_img', 1878 src: '/bitrix/tools/captcha.php?captcha_sid='+responseData.captchaCode+'' 1879 }, 1880 attrs: { 1881 width: '180', 1882 height: '40', 1883 alt: 'captcha', 1884 onclick: this.jsObject+'.reloadCaptcha();' 1885 } 1886 }) 1887 ] 1888 }), 1889 BX.create('div', { 1890 props: {className: 'bx-catalog-subscribe-form-container-input'}, 1891 children: [ 1892 BX.create('input', { 1893 props: { 1894 id: 'captcha_word', 1895 className: '', 1896 type: 'text', 1897 name: 'captcha_word' 1898 }, 1899 attrs: {maxlength: '50'} 1900 }) 1901 ] 1902 }) 1903 ] 1904 })); 1905 } 1906 var form = BX.create('form', { 1907 props: { 1908 id: 'bx-catalog-subscribe-form' 1909 }, 1910 children: [ 1911 BX.create('input', { 1912 props: { 1913 type: 'hidden', 1914 name: 'manyContact', 1915 value: manyContact 1916 } 1917 }), 1918 BX.create('input', { 1919 props: { 1920 type: 'hidden', 1921 name: 'sessid', 1922 value: BX.bitrix_sessid() 1923 } 1924 }), 1925 BX.create('input', { 1926 props: { 1927 type: 'hidden', 1928 name: 'itemId', 1929 value: this.elemButtonSubscribe.dataset.item 1930 } 1931 }), 1932 BX.create('input', { 1933 props: { 1934 type: 'hidden', 1935 name: 'landingId', 1936 value: this.landingId 1937 } 1938 }), 1939 BX.create('input', { 1940 props: { 1941 type: 'hidden', 1942 name: 'siteId', 1943 value: BX.message('SITE_ID') 1944 } 1945 }), 1946 BX.create('input', { 1947 props: { 1948 type: 'hidden', 1949 name: 'contactFormSubmit', 1950 value: 'Y' 1951 } 1952 }) 1953 ] 1954 }); 1955 1956 form.appendChild(content); 1957 1958 return form; 1959 }; 1960 1961 window.JCCatalogProductSubscribe.prototype.selectContactType = function(contactTypeId, event) 1962 { 1963 var contactInput = BX('bx-catalog-subscribe-form-container-'+contactTypeId), visibility = '', 1964 checkboxInput = BX('bx-contact-checkbox-'+contactTypeId); 1965 if(!contactInput) 1966 { 1967 return false;
1968 } 1969 1970 if(checkboxInput != event.target) 1971 { 1972 if(checkboxInput.checked) 1973 { 1974 checkboxInput.checked = false; 1975 } 1976 else 1977 { 1978 checkboxInput.checked = true; 1979 } 1980 } 1981 1982 if (contactInput.currentStyle) 1983 { 1984 visibility = contactInput.currentStyle.display; 1985 } 1986 else if (window.getComputedStyle) 1987 { 1988 var computedStyle = window.getComputedStyle(contactInput, null); 1989 visibility = computedStyle.getPropertyValue('display'); 1990 } 1991 1992 if(visibility === 'none') 1993 { 1994 BX('bx-contact-use-'+contactTypeId).value = 'Y'; 1995 BX.style(contactInput, 'display', ''); 1996 } 1997 else 1998 { 1999 BX('bx-contact-use-'+contactTypeId).value = 'N'; 2000 BX.style(contactInput, 'display', 'none'); 2001 } 2002 }; 2003 2004 window.JCCatalogProductSubscribe.prototype.createSuccessPopup = function(result) 2005 { 2006 this.initPopupWindow(); 2007 this.elemPopupWin.setTitleBar(BX.message('CPST_SUBSCRIBE_SUCCESS_POPUP_TITLE')); 2008 var content = BX.create('div', { 2009 props:{ 2010 className: 'bx-catalog-popup-content' 2011 }, 2012 children: [ 2013 BX.create('p', { 2014 props: { 2015 className: 'bx-catalog-popup-message' 2016 }, 2017 text: result.message 2018 }) 2019 ] 2020 }); 2021 this.elemPopupWin.setContent(content); 2022 this.elemPopupWin.setButtons([ 2023 new subscribeButton({ 2024 text : BX.message('CPST_SUBSCRIBE_SUCCESS_BUTTON_CLOSE'), 2025 className : 'btn btn-primary btn--d-block', 2026 events : { 2027 click : BX.delegate(function() { 2028 this.elemPopupWin.destroy(); 2029 }, this) 2030 } 2031 }) 2032 ]); 2033 this.elemPopupWin.show(); 2034 }; 2035 2036 window.JCCatalogProductSubscribe.prototype.initPopupWindow = function() 2037 { 2038 this.elemPopupWin = BX.PopupWindowManager.create('CatalogSubscribe_'+this.buttonId, null, { 2039 autoHide: true, 2040 overlay : true, 2041 closeByEsc: true, 2042 titleBar: true, 2043 closeIcon: true, 2044 contentColor: 'white', 2045 className: "subscribe__popup closed", 2046 events: { 2047 onPopupShow: function() { 2048 setTimeout(() => { 2049 this.popupContainer.classList.remove('closed') 2050 this.overlay.element.classList.add('visible') 2051 }, 0) 2052 }, 2053 onPopupClose: function() { 2054 // СобÑÑие пÑи закÑÑÑии окна 2055 this.popupContainer.classList.add('closed') 2056 this.overlay.element.classList.remove('visible') 2057 } 2058 } 2059 }); 2060 }; 2061 2062 window.JCCatalogProductSubscribe.prototype.setButton = function(statusSubscription) 2063 { 2064 this.alreadySubscribed = Boolean(statusSubscription); 2065 if(this.alreadySubscribed) 2066 { 2067 this.elemButtonSubscribe.className = this.buttonClass + ' ' + this.defaultButtonClass; 2068 BX.unbind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler); 2069 2070 if (this.elemButtonSubscribe.dataset.authorized === 'true') { 2071 this.elemButtonSubscribe.innerHTML = '<span class="btn-style__wrapper"><span class="btn-style__label">' + BX.message('CPST_TITLE_ALREADY_SUBSCRIBED') + '</span></span>'; 2072 2073 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonUnSubscribeClickHandler); 2074 } else { 2075 this.elemButtonSubscribe.classList.add('btn', 'btn--transparent', 'disabled'); 2076 this.elemButtonSubscribe.innerHTML = '<span class="btn-style__wrapper"><span class="btn-style__label">' + 'ÐÑ Ð¿Ð¾Ð´Ð¿Ð¸ÑанÑ' + '</span></span>'; 2077 } 2078 } 2079 else 2080 { 2081 this.elemButtonSubscribe.className = this.buttonClass + ' ' + this.defaultButtonClass; 2082 this.elemButtonSubscribe.innerHTML = '<span class="btn-style__wrapper"><span class="btn-style__label">' + BX.message('CPST_SUBSCRIBE_BUTTON_NAME') + '</span>'; 2083 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler); 2084 } 2085 }; 2086 2087 window.JCCatalogProductSubscribe.prototype.setIdAlreadySubscribed = function(listIdAlreadySubscribed) 2088 { 2089 if (BX.type.isPlainObject(listIdAlreadySubscribed)) 2090 { 2091 this.listOldItemId = listIdAlreadySubscribed; 2092 } 2093 }; 2094 2095 window.JCCatalogProductSubscribe.prototype.showWindowWithAnswer = function(answer) 2096 { 2097 answer = answer || {}; 2098 if (!answer.message) { 2099 if (answer.status == 'success') { 2100 answer.message = BX.message('CPST_STATUS_SUCCESS'); 2101 } else { 2102 answer.message = BX.message('CPST_STATUS_ERROR'); 2103 } 2104 } 2105 var messageBox = BX.create('div', { 2106 props: { 2107 className: 'bx-catalog-subscribe-alert' 2108 }, 2109 children: [ 2110 BX.create('span', { 2111 props: { 2112 className: 'bx-catalog-subscribe-aligner' 2113 } 2114 }), 2115 BX.create('span', { 2116 props: { 2117 className: 'bx-catalog-subscribe-alert-text' 2118 }, 2119 text: answer.message 2120 }), 2121 BX.create('div', { 2122 props: { 2123 className: 'bx-catalog-subscribe-alert-footer' 2124 } 2125 }) 2126 ] 2127 }); 2128 var currentPopup = BX.PopupWindowManager.getCurrentPopup(); 2129 if(currentPopup) { 2130 currentPopup.destroy(); 2131 } 2132 var idTimeout = setTimeout(function () { 2133 var w = BX.PopupWindowManager.getCurrentPopup(); 2134 if (!w || w.uniquePopupId != 'bx-catalog-subscribe-status-action') { 2135 return; 2136 } 2137 w.close(); 2138 w.destroy(); 2139 }, 3500); 2140 var popupConfirm = BX.PopupWindowManager.create('bx-catalog-subscribe-status-action', null, {
2141 content: messageBox, 2142 onPopupClose: function () { 2143 this.destroy(); 2144 clearTimeout(idTimeout); 2145 }, 2146 autoHide: true, 2147 zIndex: 2000, 2148 className: 'bx-catalog-subscribe-alert-popup' 2149 }); 2150 popupConfirm.show(); 2151 BX('bx-catalog-subscribe-status-action').onmouseover = function (e) { 2152 clearTimeout(idTimeout); 2153 }; 2154 BX('bx-catalog-subscribe-status-action').onmouseout = function (e) { 2155 idTimeout = setTimeout(function () { 2156 var w = BX.PopupWindowManager.getCurrentPopup(); 2157 if (!w || w.uniquePopupId != 'bx-catalog-subscribe-status-action') { 2158 return; 2159 } 2160 w.close(); 2161 w.destroy(); 2162 }, 3500); 2163 }; 2164 }; 2165 2166})(window); 2167 2168 2169 2170 2171/* End */ 2172; 2173; /* Start:"a:4:{s:4:"full";s:99:"/local/templates/visagehall_new/components/bitrix/catalog.item/.default_new/script.js?1729602624752";s:6:"source";s:85:"/local/templates/visagehall_new/components/bitrix/catalog.item/.default_new/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 2174function buttonClick(itemId) { 2175 var images = document.querySelectorAll("#image_" + itemId); 2176 images.forEach(function(image) { 2177 image.classList.toggle("img2"); 2178 image.classList.remove("img_hover"); 2179 }); 2180 var advertisingInfos = document.querySelectorAll(".adrevtising_info-" + itemId); 2181 advertisingInfos.forEach(function(advertisingInfo) { 2182 advertisingInfo.classList.toggle("teg_pop_up"); 2183 }); 2184 setTimeout(function() { 2185 advertisingInfos.forEach(function(advertisingInfo) { 2186 advertisingInfo.classList.remove("teg_pop_up"); 2187 }); 2188 images.forEach(function(image) { 2189 image.classList.add("img_hover"); 2190 image.classList.remove("img2"); 2191 }); 2192 }, 5000); 2193} 2194 2195 2196/* End */ 2197;; /* /local/templates/visagehall_new/components/bitrix/catalog.smart.filter/.default_new/script.js?178937032652341*/ 2198; /* /local/templates/visagehall_new/components/bitrix/catalog.section/.default_new/script.js?177383998022773*/ 2199; /* /local/templates/visagehall_new/components/bitrix/catalog.item/.default_new/script.js?1729602624752*/
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.