8201}8202}8203if (fullWeight) {8204Array.prototype.forEach.call(el_tabCharcs, function (tabCharc) {8205var storeProdWeight = tabCharc.querySelector('.js-catalog-prod-weight');8206if (storeProdWeight) {8207storeProdWeight.innerHTML = fullWeight;8208}8209});8210}8211} catch (e) {8212console.error(e);
} } // change edition img // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 if (edition.img) { // @ts-expect-error ST-2949_1 el_product.setAttribute('data-product-img', edition.img); // move slider if (el_product.getAttribute('data-card-size') === 'large') { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 t_catalog_product_updateEdition_moveSlider(recid, el_product, edition); } else if (isChanged) { // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 t_catalog_get_productCard_img_replaceWith(product, el_product, options, edition.img); } } else { // move slider to default image, if previus edition had cutomized image (and filled attribute data-product-img) var prevEditionImgUrl = el_product.getAttribute('data-product-img'); if (prevEditionImgUrl && el_product.getAttribute('data-card-size') === 'large') { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 t_catalog_product_updateEdition_moveSlider(recid, el_product, edition); el_product.setAttribute('data-product-img', ''); } } // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 if (product.unit && product.portion > 0) { // unit // @ts-expect-error ST-2949_1 el_product.setAttribute('data-product-unit', product.unit); // portion // @ts-expect-error ST-2949_1 el_product.setAttribute('data-product-portion', product.portion); // single // @ts-expect-error ST-2949_1 el_product.setAttribute('data-product-single', product.single); } else { el_product.removeAttribute('data-product-unit'); el_product.removeAttribute('data-product-portion'); el_product.removeAttribute('data-product-single'); }}/** * Обновляет положение слайдера товара на основе выбранного варианта товара * ! Смена слайда может вызываться из товаров, у которых нет слайдера * * @param {string} recid - ID записи * @param {HTMLElement} el_product - Элемент товара * @param {CatalogProductEdition} edition - Поля варианта товара */function t_catalog_product_updateEdition_moveSlider(recid, el_product, edition) { if (!el_product || !edition || !edition.img) return; var sliderWrapper = el_product.querySelector('.t-slds__items-wrapper'); if (!sliderWrapper) return; var sliderPosition = 1; // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 var totalSlides = parseInt(sliderWrapper.getAttribute('data-slider-totalslides'), 10); var editionImageUrl = edition.img.replace(/&/g, '&'); var slideEls = Array.from(el_product.querySelectorAll('.t-slds__item')); // находим слайд с изображением var editionSlide = slideEls.find(function (sliderEl) { var index = parseInt(sliderEl.getAttribute('data-slide-index') || '', 10); // нулевой и последний слайды нужны лишь для анимации переходов в слайдере if (index === 0 || index === totalSlides + 1) return null; return sliderEl.querySelector('.t-slds__bgimg[data-original="' + editionImageUrl + '"]'); }); // по умолчанию ссылка на изображение содержит домен .com // если нет .com, то ищем по другим доменам: // .pub, .ink, .pro, .biz, .net, .one, .info и др. if (!editionSlide && editionImageUrl.includes('.com')) { const imgPathName = (function () { try {