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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-catalog-1.2.js

Код файла
Версия от 05.12.2026, 07:01:02 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
5401		// @ts-expect-error ST-2949_55402		storeProduct.setAttribute('data-product-pack-y', pack_y);5403		// @ts-expect-error ST-2949_55404		storeProduct.setAttribute('data-product-pack-z', pack_z);5405		storeProduct.setAttribute('data-product-url', productUrl);5406	}5407}5408 5409/**5410 * Adding the product options to the product5411 *5412 * @param {string} recid
История файла и сравнение версий
  • 05.12.2026, 07:01:02 · 56c3b845
5413 * @param {object} product - options of product
5414 * @param {HTMLElement} productElement - the product element
5415 * @param {CatalogOptions} options
5416 **/
5417function t_catalog_addProductOptions(recid, product, productElement, options) {
5418 var el_product = productElement;
5419 // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592)
5420 // @ts-expect-error ST-2949_4
5421 if (window.jQuery && el_product instanceof jQuery) {
5422 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
5423 // @ts-expect-error ST-2949_1
5424 if (el_product.length === 0) {
5425 return;
5426 }
5427 // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
5428 // @ts-expect-error ST-2949_2
5429 el_product = el_product[0];
5430 }
5431
5432 var optionsWrapper = el_product.querySelector('.js-product-controls-wrapper');
5433 if (!optionsWrapper) return;
5434 optionsWrapper.querySelectorAll('.js-product-editions-wrapper, .js-product-options-wrapper').forEach(widgetContainer => {
5435 if (widgetContainer instanceof HTMLElement) t_catalog_unmountComponent(widgetContainer);
5436 });
5437 optionsWrapper.innerHTML = '';
5438 /*
5439 product edition — is a combination of parameters with separate quantity and price
5440 example: "Blue XS T-Shirt"
5441 */
5442 t_catalog_product__initEditionsWidget(recid, product, el_product, options);
5443 t_catalog_product__initOptionsWidget(product, el_product, options);
5444}
5445
5446/**
5447 * Инициализирует options widget в обертке опций товара.
5448 *
5449 * @param {object} product
5450 * @param {HTMLElement} productEl
5451 * @param {CatalogOptions} options
5452 */
5453function t_catalog_product__initOptionsWidget(product, productEl, options) {
5454 const productControlsWrapper = productEl.querySelector('.js-product-controls-wrapper');
5455 if (!productControlsWrapper) return;
5456
5457 // Без модификаторов не монтируем пустой shell — иначе :has(*) даёт padding-top на t-catalog__card__prod-controls-wrapper
5458 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
5459 // @ts-expect-error ST-2949_1
5460 if (!product.properties || !product.properties.length) {
5461 // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592)
5462 // @ts-expect-error ST-2949_4
5463 t_prod__updatePrice(productEl, options);
5464 return;
5465 }
5466
5467 const optionsWidgetWrapper = document.createElement('div');
5468 optionsWidgetWrapper.classList.add('js-product-options-wrapper');
5469 productControlsWrapper.appendChild(optionsWidgetWrapper);
5470
5471 const optionsState = t_catalog_createOptionsState({
5472 product,
5473 onChange: () => {
5474 // Пересчет цены с учетом опций.
5475 // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592)
5476 // @ts-expect-error ST-2949_4
5477 t_prod__updatePrice(productEl, options);
5478 },
5479 });
5480 t_catalog_mountComponent(t_catalog_OptionsWidget, optionsWidgetWrapper, { state: optionsState });
5481
5482 // @ts-expect-error ST-2949_4
5483 t_prod__updatePrice(productEl, options);
5484}
5485
5486/**
5487 * Returns the color value for a given option value.
5488 *
5489 * @param {Object} valuesObj - An object containing option values and their corresponding colors.
5490 * @param {string} value - The option value to get the color for.
5491 * @return {string} - The color value for the given option value.
5492 */
5493function t_catalog_option_getColorValue(valuesObj, value) {
5494 var result = '#ffffff';
5495
5496 for (var key in valuesObj) {
5497 // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
5498 // @ts-expect-error ST-2949_2
5499 var item = valuesObj[key];
5500 if (!item || item.value == null) continue;
Предыдущие 100 строкСледующие 100 строк