401* @param {Object} coverParams402*/403function t_cover__processIframeVideo(el, coverParams) {404if ('IntersectionObserver' in window) {405var iframeVideoObserver = new IntersectionObserver(function (entries, iframeVideoObserver) {406entries.forEach(function (entry) {407if (!entry.isIntersecting) return;408var target = entry.target;409iframeVideoObserver.unobserve(target);410t_onFuncLoad('t_videoprocessor__processIframeVideo', function () {411window.t_videoprocessor__processIframeVideo(target, coverParams);
}); }); }); iframeVideoObserver.observe(el); } else { t_cover__createIframeCover(el, coverParams); window.addEventListener( 'scroll', t_throttle(function () { t_cover__createIframeCover(el, coverParams); }, 100) ); }}/** * set styles before video has been loaded * * @param {HTMLElement} el - video wrapper * @param {string} type - YouTube- or HTML5-video */function t_cover__setStylesForCoverVideo(el, type) { el.style.backgroundColor = '#000000'; el.style.backgroundImage = type === 'youtube' ? '' : 'url("https://tilda.ws/img/spinner-white.gif")'; el.style.backgroundSize = type === 'youtube' ? '' : 'unset'; el.style.backgroundPosition = type === 'youtube' ? '' : 'center'; el.style.backgroundRepeat = type === 'youtube' ? '' : 'no-repeat'; el.setAttribute('data-content-cover-bg', '');}/** * find arrow and set listener scroll to the next section * * @param {string} id */function t_cover__setListenerToArrow(id) { var rec = document.getElementById('rec' + id); if (!rec) return; var coverArrow = rec.querySelector('.t-cover__arrow-wrapper'); if (!coverArrow) return; coverArrow.addEventListener('click', function () { var recHeight = rec.offsetHeight; if (!recHeight) return; var recBottomPos = rec.offsetHeight + rec.getBoundingClientRect().top + window.pageYOffset; t_cover__scrollToNextSection(recBottomPos); });}function t_cover__initCovers() { var records = document.querySelector('.t-records'); var isEditMode = records && records.getAttribute('data-tilda-mode') === 'edit'; if (isEditMode) return; var coverList = Array.from(document.querySelectorAll('.t-cover__carrier')); coverList.forEach(function (cover) { var id = cover.getAttribute('data-content-cover-id'); if (id) cover_init(id); });}/** * Задаём принудительный перенос строки, если текстовый контент обложки не вмещается по ширине страницы. * Текстовый контент в слайдерах игнорируется, так как позиция слайда может превышать ширину экрана. */function t_cover__setWordWrapOnInit() { var coverWrapperList = Array.from(document.querySelectorAll('.t-cover__wrapper')); var windowWidth = window.t_cover__isMobile ? document.documentElement.clientWidth : window.innerWidth; coverWrapperList.forEach(function (coverWrapper) { if (coverWrapper.closest('.t-slds')) return; if (Math.floor(coverWrapper.getBoundingClientRect().right) > windowWidth) { coverWrapper.style.wordBreak = 'break-all'; } });}t_onReady(function () { // in t_onFuncLoad function check the readiness of the block editor to execute the script t_onFuncLoad('t_cover__initCovers', function () { t_cover__initCovers(); if (document.readyState === 'complete') { t_cover__setWordWrapOnInit(); } else { window.addEventListener('load', t_cover__setWordWrapOnInit); } });});/** * create cover for YouTube, when user will scroll to the current video