201*202* @param {HTMLElement} el203* @param {Object} coverParams204* @param {Boolean} isContainsVideo205*/206function t_cover__setCoverParams(el, coverParams, isContainsVideo) {207var isFixedParallax = coverParams['cover-parallax'] === 'fixed';208var isDynamicParallax = coverParams['cover-parallax'] === 'dynamic';209var isbgBase64 = coverParams['bg-base64'] === 'yes';210var parentBG = coverParams['parent-bg'];211212
if (parentBG) { var cover = el.closest('.t-cover'); if (cover) cover.classList.add('t-cover__transparent'); } t_cover__setCoverVideoParams(el, coverParams, isContainsVideo, isFixedParallax); if (isFixedParallax && window.isOpera) el.style.transform = 'unset'; if (isDynamicParallax && !window.t_cover__isMobile) { var coverHeight = t_cover__getPureHeight(el); var isScaled = t_cover__isScaled(el); if (coverHeight < window.innerHeight) { var heightPadding = window.innerHeight * 0.2; const finalHeight = coverHeight + heightPadding + 'px'; el.style.height = isScaled ? `calc(${finalHeight} / var(--t-zoom, 1))` : finalHeight; } t_cover__parallax(el); } if (isbgBase64 && coverParams['cover-bg'] && !isContainsVideo) { var bgIsLoaded = false; var img = document.createElement('img'); img.src = coverParams['cover-bg']; img.onload = function () { if (img.parentElement) img.parentElement.removeChild(img); el.style.backgroundImage = 'url("' + coverParams['cover-bg'] + '")'; el.style.opacity = '1'; bgIsLoaded = true; }; if (!bgIsLoaded) { el.style.backgroundImage = ''; el.style.opacity = '0'; el.style.transition = 'opacity 25ms'; } }}function t_cover__isScaled(element) { const scaledRecord = element?.closest('.t-record_scaled'); if (!scaledRecord) return false; const userHeightElement = scaledRecord.querySelector('[data-content-cover-height]'); const userHeightValue = userHeightElement?.getAttribute('data-content-cover-height'); return userHeightValue && userHeightValue.includes('vh');}/** * set for created video (if it existed) params from data-attributes and process it. * Different ways to create video depend on them types * * @param {HTMLElement} el * @param {Object} coverParams * @param {Boolean} isContainsVideo * @param {Boolean} isFixedParallax */function t_cover__setCoverVideoParams(el, coverParams, isContainsVideo, isFixedParallax) { var videoType = ''; if (coverParams['video-url-youtube']) videoType = 'youtube'; if ( coverParams['video-url-vimeo'] || coverParams['video-url-rutube'] || coverParams['video-url-kinescope'] || coverParams['video-url-vkvideo'] ) videoType = 'iframe'; if ( ((window.t_cover__isMobile || 'ontouchend' in document) && ['on', null].indexOf(coverParams['use-image-for-mobile-cover']) !== -1) || !isContainsVideo ) return; t_cover__setStylesForCoverVideo(el, videoType === 'youtube' ? 'youtube' : ''); switch (videoType) { case 'youtube': t_cover__processYouTubeVideo(el, coverParams); break; case 'iframe': t_cover__processIframeVideo(el, coverParams); break; default: t_cover__processHTML5Video(el, coverParams, isFixedParallax); }}/** * process YouTube video, when it inside viewport