201function t_textClamp__reset(recid, textSelector) {202var rec = document.getElementById('rec' + recid);203if (!rec) return;204205var texts = rec.querySelectorAll(textSelector);206texts.forEach(function (textEl) {207if (!textEl.getAttribute('data-clamp-init')) return;208209textEl.removeAttribute('data-clamp-init');210211var innerDiv = textEl.querySelector('.t-text-clamp__inner');212
if (innerDiv) { textEl.innerHTML = innerDiv.innerHTML; innerDiv.parentElement && innerDiv.parentElement.removeChild(innerDiv); } var btn = textEl.querySelector('.t-text-clamp__btn'); if (btn && btn.parentElement) { btn.parentElement.removeChild(btn); } }); t_textClamp__updateHeight(recid);}/** * Обновляет количество свернутых строк, если элемент не был раскрыт * @param {string} recid * @param {number | string} linesCount новое количество строк, которое нужно обрезать * @param {string} textSelector селектор текста, который будет обрезан */function t_textClamp__updateClampLines(recid, linesCount, textSelector) { const rec = document.getElementById('rec' + recid); if (!rec) return; var texts = rec.querySelectorAll(textSelector); texts.forEach(function (textEl) { const innerDiv = textEl.querySelector('.t-text-clamp__inner'); if (!innerDiv) return; const isExpanded = innerDiv.getAttribute('data-expanded'); if (isExpanded) return; // сначала сбрасываем значение, чтобы кол-во строк всегда обновлялось корректно innerDiv.style.webkitLineClamp = ''; innerDiv.style.webkitLineClamp = linesCount; });}/** * Обновление высоты слайдера и/или обложки при обновленнии текста * @param {string} recid */function t_textClamp__updateHeight(recid) { var rec = document.getElementById('rec' + recid); if (!rec) return; // Получаем tplId блока // Если есть атрибут data-alias-record-type, то берем его, т.к. он является tplId копируемого блока для блока T213 Alias var tplId = rec.getAttribute('data-alias-record-type') || rec.getAttribute('data-parenttplid') || rec.getAttribute('data-record-type'); var container = rec.querySelector('.t' + tplId); // Пересчитываем высоту слайдерв if (rec.querySelector('.t-slds')) { t_onFuncLoad('t_slds_SliderHeight', function () { t_slds_SliderHeight(recid); }); } // Пересчитываем высоту блока обложки if (rec.querySelector('.t-cover')) { t_onFuncLoad('t_cover__recalcContentHeight', function () { t_cover__recalcContentHeight(recid, false, 0); }); } // Пересчитываем высоту шага квиз if (rec.querySelector('.t-quiz')) { t_onFuncLoad('t_quiz__adjustStepToHeight', function () { t_quiz__adjustStepToHeight({ rec }); }); } // Перерасчитываем высоту для блоков if (container && typeof t_triggerEvent === 'function') { t_triggerEvent(container, 'tildaclamp:update'); }}