Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-catalog-1.2.js

Код файла
Версия от 05.12.2026, 07:01:02 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1101function t_catalog_createСssStyleTag(styleId, css) {1102	let styleEl = document.getElementById(styleId);1103	if (!styleEl) {1104		styleEl = document.createElement('style');1105		styleEl.id = styleId;1106		(document.head || document.documentElement).appendChild(styleEl);1107	}1108 1109	// TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)1110	// @ts-expect-error ST-2949_11111	if (styleEl.styleSheet) {1112
История файла и сравнение версий
  • 05.12.2026, 07:01:02 · 56c3b845
// @ts-expect-error ST-2949_1
1113 styleEl.styleSheet.cssText = css;
1114 } else {
1115 styleEl.textContent = css;
1116 }
1117}
1118
1119/**
1120 * Применяет стили к кнопке сниппета
1121 * @param {string} recid
1122 * @param {Object} options
1123 */
1124function t_catalog_applyButtonStyles(recid, options) {
1125 try {
1126 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1127 // @ts-expect-error ST-2949_1
1128 if (!options || !options.button_styles) return;
1129
1130 const button = t_catalog_getSnippetMainButton(recid);
1131
1132 if (button) {
1133 const isReplaced = button.classList.contains('t_catalog__prod-popup__btn-replaced');
1134 button.removeAttribute('style'); // очищаем инлайновые стили с бэкенда
1135 if (isReplaced) {
1136 // кнопка не должна показываться, если она заменена на notify кнопку
1137 button.style.display = 'none';
1138 }
1139 t_catalog_applyButtonClasses(button);
1140 }
1141
1142 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
1143 // @ts-expect-error ST-2949_5
1144 let css = t_catalog_createButtonStyleCss(
1145 recid,
1146 '.t-catalog__prod-popup__btn-wrapper .t-catalog__prod-popup__btn',
1147 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1148 // @ts-expect-error ST-2949_1
1149 options.button_styles
1150 );
1151
1152 // @ts-expect-error ST-2949_1
1153 if (options.showRelevants) {
1154 css += t_catalog_createButtonStyleCss(
1155 recid,
1156 '.t-catalog__relevants__container .t-catalog__card__btn:not(.t-catalog__card__btn_second)',
1157 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1158 // @ts-expect-error ST-2949_1
1159 options.button_styles,
1160 ['padding']
1161 );
1162
1163 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1164 // @ts-expect-error ST-2949_1
1165 if (options.button2_styles) {
1166 css += t_catalog_createButtonStyleCss(
1167 recid,
1168 '.t-catalog__relevants__container .t-catalog__card__btn_second',
1169 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1170 // @ts-expect-error ST-2949_1
1171 options.button2_styles,
1172 ['padding']
1173 );
1174 }
1175 }
1176
1177 t_catalog_createСssStyleTag('js-catalog-btn-styles-' + recid, css);
1178
1179 if (button?.parentNode) {
1180 // Показываем кнопку, когда стили готовы
1181 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1182 // @ts-expect-error ST-2949_1
1183 button.parentNode.style.opacity = 1;
1184 return;
1185 }
1186
1187 const buttonWrapper = document.querySelector('.t-catalog__product-snippet .t-catalog__prod-popup__btn-wrapper');
1188
1189 if (!buttonWrapper) {
1190 return;
1191 }
1192
1193 // скрываем блок полностью так как нет кнопки в попапе
1194 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
1195 // @ts-expect-error ST-2949_1
1196 buttonWrapper.style.display = 'none';
1197 } catch (error) {
1198 console.error('Ошибка при применениии стилей к кнопке (refactored): ' + error);
1199 }
1200}
Предыдущие 100 строкСледующие 100 строк