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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-members-userbar.js

Код файла
Версия от 21.10.2026, 07:00:46 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
501	var windowHeight = window.innerHeight;502	var isTop = userBarRect.top < windowHeight / 2;503	var isLeft = userBarRect.left < windowWidth / 2;504	var MARGIN = 10;505 506	userPopupWrap.style.maxHeight = null;507 508	// Абсолютное позиционирование относительно viewport509	userPopup.style.position = 'fixed';510	// Устанавливаем высокий z-index, чтобы перекрыть другие элементы на странице, например блоки меню511	userPopup.style.zIndex = '1000000';512
История файла и сравнение версий
  • 21.10.2026, 07:00:46 · 56c3b845
513 if (isTop) {
514 userPopup.style.top = userBarRect.bottom + MARGIN + 'px';
515 userPopup.style.bottom = 'auto';
516 } else {
517 userPopup.style.bottom = windowHeight - userBarRect.top + MARGIN + 'px';
518 userPopup.style.top = 'auto';
519 userPopup.classList.add('tlk-userbar__popup_bottom');
520 }
521
522 if (isLeft) {
523 userPopup.style.left = userBarRect.left + 'px';
524 userPopup.style.right = 'auto';
525 userPopup.classList.add('tlk-userbar__popup_left');
526
527 const userPopupRect = userPopup.getBoundingClientRect();
528 if (windowWidth - (userPopupRect.left + userPopupRect.width) < 0) {
529 const leftOffset = windowWidth - (userPopupRect.left + userPopupRect.width) - MARGIN;
530 userPopup.style.left = `${leftOffset}px`;
531 }
532 } else {
533 userPopup.style.right = windowWidth - userBarRect.right + 'px';
534 userPopup.style.left = 'auto';
535 }
536
537 // Проверяем и корректируем высоту после позиционирования
538 setTimeout(function () {
539 var userPopupRect = userPopup.getBoundingClientRect();
540
541 if (isTop && windowHeight < userPopupRect.bottom) {
542 userPopupWrap.style.maxHeight = userPopupRect.height - (userPopupRect.bottom - windowHeight + 10) + 'px';
543 } else if (!isTop && userPopupRect.top < 0) {
544 userPopupWrap.style.maxHeight = userPopupRect.height - Math.abs(userPopupRect.top) - 10 + 'px';
545 }
546
547 if (userPopupRect.left < 0) {
548 userPopup.style.left = '10px';
549 }
550 }, 0);
551}
552
553/**
554 * Throttle утилита для ограничения частоты вызова функций
555 * @param {Function} fn
556 * @param {number} wait
557 * @returns {Function}
558 */
559function tma__userbar__throttle(fn, wait) {
560 var lastTime = 0;
561 var timeoutId;
562 return function () {
563 var now = Date.now();
564 var args = arguments;
565 if (lastTime && now - lastTime < wait) {
566 clearTimeout(timeoutId);
567 timeoutId = setTimeout(
568 function () {
569 lastTime = Date.now();
570 fn.apply(null, args);
571 },
572 wait - (now - lastTime)
573 );
574 } else {
575 lastTime = now;
576 fn.apply(null, args);
577 }
578 };
579}
580
581/**
582 * Вешает обработчик клика вне попапа для его закрытия.
583 * Используем mousedown, чтобы закрывать раньше фокуса на элементах внутри.
584 */
585function tma__userbar__addOutsideClickHandler() {
586 if (window['userbar_outside_click']) return; // уже навешан
587
588 /** @param {MouseEvent} e */
589 const handler = function (e) {
590 // Игнорируем правый клик (contextmenu) — закрываем только при обычных кнопках
591 if (e.button && e.button !== 0) return;
592
593 const popup = document.querySelector('.tlk-userbar__popup');
594 if (!popup) return; // уже закрыт
595
596 const target = /** @type {Element} */ (e.target);
597
598 // Если клик внутри попапа — не закрываем
599 if (popup.contains(target)) return;
600
Предыдущие 100 строкСледующие 100 строк