Каталог файловtilda-zoom-2.0.js
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
История файла и сравнение версий
if (popupBgColor) parentBGColor = popupBgColor;
1715 return t_zoom__getThemePreset(parentBGColor, false); 1719 * Применение цветов к элементам модального окна 1721 * @param {HTMLElement} parent - родительская запись rec 1722 * @param {HTMLElement} targetElement - текущий элемент, по которому кликнули для открытия зума 1724function t_zoom__setModalColors(parent, targetElement) { 1725 const { bgColor, textColor, isDark } = t_zoom__getModalColors(parent, targetElement); 1727 const modalContainer = document.querySelector('.t-zoomer__container'); 1728 if (!modalContainer) return; 1730 const controls = document.querySelectorAll('.t-zoomer__ui-item'); 1731 const textWrappers = document.querySelectorAll('.t-zoomer__comments'); 1733 modalContainer.style.background = bgColor; 1734 modalContainer.style.color = textColor; 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')); 1742 * Определяет яркость цвета с учётом прозрачности 1744 * @param {Array} color - цвет в формате [R, G, B, A], где R,G,B — 0-255, A — 0-1 1745 * @returns {string} 'black' для тёмных цветов, 'white' для светлых 1747function t_zoom_luma_rgba(color) { 1748 if (!color || !Array.isArray(color) || color.length < 3) { 1755 const a = color.length >= 4 ? color[3] : 1; 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); 1762 // Вычисляем относительную яркость 1763 const luma = 0.2126 * blendedR + 0.7152 * blendedG + 0.0722 * blendedB; 1765 return luma < 128 ? 'black' : 'white'; 1769 * transform from HEX/RGB/RGBA to RGBA array 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 1774function t_zoom_hexToRGBA(color) { 1775 const DEFAULT_RGBA = [255, 255, 255, 1]; 1776 if (!color || typeof color !== 'string') return DEFAULT_RGBA; 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(); 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); 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]; 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) {