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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-popup-1.0.js

Код файла
Версия от 18.08.2026, 07:00:16 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
101	if (popupHeight > window.innerHeight - windowHeightIndent) {102		popupContainer.classList.add('t-popup__container-static');103	} else {104		popupContainer.classList.remove('t-popup__container-static');105	}106}107 108/**109 * Отображение попапа после нажатия на кнопку-триггер110 * @param {node} popup - popup element111 */112function t_popup__showPopup(popup) {
История файла и сравнение версий
  • 18.08.2026, 07:00:16 · 56c3b845
113
if (popup) popup.style.display = 'block';
114
115 setTimeout(function () {
116 popup.focus();
117 var popupContainer = popup ? popup.querySelector('.t-popup__container') : null;
118 if (popupContainer) popupContainer.classList.add('t-popup__container-animated');
119 if (popup) popup.classList.add('t-popup_show');
120 t_onFuncLoad('t_popup__trapFocus', function () {
121 t_popup__trapFocus(popup);
122 });
123 }, 50);
124}
125
126function t_popup__closePopup(popup) {
127 const popupActive = document.querySelector('.t-popup.t-popup_show');
128 const popupContainer = popup.querySelector('.t-popup__container');
129
130 if (popup === popupActive) {
131 const body = document.body;
132 body.dispatchEvent(new CustomEvent('popupHidden'));
133 body.classList.remove('t-body_popupshowed');
134 body.classList.remove('t-quiz__body_popupshowed');
135 }
136
137 popup.classList.remove('t-popup_show');
138 popupContainer.style.removeProperty('transition');
139 popupContainer.classList.remove('t-popup__container_no-transform');
140
141 setTimeout(function () {
142 const hiddenPopups = document.querySelectorAll('.t-popup:not(.t-popup_show)');
143 hiddenPopups.forEach(popup => {
144 popup.style.display = 'none';
145 });
146 }, 300);
147
148 t_popup__addFocusOnTriggerButton();
149}
150
151/**
152 * a11y
153 * Добавление класса на кнопку-триггер для последующего фокусирования
154 * @param {node} element
155 * @param {string} hook - hook for current trigger button
156 */
157function t_popup__addClassOnTriggerButton(element, hook) {
158 var allTriggeredButtons = document.querySelectorAll('.t-popup__triggered-btn');
159 Array.prototype.forEach.call(allTriggeredButtons, function (button) {
160 button.classList.remove('t-popup__triggered-btn');
161 });
162 element.addEventListener('keydown', function (event) {
163 if (event.keyCode === 13) {
164 var target = event.target;
165 var href = target.closest('a[href="' + hook + '"]') ? target : false;
166 if (!href) return;
167 if (!window.isMobile) href.classList.add('t-popup__triggered-btn');
168 }
169 });
170}
171
172/**
173 * a11y
174 * Добавление фокуса на кнопку-триггер после закрытия попапа
175 */
176function t_popup__addFocusOnTriggerButton() {
177 const triggeredButton = document.querySelector('.t-popup__triggered-btn');
178 if (!triggeredButton || triggeredButton.classList.contains('t724__opener')) return;
179 triggeredButton.focus();
180 triggeredButton.classList.remove('t-popup__triggered-btn');
181}
182
183// Polyfill: Element.prototype.matches
184if (!Element.prototype.matches) {
185 Element.prototype.matches =
186 Element.prototype.matchesSelector ||
187 Element.prototype.msMatchesSelector ||
188 Element.prototype.mozMatchesSelector ||
189 Element.prototype.webkitMatchesSelector ||
190 Element.prototype.oMatchesSelector;
191}
192// Polyfill: Element.closest
193if (!Element.prototype.closest) {
194 Element.prototype.closest = function (s) {
195 var el = this;
196
197 while (el && el.nodeType === 1) {
198 if (Element.prototype.matches.call(el, s)) {
199 return el;
200 }
Предыдущие 100 строкСледующие 100 строк