Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
Журнал изменений История Git Файлы Tilda MCP Каталог файловtilda-catalog-1.1.js Следить за файлом 1 /**2 * tilda-catalog работает во всех блоках категории ST (store), а также на отдельных страницах товаров, подключенных к каталогу3 **/4 5 import { t_cart__useRootZone } from '../src/tilda-cart/shared/rootZone/index.ts';6 import {7 t_catalog__addVideoIconForGallery,8 t_catalog__getVideoElement,9 t_catalog__svgVideoIcon,10 } from '../src/tilda-catalog/gallery-video/index.ts';11 12 // global variables declarationИстория файла и сравнение версий window.tStoreIsSearchBot = /Bot/i.test(navigator.userAgent);
14 window.tStoreIsMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);15 window.tStoreBrowserLang = (window.navigator.userLanguage || window.navigator.language).toUpperCase().slice(0, 2);17 window.t_store_endpoint = 'store.tildaapi.com';19 const t_store_POPUP_SHOWED_EVENT_NAME = 'catalog:popupShowed';20 const t_store_POPUP_CLOSED_EVENT_NAME = 'catalog:popupClosed';23 * Language override based on attribute25 t_onReady(function () {26 const allRecords = document.getElementById('allrecords');29 const projectLang = allRecords.getAttribute('data-tilda-project-lang');31 window.tStoreBrowserLang = projectLang;34 t_store__setupEndpoint();41 // Временный фикс для Safari 16.3: картинки с position: absolute непропорционально растягивались42 // object-fit: contain исправляет это поведение. Фикс надо удалить по истечению времени43 function t_store_fixImgs() {44 var isSafari16_3 = /Version\/16\.3/.test(navigator.userAgent) && /Safari/.test(navigator.userAgent);45 if (!isSafari16_3) return;47 var recTypes = ['754', '776', '778', '786', '1025'];48 recTypes.forEach(function (recType) {49 var imgs = document.querySelectorAll(50 `[data-record-type="${recType}"] .t-img, [data-parenttplid="${recType}"] .t-img`52 Array.prototype.forEach.call(imgs, function (img) {53 img.style.objectFit = 'contain';59 * This function is responsible for initializing the store61 * @param {string} recid62 * @param {TildaStoreOptions} options65 function t_store_init(recid, options) {66 t_onReady(function () {67 var rec = document.getElementById('rec' + recid);69 if (!window.tStoreInit) {70 window.tStoreInit = {};72 window.tStoreInit[recid] = true;74 const allRecords = document.getElementById('allrecords');77 t_store__setupEndpoint();80 // apply lazy init, if block's count > 7th81 if ('IntersectionObserver' in window && Object.keys(window.tStoreInit).length > 7) {82 window.tStoreInit[recid] = 'lazy';83 var recordObserver = new IntersectionObserver(84 function (entries, observer) {85 entries.forEach(function (entry) {86 if (entry.isIntersecting) {87 var target = entry.target;88 observer.unobserve(target);89 if (window.tStoreInit[recid] === 'lazy') {90 t_store_lazyInit(recid, options);91 window.tStoreInit[recid] = true;97 rootMargin: '150px 0px',100 recordObserver.observe(rec);