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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-catalog-1.2.js

Код файла
Версия от 05.12.2026, 07:01:02 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
4801}4802 4803/**4804 * Монтирует quantity widget.4805 * Учитывает настройки показа, наличие кнопки заказа и остаток товара.4806 *4807 * @param {Element | null} productEl - Корневой DOM-элемент товара (карточка или попап).4808 * @param {object} product - Данные товара или выбранной edition (в т.ч. quantity/editions).4809 * @param {CatalogOptions | null} [opt] - Настройки показа количества.4810 */4811function t_catalog_addProductQuantity(productEl, product, opt) {4812
История файла и сравнение версий
  • 05.12.2026, 07:01:02 · 56c3b845
if (!productEl) return;
4813 const options = opt || {};
4814
4815 const popupButton = productEl.querySelector(
4816 '.t-catalog__prod-popup__btn-wrapper a[href="#order"]:not(.t-catalog__prod-popup__btn_disabled)'
4817 );
4818 const cardButton = productEl.querySelector(
4819 '.t-catalog__card__btns-wrapper a[href="#order"]:not([style*="display: none"])'
4820 );
4821
4822 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
4823 // @ts-expect-error ST-2949_1
4824 let quantity = parseInt(product.quantity, 10);
4825 // @ts-expect-error ST-2949_1
4826 if (isNaN(quantity) && product.editions && product.editions.length) {
4827 // @ts-expect-error ST-2949_1
4828 const firstAvailableEdition = t_catalog_product_getFirstAvailableEditionData(product.editions);
4829 quantity = parseInt(firstAvailableEdition.quantity, 10);
4830 }
4831
4832 if (
4833 (!cardButton && !popupButton) ||
4834 quantity === 0 ||
4835 quantity === 1 ||
4836 options.showStoreBtnQuantity === '' ||
4837 !options.showStoreBtnQuantity
4838 ) {
4839 t_catalog_removeProductQuantity(productEl);
4840 return;
4841 }
4842
4843 if (
4844 !(
4845 (options.showStoreBtnQuantity === 'list' && productEl.classList.contains('t-catalog__card')) ||
4846 (options.showStoreBtnQuantity === 'popup' && productEl.classList.contains('t-catalog__product-snippet')) ||
4847 (options.showStoreBtnQuantity === 'popup' && productEl.classList.contains('t-catalog__product-popup')) ||
4848 options.showStoreBtnQuantity === 'both'
4849 )
4850 ) {
4851 t_catalog_removeProductQuantity(productEl);
4852 return;
4853 }
4854
4855 const mountTarget = popupButton || cardButton;
4856 if (!mountTarget) {
4857 t_catalog_removeProductQuantity(productEl);
4858 return;
4859 }
4860
4861 if (cardButton) {
4862 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
4863 // @ts-expect-error ST-2949_5
4864 t_catalog__prepareCardQuantityWrapper(cardButton);
4865 }
4866
4867 let quantityContainer = productEl.querySelector('.js-product-quantity-widget');
4868 if (!quantityContainer) {
4869 quantityContainer = document.createElement('div');
4870 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
4871 // @ts-expect-error ST-2949_1
4872 quantityContainer.style.display = 'contents';
4873 quantityContainer.classList.add('js-product-quantity-widget');
4874 mountTarget.insertAdjacentElement('beforebegin', quantityContainer);
4875 }
4876
4877 // eslint-disable-next-line no-nested-ternary
4878 const max = isNaN(quantity) ? 99999 : quantity > 0 ? quantity : 1;
4879 /** @type {import('../src/tilda-catalog/components/quantity/index.ts').QuantityWidgetSize | undefined} */
4880 let size;
4881 let borderRadius;
4882 if (productEl.classList.contains('t-catalog__card')) {
4883 // Степпер встает перед кнопкой покупки: размер берем у нее, btnSize — размер первой кнопки
4884 size = t_catalog__resolveCardButtonSize(cardButton, options.btnSize);
4885 }
4886
4887 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
4888 // @ts-expect-error ST-2949_1
4889 if (options.buttonRadius) {
4890 // @ts-expect-error ST-2949_1
4891 borderRadius = options.buttonRadius;
4892 } else if (typeof options.btn1_style === 'string') {
4893 const match = options.btn1_style.match(/border-radius\s*:\s*([^;]+)/);
4894 if (match && typeof match[1] === 'string' && match[1].trim()) {
4895 borderRadius = match[1].trim();
4896 }
4897 }
4898
4899 if (!(quantityContainer instanceof HTMLElement)) return;
4900 const quantityState = t_catalog_createQuantityState({
Предыдущие 100 строкСледующие 100 строк