4501if (buttons) buttons.style.width = null;4502col.style.width = null;4503} else {4504col.style.width = null;4505}4506}4507});45084509Array.prototype.forEach.call(items, function (item) {4510var col = item.querySelector('.t-catalog__card__price-buttons');4511if (col) {4512if (col.classList.contains('t-catalog__card__price-buttons_in-row')) {
var price = col.querySelector('.t-catalog__card__price-wrapper'); var buttons = col.querySelector('.t-catalog__card__btns-wrapper'); if (price) { var priceStyle = window.getComputedStyle(price); var priceWidth = Math.ceil(parseFloat(priceStyle.width)) + Math.ceil(parseFloat(priceStyle.marginRight)); if (priceWidth > maxPriceWidth) maxPriceWidth = priceWidth; } if (buttons) { var buttonsWidth = Math.ceil(parseFloat(window.getComputedStyle(buttons).width)); if (buttonsWidth > maxButtonsWidth) maxButtonsWidth = buttonsWidth; } } else { var curWidth = Math.ceil(parseFloat(window.getComputedStyle(col).width)); if (curWidth > maxWidth) maxWidth = curWidth; } } }); Array.prototype.forEach.call(items, function (item) { var col = item.querySelector('.t-catalog__card__price-buttons'); if (col) { if (col.classList.contains('t-catalog__card__price-buttons_in-row')) { var price = col.querySelector('.t-catalog__card__price-wrapper'); var buttons = col.querySelector('.t-catalog__card__btns-wrapper'); if (price) price.style.width = maxPriceWidth + 'px'; if (buttons) buttons.style.width = maxButtonsWidth + 'px'; var gap = 0; // ST-2522: gap есть только у карточки из нового шаблона. На старой строке computed gap часто "normal". if (price && buttons && item.classList.contains('t-catalog__card_from-template')) { var parsedGap = parseFloat(window.getComputedStyle(col).gap); if (!isNaN(parsedGap)) gap = Math.ceil(parsedGap); } col.style.width = maxPriceWidth + maxButtonsWidth + gap + 'px'; } else { col.style.width = maxWidth + 'px'; } } });}/** * Проверяет, имеет ли текущий URL шаблон блока продуктов * @param {string} url - URL для проверки * @returns {string|undefined} - Найденный шаблон или undefined, если не найдено */function t_catalog__findBlockProductPatternInUrl(url) { // TODO АЛИАС: При вклюении алиасов тут необходимы доработки // ST-1536 Алиасы в каталоге https://yt.tilda.team/issue/ST-1536/Aliasy-v-kataloge if (!url) return undefined; return T_CATALOG_TPRODUCT_PATTERNS.find(pattern => url.indexOf(pattern) !== -1);}/** * Initialize the popup for the product * * @param {string} recid * @param {object} obj_products - The products that are shown in the popup. * @param {CatalogOptions} options * @param {boolean} isRelevantsShow * @param {object} obj **/function t_catalog_initPopup(recid, obj_products, options, isRelevantsShow, obj) { if (!isRelevantsShow) { t_catalog__setInitialUrl(true); } var isSnippet = document.getElementById('allrecords') !== document.querySelector('.t-catalog__product-snippet') && // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538) // @ts-expect-error ST-2949_3 document.getElementById('allrecords').contains(document.querySelector('.t-catalog__product-snippet')); var rec = document.getElementById('rec' + recid); for (var productKey in obj_products) { var productNode = isRelevantsShow ? // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538) // @ts-expect-error ST-2949_3 rec.querySelector('.js-product-relevant[data-product-gen-uid="' + productKey + '"]') : // @ts-expect-error ST-2949_3 rec.querySelector('[data-product-gen-uid="' + productKey + '"]'); if (!productNode) { continue; } // Replace #prodpopup to absolute link var prodPopups = productNode.querySelectorAll('[href^="#prodpopup"]'); Array.prototype.forEach.call(prodPopups, function (prodpopup) {