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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-cover-1.0.js

Код файла
Версия от 18.08.2026, 07:00:17 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
701 */702function t_cover__getHeightFromAttr(height) {703	if (!height) return 0;704	if (height.indexOf('vh') !== -1) {705		return (parseInt(height, 10) * document.documentElement.clientHeight) / 100;706	} else {707		return parseInt(height, 10);708	}709}710 711/**712 * update cover height713
История файла и сравнение версий
  • 18.08.2026, 07:00:17 · 56c3b845
*
714 * @param {HTMLElement} rec - current record
715 * @param {number} contentHeight - height of content without padding
716 */
717function t_cover__setRecalculatedHeight(rec, contentHeight) {
718 var coverCarrier = rec.querySelector('.t-cover__carrier');
719 var coverCarrierHeight = coverCarrier ? coverCarrier.getAttribute('data-content-cover-height') : '';
720 if (!coverCarrierHeight) {
721 var coverHeightElem = rec.querySelector('[data-content-cover-height]');
722 coverCarrierHeight = coverHeightElem ? coverHeightElem.getAttribute('data-content-cover-height') : '0';
723 }
724 var setByUserHeight = t_cover__getHeightFromAttr(coverCarrierHeight);
725 var isDynamicParallax = coverCarrier ? coverCarrier.getAttribute('data-content-cover-parallax') === 'dynamic' : '';
726
727 const recordType = t_cover__getRecordType(rec);
728 const isCR30N = recordType === '734';
729 const isTS208 = recordType === '942';
730
731 var contentHeightPadding = window.innerWidth <= 568 ? 40 : 120;
732 var contentHeightExtraPadding = window.innerWidth <= 568 ? 50 : 100;
733 if (isCR30N || isTS208) {
734 contentHeightPadding = 0;
735 contentHeightExtraPadding = 0;
736 }
737
738 const isScaled = t_cover__isScaled(rec);
739 const zoomValue = isScaled ? parseFloat(getComputedStyle(rec).getPropertyValue('zoom')) || 1 : 1;
740
741 if (isScaled) {
742 contentHeight *= zoomValue;
743 contentHeight += contentHeightPadding / zoomValue;
744 if (contentHeight > 1000) contentHeight += contentHeightExtraPadding / zoomValue;
745 } else {
746 contentHeight += contentHeightPadding;
747 if (contentHeight > 1000) contentHeight += contentHeightExtraPadding;
748 }
749
750 var finishHeight = contentHeight > setByUserHeight ? contentHeight : setByUserHeight;
751 var heightPadding = 0;
752 var selectorsList = ['.t-cover', '.t-cover__filter', '.t-cover__carrier', '.t-cover__wrapper'];
753
754 // for support CR30N (querySelector need for Edit-mode)
755 if (isCR30N || rec.querySelector('.t734')) selectorsList.push('.t-slds__items-wrapper');
756
757 if (isScaled && contentHeight === finishHeight) finishHeight /= zoomValue;
758 const needProcessScale = isScaled && finishHeight === setByUserHeight;
759 selectorsList.forEach(function (selector) {
760 // block CR30N has more than one cover carrier
761 var elementList = Array.prototype.slice.call(rec.querySelectorAll(selector));
762 elementList.forEach(function (element) {
763 if (
764 isDynamicParallax &&
765 element &&
766 element.classList.contains('t-cover__carrier') &&
767 finishHeight < document.documentElement.clientHeight
768 ) {
769 heightPadding = document.documentElement.clientHeight * 0.2;
770 const finalHeight = finishHeight + heightPadding + 'px';
771 element.style.height = needProcessScale ? `calc(${finalHeight} / var(--t-zoom, 1))` : finalHeight;
772 } else if (element) {
773 element.style.height = needProcessScale
774 ? `calc(${finishHeight}px / var(--t-zoom, 1))`
775 : finishHeight + 'px';
776 }
777 });
778 });
779 coverCarrier.setAttribute('data-content-cover-updated-height', finishHeight + heightPadding + 'px');
780 var event = document.createEvent('Event');
781 event.initEvent('coverHeightUpdated', true, true);
782 coverCarrier.dispatchEvent(event);
783}
784
785function t_cover__getRecordType(rec) {
786 if (!rec) return '';
787 return (
788 rec.getAttribute('data-parenttplid') ||
789 rec.getAttribute('data-record-type') ||
790 rec.closest('.record')?.getAttribute('data-parenttplid') ||
791 rec.closest('.record')?.getAttribute('data-record-type') ||
792 ''
793 );
794}
795
796/**
797 * @param {HTMLElement} rec - element which can be contains element .t-cover__carrier
798 */
799function t_cover__updateResizeElem(rec) {
800 var allRec = document.getElementById('allrecords');
Предыдущие 100 строкСледующие 100 строк