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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-cart-1.1.js

Код файла
Версия от 04.12.2026, 04:03:54 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
7201 7202// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)7203// @ts-expect-error ST-2949_27204function tcart_ceil(num) {7205	var result = num * 100;7206	// TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)7207	// @ts-expect-error ST-2949_57208	result = result.toFixed(3);7209	result = Math.ceil(result) / 100;7210	return result;7211}
История файла и сравнение версий
  • 04.12.2026, 04:03:54 · 56c3b845
7212
7213/**
7214 * Показывает всплывающее сообщение о том, что товар добавлен в корзину
7215 * Если корзина открывается сразу после нажатия "Купить", то всплывающего сообщения не будет
7216 *
7217 * @param {string} text - текст сообщения
7218 */
7219function tcart__showBubble(text) {
7220 const MAX_BUBBLES = 4;
7221 const DELAY_MS = 3000;
7222
7223 // Если корзина открывается по кнопке "купить", то не показываем сообщение
7224 const cart = tcart__getCartBlock();
7225 // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538)
7226 // @ts-expect-error ST-2949_3
7227 if (cart.getAttribute('data-opencart-onorder') === 'yes') return;
7228
7229 // Общий контейнер всех сообщений
7230 if (!document.querySelector('.t706__bubble-container')) {
7231 const container = document.createElement('div');
7232 container.className = 't706__bubble-container';
7233 document.body.appendChild(container);
7234 }
7235
7236 const container = document.querySelector('.t706__bubble-container');
7237 // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538)
7238 // @ts-expect-error ST-2949_3
7239 const existingBubbles = container.querySelectorAll('.t706__bubble.t706__bubble_visible');
7240 // Удаляем самый старый bubble
7241 if (existingBubbles.length >= MAX_BUBBLES) {
7242 const oldestBubble = existingBubbles[0];
7243 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
7244 // @ts-expect-error ST-2949_5
7245 tcart__closeBubble(oldestBubble);
7246 }
7247
7248 const bubble = document.createElement('div');
7249 bubble.className = 't706__bubble t706__bubble_visible';
7250 bubble.innerHTML = `
7251 <div class="t706__bubble-close">&times;</div>
7252 <div class="t706__bubble-text t-descr"></div>
7253 `;
7254 // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538)
7255 // @ts-expect-error ST-2949_3
7256 bubble.querySelector('.t706__bubble-text').textContent = tcart__decodeHtml(text);
7257 // @ts-expect-error ST-2949_3
7258 bubble.querySelector('.t706__bubble-close').addEventListener('click', () => {
7259 tcart__closeBubble(bubble);
7260 });
7261
7262 // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538)
7263 // @ts-expect-error ST-2949_3
7264 container.appendChild(bubble);
7265
7266 // Удаление после задержки 3с
7267 const timerId = setTimeout(() => {
7268 tcart__closeBubble(bubble);
7269 }, DELAY_MS);
7270
7271 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
7272 // @ts-expect-error ST-2949_5
7273 bubble.dataset.id = timerId;
7274}
7275
7276/**
7277 * Закрывает всплывающее сообщение
7278 *
7279 * @param {HTMLElement} bubble - элемент bubble для закрытия
7280 */
7281function tcart__closeBubble(bubble) {
7282 // Элемент может быть закрыт вручную или по таймеру
7283 if (bubble) {
7284 const bubbleId = bubble.dataset.id;
7285 clearTimeout(bubbleId);
7286
7287 bubble.classList.remove('t706__bubble_visible');
7288 bubble.classList.add('t706__bubble_hidden');
7289
7290 bubble.addEventListener(
7291 'animationend',
7292 () => {
7293 bubble.remove();
7294 },
7295 { once: true }
7296 );
7297 }
7298}
7299
7300/**
Предыдущие 100 строкСледующие 100 строк