2001if (inputTextField.value) inputTextField.value = ''; // если были только пробелы - очищаем поле2002const isZero = inputTextField.closest('.tn-atom__form');2003if (isZero) return;20042005if (inputTextField.timerID) clearTimeout(inputTextField.timerID);2006inputTextField.timerID = setTimeout(() => {2007inputTextField.classList.add('t-input-ownanswer_active');2008inputTextField.style.display = 'flex';2009clearTimeout(inputTextField.timerID);2010}, 500);2011}2012
/* a11y: add a visual display of focus when interacting with the page from the keyboardt-submit */function t_forms__addFocusOnTab(rec) { if (window.isMobile) return; var focusableElements = rec.querySelectorAll('.t-input, .t-select'); if (!focusableElements) return; /* check if event focus from mouse or from keyboard */ var handlerType = null; document.addEventListener('keydown', function () { handlerType = 'keyboard'; }); document.addEventListener('mousedown', function () { handlerType = 'mouse'; }); document.addEventListener('visibilitychange', function () { handlerType = 'mouse'; }); Array.prototype.forEach.call(focusableElements, function (focusableElement) { focusableElement.addEventListener('focus', function () { if (handlerType === 'keyboard') { var elementToFocus = focusableElement; if ( elementToFocus.classList.contains('t-input_pvis') || elementToFocus.classList.contains('t-input-phonemask') ) { elementToFocus = elementToFocus.parentElement; } elementToFocus.classList.add('t-focusable'); handlerType = null; } }); focusableElement.addEventListener('blur', function () { focusableElement.classList.remove('t-focusable'); }); });}/* Resetting standard inputs handlers and hovering own event listeners */function t_forms__initEventPlaceholder(rec) { var eventFocus = 'focus'; var eventBlur = 'blur'; if (!document.addEventListener) { eventFocus = 'focusin'; eventBlur = 'focusout'; } t_removeEventListener(rec, eventFocus, t_forms__removePlaceholder); t_addEventListener(rec, eventFocus, t_forms__removePlaceholder, true); t_removeEventListener(rec, eventBlur, t_forms__addPlaceholder); t_addEventListener(rec, eventBlur, t_forms__addPlaceholder, true);}/* Remove placeholder on focus event */function t_forms__removePlaceholder(event) { var targetEvent = event || window.event; var input = targetEvent.target || targetEvent.srcElement; if (input.tagName !== 'INPUT') return; var inputGroup = input.closest('[data-input-lid]'); var strPlace = input.getAttribute('placeholder'); var inputId = ''; if (inputGroup) { inputId = inputGroup.getAttribute('data-input-lid'); } else { var form = input.closest('form'); if (form) inputId = form.getAttribute('data-input-lid'); } if (strPlace && inputId) { window.t_forms__inputData[inputId] = strPlace; input.setAttribute('placeholder', ''); }}/** * Move to input with error * @param {Element} elementToFocus * @param {Element} currentErrorItem */function t_forms__addMoveToInputWithErrorClickHandler(elementToFocus, currentErrorItem) { if (!currentErrorItem || !elementToFocus) return;