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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-zoom-2.0.js

Код файла
Версия от 04.12.2026, 04:03:54 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
1701		document1702			.getElementById('allrecords')1703			.contains(document.querySelector('.t-catalog__product-snippet, .t-store__product-snippet'));1704	if (isSnippet && parent) {1705		parentBGColor = parent.style.backgroundColor;1706	}1707 1708	// Проверяем попап1709	const popupParent = targetElement.closest('.t-popup');1710	if (popupParent) {1711		const popupBgColor = popupParent.style.backgroundColor;1712
История файла и сравнение версий
  • 04.12.2026, 04:03:54 · 56c3b845
if (popupBgColor) parentBGColor = popupBgColor;
1713 }
1714
1715 return t_zoom__getThemePreset(parentBGColor, false);
1716}
1717
1718/**
1719 * Применение цветов к элементам модального окна
1720 *
1721 * @param {HTMLElement} parent - родительская запись rec
1722 * @param {HTMLElement} targetElement - текущий элемент, по которому кликнули для открытия зума
1723 */
1724function t_zoom__setModalColors(parent, targetElement) {
1725 const { bgColor, textColor, isDark } = t_zoom__getModalColors(parent, targetElement);
1726
1727 const modalContainer = document.querySelector('.t-zoomer__container');
1728 if (!modalContainer) return;
1729
1730 const controls = document.querySelectorAll('.t-zoomer__ui-item');
1731 const textWrappers = document.querySelectorAll('.t-zoomer__comments');
1732
1733 modalContainer.style.background = bgColor;
1734 modalContainer.style.color = textColor;
1735
1736 const themeClassAction = isDark ? 'add' : 'remove';
1737 controls.forEach(control => control.classList[themeClassAction]('t-zoomer__ui-item--dark'));
1738 textWrappers.forEach(textWrapper => textWrapper.classList[themeClassAction]('t-zoomer__comments--dark'));
1739}
1740
1741/**
1742 * Определяет яркость цвета с учётом прозрачности
1743 *
1744 * @param {Array} color - цвет в формате [R, G, B, A], где R,G,B — 0-255, A — 0-1
1745 * @returns {string} 'black' для тёмных цветов, 'white' для светлых
1746 */
1747function t_zoom_luma_rgba(color) {
1748 if (!color || !Array.isArray(color) || color.length < 3) {
1749 return 'black';
1750 }
1751
1752 const r = color[0];
1753 const g = color[1];
1754 const b = color[2];
1755 const a = color.length >= 4 ? color[3] : 1;
1756
1757 // Смешиваем с белым фоном (255, 255, 255) с учётом прозрачности
1758 const blendedR = r * a + 255 * (1 - a);
1759 const blendedG = g * a + 255 * (1 - a);
1760 const blendedB = b * a + 255 * (1 - a);
1761
1762 // Вычисляем относительную яркость
1763 const luma = 0.2126 * blendedR + 0.7152 * blendedG + 0.0722 * blendedB;
1764
1765 return luma < 128 ? 'black' : 'white';
1766}
1767
1768/**
1769 * transform from HEX/RGB/RGBA to RGBA array
1770 *
1771 * @param {string} color - color in hex (#RGB, #RRGGBB, #RRGGBBAA), rgb() or rgba() format
1772 * @returns {Array} - color in RGBA format [R, G, B, A] where R,G,B are 0-255 and A is 0-1
1773 */
1774function t_zoom_hexToRGBA(color) {
1775 const DEFAULT_RGBA = [255, 255, 255, 1];
1776 if (!color || typeof color !== 'string') return DEFAULT_RGBA;
1777
1778 // Парсинг глобального стиля цвета
1779 const varRegexp = /^var\((--uc-color-color-[a-zA-Z0-9]+),\s*(.+)\)$/;
1780 const varMatch = varRegexp.exec(color);
1781 let colorString = color.trim();
1782 if (varMatch && varMatch[1]) {
1783 const varName = varMatch[1];
1784 const bodyStyle = window.getComputedStyle(document.body);
1785 colorString = (bodyStyle.getPropertyValue(varName) || varMatch[2]).trim();
1786 }
1787
1788 // Парсинг rgba() и rgb() форматов
1789 const rgbaMatch = /^rgba?\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*(?:,\s*([0-9.]+)\s*)?\)$/i.exec(colorString);
1790 if (rgbaMatch) {
1791 const r = parseInt(rgbaMatch[1], 10);
1792 const g = parseInt(rgbaMatch[2], 10);
1793 const b = parseInt(rgbaMatch[3], 10);
1794 const a = rgbaMatch[4] !== undefined ? parseFloat(rgbaMatch[4]) : 1;
1795 return [r, g, b, a];
1796 }
1797
1798 // Парсинг #RRGGBBAA формата (8 символов)
1799 const hexAlphaMatch = /^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(colorString);
1800 if (hexAlphaMatch) {
Предыдущие 100 строкСледующие 100 строк